Optimize handling of weakmaps in major GC
Categories
(Core :: JavaScript: GC, enhancement)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox138 | --- | fixed |
People
(Reporter: jonco, Assigned: jonco)
References
(Blocks 1 open bug)
Details
Attachments
(8 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 |
Bug 1952626 contains a (pretty artificial) weakmap benchmark where we do very poorly, with a lot time spent in major GC. This bug is about improving the way weakmaps are treated during major GC. The patches improve performance by about 20% in local testing.
| Assignee | ||
Comment 1•1 year ago
|
||
This renames exposeGCThingToActiveJS to valueReadBarrier, consolidtates
protected method definitions and moves a comment about delegates next to the
code it is referring to.
| Assignee | ||
Comment 2•1 year ago
|
||
Previously ObjectWeakMap was a wrapper around a JSObject to JS::Value weakmap
with a slightly different API. This didn't make sense because we actually
support object to object maps directly, so storing the values as JS::Value is
pointless.
The patch removes this and replaces its uses with the standard weakmap
template. A 'maybeGet' method is added to get the value for a ket or a default
constructed Value if it is missing, since this is useful and frequently used.
Better name suggestions accepted.
| Assignee | ||
Comment 3•1 year ago
|
||
This caches information about whether a weakmap is likely to contain keys with
delegates or symbol keys so it can hopefully skip scanning the map during GC.
Note that whether a key has a delegate can change if the object is swapped with
a wrapper, so we have to count keys which are able to be swapped too.
| Assignee | ||
Comment 4•1 year ago
|
||
An exception is made for deleting empty maps to allow OOM handling.
| Assignee | ||
Comment 5•1 year ago
|
||
All clients use HeapPtr anyway. Adding the barriers internally will allow us to
elide them on destruction.
| Assignee | ||
Comment 6•1 year ago
|
||
I used to thing this was neat and made things simpler, but I've come to realise
it does not. Embedding the map in WeakMap gives much more control at the cost
of writing a few simple forwarding methods.
| Assignee | ||
Comment 7•1 year ago
|
||
Currently we trigger write barriers when we destroy a weakmap but this is
ununecessary. This removes them by making the actual storage of the map
unbarriered, and casting it to a barriered map for all mutator accesses.
| Assignee | ||
Comment 8•1 year ago
|
||
This is already handled in WeakMap::lookup.
Comment 11•1 year ago
|
||
Comment 12•1 year ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/268e09591fe6
https://hg.mozilla.org/mozilla-central/rev/f86f9ae1d62c
https://hg.mozilla.org/mozilla-central/rev/32a805058a1e
https://hg.mozilla.org/mozilla-central/rev/5074cd5ae805
https://hg.mozilla.org/mozilla-central/rev/6af14659fcba
https://hg.mozilla.org/mozilla-central/rev/4fdf0f4b9ef6
https://hg.mozilla.org/mozilla-central/rev/82f91932ddfb
https://hg.mozilla.org/mozilla-central/rev/3cf06f78a8fd
| Assignee | ||
Updated•8 months ago
|
Description
•