Move the chunk cache into each arena.
Categories
(Core :: Memory Allocator, enhancement)
Tracking
()
People
(Reporter: pbone, Assigned: jstutte)
References
(Blocks 1 open bug)
Details
Attachments
(4 obsolete files)
Currently all arenas share a single cache of chunks, the cache isn't clear about how much of those chunks are resident. Note that on Windows all the chunks in the cache are exactly 1MB. On other platforms they can vary in size. To support Bug 1979830 the chunk cache should be made per-arena. But should be landed in a separate bug (this bug) so it can be tested independently.
We should evaluate how non-arena chunks should be handled as there's a risk of degrading performance on platforms other than Windows. There may also be an opportunity
| Assignee | ||
Comment 1•5 months ago
|
||
Pure data-structure refactor. Replace the single mSpare slot with a
DoublyLinkedList<arena_chunk_t, SpareChunkListTrait> mSpareChunks plus
an mNumSpareChunks counter. Behavior is identical: the list holds at
most one element (DemoteChunkToSpare evicts the oldest when size > 1),
so reuse and dealloc patterns match the prior single-spare semantics.
The original spare-prioritisation is preserved: spare chunks stay in
mChunksDirty, and Purge prefers purging their dirty pages first (a
spare isn't allocated from until mRunsAvail is exhausted, so its pages
are the least likely to be re-faulted soon). The former single-slot
mSpare check in Purge becomes a scan over mSpareChunks.
The list shape sets up the per-arena retention pool used by Part 2.
Drive-by: rename arena_chunk_t::mChunksDirtyElim to mChunksDirtyElement
and fix the typo mChunksMavisedElim to mChunksMadvisedElement, and add
the const Get() overload to DirtyChunkListTrait for symmetry with the
new SpareChunkListTrait.
Updated•5 months ago
|
| Assignee | ||
Comment 2•5 months ago
|
||
Allow each arena to retain a configurable number of empty chunks
between alloc/free cycles, so workloads with chunk-level churn don't
pay mmap/unmap round trips when the chunk count oscillates near the
working-set boundary.
arena_params_t::mMinSpareRetention sets the floor; default 1.
UpdateMaxDirty drops the effective floor to 0 on background.
Purge gains a preamble that drains excess spares oldest-first:
PurgeUnconditional drains to 0, otherwise to mMinSpareRetention. On
64-bit the drain also gates on ShouldContinuePurge.
DemoteChunkToSpare skips its eviction path when lazy purge is enabled
-- Purge's preamble handles the drain instead.
PurgeStats gains spares_drained / spares_retained, surfaced via
PurgeArenaMarker.
No arena opts in to a non-default floor in this patch; Part 3 opts in
the default arena and the JS arenas.
| Assignee | ||
Comment 3•5 months ago
|
||
The default arena and the four JS arenas (MallocArena,
BackgroundMallocArena, ArrayBufferContentsArena, StringBufferArena)
set mMinSpareRetention = 4 on 64-bit. 32-bit stays at the default of 1
(address-space budget).
These arenas see the most chunk-level alloc/free churn, so a small
warm pool of empty chunks meaningfully reduces mmap/unmap rate.
| Assignee | ||
Comment 4•5 months ago
|
||
Remove chunk_record / chunk_recycle and the global gChunksBySize /
gChunksByAddress trees (with chunks_mtx and gRecycledSize) that
implemented cross-arena address-space reuse. system_pages_map now maps
directly, gSystemChunkAllocator.unmap and BaseAlloc::free unmap
directly, and the gRecycleLimit / CAN_RECYCLE / ChunkType machinery is
removed with them.
With the per-arena spare-chunk retention from Parts 1-3 covering the
short-lived reuse window, the global cache provided little measurable
benefit: entries were purged (decommitted) on insertion, so any reuse
paid a recommit/fault anyway. Dropping it also retires the cross-arena
VA reuse that bug 1979830 wants gone for security.
extent_node_t loses its recycle-only mChunkType union member; a node
now only carries the arena association used by the huge-allocation
tree.
The coalescing/best-fit recycling logic itself is not gone for good --
it is reintroduced as a reusable ExtentPool class in the next patch
(bug 1979830 Part 1), its only remaining consumer.
Updated•5 months ago
|
Updated•5 months ago
|
Updated•5 months ago
|
Updated•5 months ago
|
Updated•4 months ago
|
Updated•4 months ago
|
Updated•4 months ago
|
Updated•4 months ago
|
| Assignee | ||
Updated•4 months ago
|
| Reporter | ||
Comment 6•4 months ago
|
||
It's not a duplicate, We can land the performance win of Bug 2055507 sooner if we leave the change to the main chunk cache in this bug.
| Reporter | ||
Updated•4 months ago
|
Description
•