Closed Bug 1976259 Opened 1 year ago Closed 1 year ago

Improve buffer allocator performance with frequent nursery collections

Categories

(Core :: JavaScript: GC, task, P3)

task

Tracking

()

RESOLVED FIXED
143 Branch
Tracking Status
firefox143 --- fixed

People

(Reporter: jonco, Assigned: jonco)

References

(Blocks 1 open bug)

Details

Attachments

(6 external files)

Bug 1973033 causes a small performance regression for the typescript benchmark. Investigating this shows that it can slow down nursery collections and in benchmarks with many nursery collections this can become significant.

The root cause is that on minor GC the buffer allocator currently removes all free regions in chunks containing nursery allocations from the table of free regions it allocates out of, so that the chunks containing them can be swept. This can become significant if there are many such free regions.

The plan is to avoid this by separating free regions that have been recently allocated out of from the set of all known free regions, thus reducing the number of regions that need to be traversed on minor GC.

Severity: -- → N/A
Priority: -- → P3

Currently free regions live in the central BufferAllocator::freeLists. This
change allows individual chunks to optionally own their own free regions. This
will be used to hold their free regions after they have been swept but before
the regions are mreged into the main freeLists.

Currently there are two chunk lists, |mixedChunks| and |tenuredChunks| that
hold all chunks not currently being swept. Currently all free regions are held
in the central |BufferAllocator::freeLists|. On sweeping this is cleared and
rebuilt.

This change adds |availableMixedChunks| and |availableTenuredChunks|. Chunks in
these lists own their own free regions. These are merged into |freeLists| as
needed.

To prepare for sweeping a chunk we either move free regions in that chunk from the central
|freeLists| to the chunk's |freeLists| for tenured chunks, or just remove them
from |freeLists|. On sweep free lists are rebuild and stored in the chunk's
|freeLists| (a future possible option is to skip this if we notice that nothing
has died in the chunk). When a chunk is selected for allocation the contents of
its |freeLists| are moved to the central one and allocation proceeds as normal.

The benefit of all this is to reduce the number of regions in the main
freeLists, which has to be traversed on minor collection.

Similar to FreeLists, these will store lists of chunks binned by the size of their
largest free region. These will be used to efficiently find an availble chunk
to start allocating out of.

This aims to increase the frequency of the fast path hitting and to make us
more likely to reuse free space in existing chunks before allocting new chunks.

This adds the appropriate iterators that make use of |available| rather than
iterating every list.

Pushed by jcoppeard@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/8a4c3479b6d8 https://hg.mozilla.org/integration/autoland/rev/68eac295b0a4 Part 1: Add freeLists to BufferChunk r=sfink https://github.com/mozilla-firefox/firefox/commit/9f6851ded4ac https://hg.mozilla.org/integration/autoland/rev/72ad5e271209 Part 2: Separate chunks that are currently in use for allocation from swept chunks available for future allocation r=sfink https://github.com/mozilla-firefox/firefox/commit/115ac9665dda https://hg.mozilla.org/integration/autoland/rev/cacc9835d03c Part 3: Add ChunkLists to store lists of chunks binned by size r=sfink https://github.com/mozilla-firefox/firefox/commit/fbc06fafb30b https://hg.mozilla.org/integration/autoland/rev/c1341b7d7416 Part 4: Use ChunkLists for available chunks r=sfink https://github.com/mozilla-firefox/firefox/commit/8fefe0291aae https://hg.mozilla.org/integration/autoland/rev/6393d680cb06 Part 5: Add free regions from more than one chunk to the free lists when we run out r=sfink https://github.com/mozilla-firefox/firefox/commit/97c39b6d7d67 https://hg.mozilla.org/integration/autoland/rev/2864db012879 Part 6: Make use of knowledge of which lists are empty when iterating FreeLists and ChunkLists r=sfink
Blocks: 1940491
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: