PSA: Heap usage metrics coming your way in chrome://profiler

11 views
Skip to first unread message

Sigurður Ásgeirsson

unread,
Dec 2, 2016, 3:23:28 PM12/2/16
to chromium-dev
Hey y'all,

I've just landed this CL . This adds some heap usage metrics to the venerable profiler in chrome://profile. Initially this is disabled for official builds, but I hope to change that shortly (once the bugs have been shaken out). On Windows, due to how this hooks into the allocator, it's only available in non-component release builds, alas.

This instrumentation will allow you to see the average number of allocations & frees, the average net number of heap bytes consumed, as well as the high watermark of outstanding bytes during a single task execution. You can also add extra columns to see the cumulative metrics for your tasks. 
pasted1
This builds on all the existing goodness of chrome://profiler, which means you can break this down by process type, thread or a variety of other ways. You can grab multiple snapshots and diff them, as well as save the data you're looking at for a closer perusal later, or to attach to bugs.

You can also use the existing macros in base/profiler/scoped_profile.h to narrow down the profiling scope.

On Windows (and hopefully one day on other platforms) the byte counts include a lower-bound estimate of the heap overhead incurred on allocation. Comparing the "Allocated bytes" and the "Overhead bytes" cumulative metrics can be instructive, and may give you data that'd motivate a move to "clumpier" data structures if your data is a cloud of small allocs :).

Now, while "cumulative allocated bytes" - "cumulative freed bytes" is the number of outstanding bytes, this instrumentation is probably not super-helpful for finding leaks or memory hogs. Since individual tasks can be net positive or net negative in memory consumption, it's generally not possible to see where the outstanding allocations originated.
It should however be helpful in optimizing your code toward less memory churn and heap overhead.

Please be on the lookout for weirdness like e.g. this <http://crbug.com/669593>, and do let me know if you find this useful.

Siggi
Reply all
Reply to author
Forward
0 new messages