Implement semispace nursery collection
Categories
(Core :: JavaScript: GC, enhancement, P2)
Tracking
()
Tracking | Status | |
---|---|---|
firefox126 | --- | fixed |
People
(Reporter: sfink, Assigned: jonco)
References
(Depends on 2 open bugs, Blocks 2 open bugs, Regressed 1 open bug)
Details
(Whiteboard: [sp3])
Attachments
(31 files)
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review |
The goal is to reduce unnecessary tenuring, when we tenure short-lived but recent allocations because we hit the end of the nursery. These appear to be fairly frequent in the matrix-react benchmark, for example.
Reporter | ||
Comment 1•3 years ago
|
||
Current design: allocate a large contiguous region of virtual memory space, roughly double the desired size of the nursery. Use the second half as the nursery space initially. When collecting, leave some portion in the nursery (call it K bytes). Back up the start of the nursery-allocatable region by K and run the mutator again to fill it up. Collect all but the K most recently allocated bytes, including the K-sized chunk left over from the previous iteration. Keep backing up the nursery start until hitting the beginning of the virtual memory area, then jump back to using the second half and repeat. In pictures, using 1/3 the size of the initial nursery-allocatable space as K:
[______] initial empty nursery
[___XXX] allocate into 2nd half
[_____X] collect all but last 1/3 of allocated space
[__XXXX] allocate into region just before preserved space
[____X_] collect all but most recent K sized chunk
[_XXXX_] allocate
[___X__] collect
[XXXX__] allocate
[__X___] collect
[__XXXX] now allocating into 2nd half again
[_____X] repeat
There are many details, but that's the basic idea.
Updated•3 years ago
|
Reporter | ||
Comment 2•3 years ago
|
||
Reporter | ||
Comment 3•3 years ago
|
||
Reporter | ||
Comment 4•3 years ago
|
||
Reporter | ||
Comment 5•3 years ago
|
||
Reporter | ||
Comment 6•3 years ago
|
||
Reporter | ||
Comment 7•3 years ago
|
||
Reporter | ||
Comment 8•3 years ago
|
||
Reporter | ||
Comment 9•3 years ago
|
||
Reporter | ||
Updated•3 years ago
|
Reporter | ||
Comment 10•3 years ago
|
||
Reporter | ||
Comment 11•3 years ago
|
||
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Assignee | ||
Comment 12•2 years ago
|
||
I spent a while looking into a partial nursery collection because I originally thought this would work out better than a semispace nursery.
This was based on the assumption that most live data would be at the end of the nursery. The idea was that we could collect everything up to some tail region, which we would skip until the next collection which would collect everything up to the new tail. This turned out not to be as good as I had thought because we would have to promote everything referenced from the tail region even if it was unreachable, unless we also traced through this region. Also, tracking the tail region within a nursery made up of discontiguous chunks proved complex and error prone.
Instead I made the decision to implement a standard semispace nursery.
Assignee | ||
Comment 13•2 years ago
|
||
Add a GC parameter and pref for semispace nursery which is disabled by default.
Enable it for the shell rootanalysis job to get get some test coverage.
Assignee | ||
Comment 14•2 years ago
|
||
Store these separately because the number of chunks will be per semispace and
the capacity will be the total for both semispaces when semispace collection is
enabled.
Depends on D196431
Assignee | ||
Comment 15•2 years ago
|
||
This moves a bunch of nursery data fields to a new Space struct. We will add a
second one of these to support semispace collection.
Depends on D196432
Assignee | ||
Comment 16•2 years ago
|
||
Depends on D196433
Assignee | ||
Comment 17•2 years ago
|
||
Depends on D196434
Assignee | ||
Comment 18•2 years ago
|
||
This pushes a bunch of methods into the Space struct doesn't have much effect
beyond alterating between the semispaces.
Depends on D196435
Assignee | ||
Comment 19•2 years ago
|
||
Implement semispace nursery by promoting some cells to a second nursery
generation. Since we've swapped semispaces and are evicting from-space to
to-sapce, promotion works like normal allocation. In the same way, swapping
store buffers makes post barriers also work like normal.
While tracing store buffers, we may need to re-add the store buffer entry. The
TenuringTrace has a flag that is set if any allocation is made into the next
generation which is used to check whether this is necessary.
Whether to tenure a particular nursery cell is based on its position in the
nursery. Cells that were promoted in the last collection are tenured.
Sometimes we tenure everything and totally empty the nursery. This is decided
based on the nursery collection reason. The GC uses the EVICT_NURSERY reason
to make sure everything is tenured during major GC.
Depends on D196438
Assignee | ||
Comment 20•2 years ago
|
||
Since we won't always be tenuring things this renames use of the term
during nursery collection to 'promotion' instead.
I haven't yet renamed TenuringTracer. Naming suggestions welcome.
Depends on D196440
Assignee | ||
Comment 21•2 years ago
|
||
Depends on D196441
Assignee | ||
Comment 22•2 years ago
|
||
Depends on D196442
Assignee | ||
Comment 23•2 years ago
|
||
Depends on D196443
Assignee | ||
Comment 24•2 years ago
|
||
Depends on D196444
Assignee | ||
Comment 25•2 years ago
|
||
Without a doubt this was the hardest part to get working.
Depends on D196445
Assignee | ||
Comment 26•2 years ago
|
||
This sweeps the nursery entries in the NurseryAwareHashMap after minor GC
rather than just clearing them.
Depends on D196446
Assignee | ||
Comment 27•2 years ago
|
||
We now have to track numbers of objects promoted to the second generation so we
can check this against the number tenured.
This removes a small optimsation I made a while ago where we assume we an
allocation site is not in the linked list if it has a nursery allocation count of
zero. That no longrer holds because it can be in the list if the second
generation count is non-zero.
This changes some pretenuring parameters. I found this important at the time,
but I'm going to go back and check it's still necessary.
Depends on D196447
Assignee | ||
Comment 28•2 years ago
|
||
The atom cache is cleared after minor GC. Arguably we should sweep it instead
to leave strings that were promoted to the second nursery generation. I don't
know how important this is.
Depends on D196448
Assignee | ||
Comment 29•2 years ago
|
||
Depends on D196449
Assignee | ||
Comment 30•2 years ago
|
||
This filters CycleCollectedRuntime::mNurseryObjects so that only objects that
have died are finalized, and objects promoted to the second nursery generation
remain. Also a post barrier is added when updating a wrapper cache object.
I'll ask Andrew for review on this too when it gets closer to landing.
Depends on D196450
Assignee | ||
Comment 31•2 years ago
|
||
We use a second list so that blocks to be freed go for two nursery collections
before being freed, unless we're evicting the whole nursery.
I had to suffle things around at the start of GC so that we always start a
background free for the blocks queued by purgeRuntime().
Depends on D196451
Assignee | ||
Comment 32•2 years ago
|
||
Depends on D196452
Assignee | ||
Comment 33•2 years ago
|
||
Also disable semispace nusery collection in a few JS API tests where it causes them to fail.
Depends on D196453
Updated•1 year ago
|
Updated•1 year ago
|
Comment 34•1 year ago
|
||
Comment 35•1 year ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/754b631234b1
https://hg.mozilla.org/mozilla-central/rev/916e8b1c1f1f
https://hg.mozilla.org/mozilla-central/rev/ac216a48df3a
https://hg.mozilla.org/mozilla-central/rev/3bb94de73aeb
https://hg.mozilla.org/mozilla-central/rev/6f5d85e44b88
https://hg.mozilla.org/mozilla-central/rev/859314ce1f64
https://hg.mozilla.org/mozilla-central/rev/855def3146ee
https://hg.mozilla.org/mozilla-central/rev/784ef6379bd0
https://hg.mozilla.org/mozilla-central/rev/81f2b46b7289
https://hg.mozilla.org/mozilla-central/rev/ea0235576102
https://hg.mozilla.org/mozilla-central/rev/921ab63cd1eb
https://hg.mozilla.org/mozilla-central/rev/6e7744490c9f
https://hg.mozilla.org/mozilla-central/rev/55650abb3bd2
https://hg.mozilla.org/mozilla-central/rev/21128c6c3b71
https://hg.mozilla.org/mozilla-central/rev/96c952c35012
https://hg.mozilla.org/mozilla-central/rev/912a737ad481
https://hg.mozilla.org/mozilla-central/rev/e6b185287249
https://hg.mozilla.org/mozilla-central/rev/88b7d0819d7a
https://hg.mozilla.org/mozilla-central/rev/5e4831d9d689
https://hg.mozilla.org/mozilla-central/rev/c2a7dd9ea790
https://hg.mozilla.org/mozilla-central/rev/59783e60bc55
https://hg.mozilla.org/mozilla-central/rev/c02cbc98a3b0
Updated•6 months ago
|
Description
•