Supporting 'bookkeeping' and 'bin_unused' memory reporters in Gecko
jasone at canonware.com
Mon Nov 3 16:41:07 PST 2014
On Oct 30, 2014, at 3:45 PM, Guilherme Goncalves <ggp at mozilla.com> wrote:
> Our memory reporting tools in Gecko rely on two statistics that don't seem straightforward
> to obtain on latest jemalloc: "bookkeeping" and "bin_unused".
> "bookkeeping" is defined as "Committed bytes which the heap allocator uses for internal data
> structures." , and is currently calculated in our mozjemalloc as the total memory used by
> all arena and chunk headers. As the comment in  suggests, it looks like this could be
> computed by adding up all base allocations in jemalloc3.
An accurate bookkeeping statistic is a bit tricky to maintain. Heap profiling, quarantine, and tcache all perform internal allocation that would need to be tracked, in addition to base allocation and arena chunk header overhead. I can see this being useful though, especially since I've been surprised on multiple occasions when trying to figure out why the stats seemed to disagree with heap profile data.
If you create an issue to track this on Github, that will make sure I don't forget about it. If you're motivated to implement it yourself, let's chat a bit about some design details before you dive in.
> "bin_unused" is defined as "Bytes reserved for bins of fixed-size allocations which do not
> correspond to an active allocation." , and is computed in mozjemalloc by adding up the product
> of each bin's number of free regions by their size.
Isn't bin_unused equivalent to (curruns*nregs - curregs)*size ? Relevant mallctl interfaces:
More information about the jemalloc-discuss