nix icon indicating copy to clipboard operation
nix copied to clipboard

`gc.heapSize` is subject to rounding on the order of MBs

Open roberth opened this issue 7 months ago • 1 comments

Is your feature request related to a problem?

It's hard to observe changes in the collectability of heap objects with NIX_SHOW_STATS.

gc.heapSize would be the measurement for this, but it is too coarse grained, and doesn't accurately reflect heap changes due to changes in expressions.

We're using this (through the _safe call instead):

Includes empty blocks and fragmentation loss. Includes some pages that were allocated but never written.

https://github.com/ivmai/bdwgc/blob/9e224cb87759c1ca420a5cd5c6082d29b9ed58cb/include/gc/gc.h#L780-L793

Proposed solution

Dig through the stats, and/or the code that produces it to figure out if we can get a better number that measures memory retention in a more fine grained manner.

Alternative solutions

Additional context

Checklist


Add :+1: to issues you find important.

roberth avatar Jun 08 '25 11:06 roberth

It would also be good to have separate stats for max heap size and final heap size, if possible.

roberth avatar Jun 08 '25 11:06 roberth