Initial implementation of parallel marking
Categories
(Core :: JavaScript: GC, task, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox109 | --- | fixed |
People
(Reporter: jonco, Assigned: jonco)
References
(Blocks 1 open bug)
Details
Attachments
(12 files, 1 obsolete file)
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 |
This bug is to a land an initial implementation of parallel marking for evaluation. It will be disabled by default can be enabled at runtime through a preference.
Assignee | ||
Comment 1•2 years ago
|
||
Assignee | ||
Comment 2•2 years ago
|
||
These will hold the mark stacks of different marking threads used by parallel
marking between slices. For everything else the first marker is used.
Depends on D163461
Assignee | ||
Comment 3•2 years ago
|
||
This adds GCRuntime::markingWorkerCount() which determines how many markers get
created. This is currently capped at a maximum of two. The markers vector is
updated whenever the GC parameters affecting its length change.
Depends on D163462
Assignee | ||
Comment 4•2 years ago
|
||
Each arena can only be on one list so having a delayed marking list per marker
doesn't work. This is only used on OOM so we don't need to worry about
performance so we can move this state to the GCRuntime. We'll make access to it
synchronised in later patches.
Depends on D163463
Assignee | ||
Comment 5•2 years ago
|
||
The mark bitmap is represented using relaxed atomics. Currently we update this
using separate load and store operations where possible as this is more
efficient but this is only possible if there are no concurrent writes.
Parallel marking will perform concurrent writes to the marking bitmap so
requires updates to be performed atomically.
The patch adds methods that are correct in the face of multiple writes
(different threads won't stomp over each others' updates) however the
markIfUnmarkedAtomic method can return false positives. It works out faster
overall to allow this and tolerate multiple threads trying to mark the same
thing at the same time occasionally than to have the extra synchronisation
overhead of avoiding it.
Depends on D163464
Assignee | ||
Comment 6•2 years ago
|
||
This adds a new marking option which calls the atomic version of the
markIfUnmarked method.
Assignee | ||
Comment 7•2 years ago
|
||
Even though this doesn't do anything during parallel marking (because the check
only when we're in weak marking mode), this made a surprising different to the
performance of parallel marking.
The patch adds a marking option for this and only includes it in the normal
marking path. It also had to be moved from traceChildren methods into GCMarker.
Depends on D163488
Assignee | ||
Comment 8•2 years ago
|
||
This would otherwise assert during parallel marking. It's safe to check the
mark bits concurrently as we don't mutate anything.
This adds 'readonlyThreadsafe' methods to SparseBitmap along the same lines as
those in mozilla::HashMap.
Depends on D163490
Assignee | ||
Comment 9•2 years ago
|
||
This adds the classes ParallelMarker and ParallelMarkTask. The former
coordinates parallel marking between multiple threads each running the latter
task.
This uses a form of work stealing. Each task marks while has work (and budget)
and then adds itself to a list of waiting tasks. While marking we check for
waiting tasks and if any are present we transfer some work to the waiting task
and resume it.
Synchronisation is acomplished using the GC lock except for checking for
waiting tasks which uses a relaxed atomic.
The main parts of marking are converted to use parallel marking if enabled.
Depends on D163491
Assignee | ||
Comment 10•2 years ago
|
||
The allows some hash table lookups to occur in parallel which is safe since we
are not mutating anything.
Depends on D163493
Assignee | ||
Comment 11•2 years ago
|
||
This patch makes us take the GC lock during parallel marking in a few places
where it's necessary, notably while marking weak maps.
Depends on D163494
Assignee | ||
Comment 12•2 years ago
|
||
When we mark a gray GC thing black during GC and it has children in uncollected
zones we must make sure they end up black too otherwise we will have created a
black to gray edge.
This happens using the standard gray unmarking path, and this can call back
into GC marking if it reaches a GC thing that is in a zone being collected.
All of this needs to work with parallel marking.
The patch moves the gray unmarking stack to GCMarker so there is a separate one
available per parallel task and uses atomic marking function in case we're
running in parallel. It would be slightly better to only use the atomic
accesses if we are marking in parallel, but I haven't done that here.
Depends on D163495
Assignee | ||
Comment 13•2 years ago
|
||
This enables parallel marking for the tsan and compacting test jobs, which
should get us some decent coverage for the shell.
Comment 14•2 years ago
|
||
Comment on attachment 9306483 [details]
Bug 1802897 - Part 13: Enable parallel marking for some shell tests r?sfink
Revision D163740 was moved to bug 1804272. Setting attachment 9306483 [details] to obsolete.
Comment 15•2 years ago
|
||
Comment 16•2 years ago
|
||
Backed out for causing build bustages on Marking.cpp
- Backout link
- Push with failures
- Failure Log
- Failure line: /builds/worker/checkouts/gecko/js/src/gc/Marking.cpp:1359:19: error: constexpr if condition evaluates to 2, which cannot be narrowed to type 'bool' [-Wc++11-narrowing]
Assignee | ||
Updated•2 years ago
|
Comment 17•2 years ago
|
||
Comment 18•2 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/8700caa2ba0d
https://hg.mozilla.org/mozilla-central/rev/4c918a83a58a
https://hg.mozilla.org/mozilla-central/rev/e9d012cf0a17
https://hg.mozilla.org/mozilla-central/rev/b46dce3f55cf
https://hg.mozilla.org/mozilla-central/rev/4b71f2915682
https://hg.mozilla.org/mozilla-central/rev/122ddd142e5c
https://hg.mozilla.org/mozilla-central/rev/805404aeaae8
https://hg.mozilla.org/mozilla-central/rev/cdf0c1609e11
https://hg.mozilla.org/mozilla-central/rev/91cff8916db3
https://hg.mozilla.org/mozilla-central/rev/dcfea8bcfa2c
https://hg.mozilla.org/mozilla-central/rev/dc838ec18940
https://hg.mozilla.org/mozilla-central/rev/5474e6f89982
Assignee | ||
Updated•2 years ago
|
Description
•