Supporting 'bookkeeping' and 'bin_unused' memory reporters in Gecko

Jason Evans 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." [1], and is currently calculated in our mozjemalloc as the total memory used by
> all arena and chunk headers. As the comment in [2] 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." [3], 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:

	stats.arenas.<i>.bins.<j>.curruns
	arenas.bin.<i>.nregs
	stats.arenas.<i>.bins.<j>.curregs
	arenas.bin.<i>.size

Thanks,
Jason


More information about the jemalloc-discuss mailing list