Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
runtime: background scavenger is overzealous with small heaps #32012
Today the background scavenger will treat newly-mapped heap memory as unscavenged, which means that if you have an application with a small heap (such as 24 MiB) on Linux, then it will scavenge 64 - 24 = 40 MiB, which is a fair bit of work to be doing.
However, those 40 MiB were never touched in the first place, so they haven't been faulted in and don't count against your RSS anyway. The scavenging work is totally unnecessary.
Instead, we should probably treat newly-mapped memory as scavenged so that this issue is avoided. It also more accurately represents reality, and by tracking this in
The one caveat here is that on Windows we currently map new heap memory as
There isn't currently a noticeable performance impact from this so I don't think this is terribly high priority, but it could affect the "warm-up" time of applications on systems without huge pages and with larger arena sizes (e.g. Linux w/o THP, AIX, etc.). Aside from that, it would also be nice to just make the accounting a little bit better here for small heaps.