Closed Bug 1021017 Opened 10 years ago Closed 9 years ago

How to profile which call sites are generating garbage?

Categories

(DevTools :: Performance Tools (Profiler/Timeline), defect, P3)

defect

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1136945

People

(Reporter: jujjyl, Unassigned)

Details

Attachments

(1 file)

It is possible to somehow profile all data that is garbage collected during an application lifetime?

I would like to have a tool that I could start/stop and while active, it'd log all objects that were collected, and the JS callstacks of where those allocations occurred. Is there a way to achieve that in Firefox?
OS: Mac OS X → All
Priority: -- → P3
Hardware: x86 → All
The new perf tool in Nightly can log allocation sites. We'll show GC markers pretty soon, so you might want to keep an eye on that. Duping this to bug 1136945 for now.
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → DUPLICATE
Amazing news! Are there documentation for that somewhere? (or too soon to ask?) I know a lot of Emscripten developers are interested in that feature!
Not yet! We might make this an official release for Firefox 40. Follow this dependency tree: https://bugzilla.mozilla.org/showdependencytree.cgi?id=1075567&hide_resolved=1
For posterity, cog > "record memory" > take a profile > "Allocations" tab in profile
Attached image allocation_profiler.png
Thanks! I gave the tool a try, and it looks great! I am seeing two odd things there though:

1. It looks like when I do multiple runs of multiple pages, the tree view keeps showing entries from a previous profile run. See the attached screenshot above. Notice in that run that at the very bottom there is a highlighted tree leaf "cpuProfiler_frameStart_cpuprofiler.js:122:2" from dl.dropboxusercontent.com. However the page I am running was loaded from a file:/// url, and the file:/// url doesn't load anything from dropbox. I had previously navigated in that tab to dropbox though. Also notice how the item is showing 0 allocation samples, but at the same time it is a leaf item, which looks very odd.

2. Also something that is visible from that screenshot is that it has got exactly one allocation in "subarray (self-hosted:3174:11)", but that does not match up. The profile is about 10 seconds in length, and it is running a smooth animation at 60fps, and the page does exactly one glBufferSubData call (subarray call) per frame, so I am expecting that the tool should show about 600 allocations from that call site. I think Nick's tool that utilized the browser console from before was able to show all allocations, but this tool seems to be somehow sampled and does not capture all allocations necessarily, is that correct? If so, could it be changed to capture all allocations? (even though that might be slow?)
(In reply to Jukka Jylänki from comment #6)
> Thanks! I gave the tool a try, and it looks great! I am seeing two odd
> things there though:
> 
> 1. It looks like when I do multiple runs of multiple pages, the tree view
> keeps showing entries from a previous profile run. See the attached
> screenshot above. Notice in that run that at the very bottom there is a
> highlighted tree leaf "cpuProfiler_frameStart_cpuprofiler.js:122:2" from
> dl.dropboxusercontent.com. However the page I am running was loaded from a
> file:/// url, and the file:/// url doesn't load anything from dropbox. I had
> previously navigated in that tab to dropbox though. Also notice how the item
> is showing 0 allocation samples, but at the same time it is a leaf item,
> which looks very odd.

Not sure what's up here.

> 2. Also something that is visible from that screenshot is that it has got
> exactly one allocation in "subarray (self-hosted:3174:11)", but that does
> not match up. The profile is about 10 seconds in length, and it is running a
> smooth animation at 60fps, and the page does exactly one glBufferSubData
> call (subarray call) per frame, so I am expecting that the tool should show
> about 600 allocations from that call site. I think Nick's tool that utilized
> the browser console from before was able to show all allocations, but this
> tool seems to be somehow sampled and does not capture all allocations
> necessarily, is that correct? If so, could it be changed to capture all
> allocations? (even though that might be slow?)

It currently samples with P = 1/20, although this is a configurable pref and you could change it. ni? Jordan for the pref name.
Flags: needinfo?(jsantell)
Thanks for trying this out, Jukka!

devtools.performance.memory.sample-probability to change the sample probability -- not sure how low this can go

I suspect the call tree showing samples outside of the expected time frame is related to bug 1145738 -- the profiler's start time, since it's used platform-wide, got messed up at some point, so it's filtering an incorrect time range (so, showing you frames from a previous content page). The patch there should hopefully rule out that happening, but I'm definitely keeping an eye on it!
Flags: needinfo?(jsantell)
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: