Write a memory allocator for JSObject slots/elements buffers
Categories
(Core :: JavaScript: GC, enhancement, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox136 | --- | fixed |
People
(Reporter: jonco, Assigned: jonco)
References
(Blocks 5 open bugs)
Details
(Keywords: perf-alert)
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 |
Currently these are allocated with jemalloc. Using our own allocator would have a number of advantages. It would:
- eliminate lock contention between foreground allocation and background sweeping
- reduce the work necessary in the JSObject finalizer
- optimise the nursery promotion check for whether something is in the tenured heap
This is also a step towards the future goal of allocating more internal data in the GC heap.
| Assignee | ||
Updated•1 year ago
|
| Assignee | ||
Comment 1•1 year ago
|
||
| Assignee | ||
Comment 2•1 year ago
|
||
| Assignee | ||
Comment 3•1 year ago
|
||
| Assignee | ||
Comment 4•1 year ago
|
||
The allocator uses a lot of lists because it has arrays of free lists per
supported allocation size. mozilla::LinkedList uses three words for the list
itself which would make this an unnecessarily large memory overhead. This
implementation only uses a single word for the list by storing a pointer to the
first list element rather than having the list be a special node in the list
itself.
Like mozilla::LinkedList it is a circular doubly linked list. Another
difference however is that it uses pointer tagging to remove the need for a
sentinel flag in each node, which ends up taking up a whole word due to
alignement constraints.
| Assignee | ||
Comment 5•1 year ago
|
||
The eventual plan is to replace these with equivalent calls that use the new allcoator.
| Assignee | ||
Comment 6•1 year ago
|
||
The allocator supports three size classes: small, medium and large. This adds
support for the small class for allocations of up to 128 bytes. This is backed
by our existing cell allocator.
This adds a new trace kind 'SmallBuffer' and new alloc kinds in powers of two.
This memory is accounted to the malloc heap size so as to disturb GC scheduling
as little as possible. Eventually the distiction between GC heap and malloc
heap will be removed.
| Assignee | ||
Comment 7•1 year ago
|
||
| Assignee | ||
Comment 8•1 year ago
|
||
| Assignee | ||
Comment 9•1 year ago
|
||
| Assignee | ||
Comment 10•1 year ago
|
||
This adds large buffers using the OS allocator. Buffers of this size are
relatively rare in the JS engine and so are not particularly optimised.
| Assignee | ||
Comment 11•1 year ago
|
||
| Assignee | ||
Comment 12•1 year ago
|
||
Comment 13•1 year ago
|
||
(In reply to Jon Coppeard (:jonco) from comment #0)
- reduce the work necessary in the JSObject finalizer
- optimise the nursery promotion check for whether something is in the tenured heap
How does this help with those things? Does this come from knowing something about the addresses?
| Assignee | ||
Comment 14•1 year ago
|
||
(In reply to Jeff Muizelaar [:jrmuizel] from comment #13)
With the new allocator we can sweep to discard unmarked allocations in 1MB chunks, rather than having to run a finalizer to call free for each one individually. This is more efficient because each free operations updates allocator state and with the new allocator we can do these updates in bulk instead.
Managing the memory ourselves means we can use tricks to work out what kind of memory it is (e.g. for the nursery vs tenured check) such looking at the chunk kind stored at the start of each 1MB chunk. We can't do this for malloced memory because we don't want to make assumptions about the layout of their data structures.
| Assignee | ||
Comment 15•1 year ago
|
||
Comment 16•1 year ago
|
||
Comment on attachment 9445569 [details]
Bug 1911537 - Part 13: Add magic check values for various data structures r?sfink
Revision D233106 was moved to bug 1940065. Setting attachment 9445569 [details] to obsolete.
Comment 17•1 year ago
|
||
Comment 18•1 year ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/20791092320d
https://hg.mozilla.org/mozilla-central/rev/ba658f0d1824
https://hg.mozilla.org/mozilla-central/rev/a15f54d57882
https://hg.mozilla.org/mozilla-central/rev/6c3ba1086317
https://hg.mozilla.org/mozilla-central/rev/543c9847cc28
https://hg.mozilla.org/mozilla-central/rev/ae0acd4fa39c
https://hg.mozilla.org/mozilla-central/rev/af074fe74bd9
https://hg.mozilla.org/mozilla-central/rev/a1bd5de92497
https://hg.mozilla.org/mozilla-central/rev/88009dbfaf57
https://hg.mozilla.org/mozilla-central/rev/f63df5aa379b
https://hg.mozilla.org/mozilla-central/rev/45ae405157e2
https://hg.mozilla.org/mozilla-central/rev/ab05c4f378df
Comment 19•1 year ago
|
||
(In reply to Cristina Horotan [:chorotan] from comment #18)
https://hg.mozilla.org/mozilla-central/rev/20791092320d
https://hg.mozilla.org/mozilla-central/rev/ba658f0d1824
https://hg.mozilla.org/mozilla-central/rev/a15f54d57882
https://hg.mozilla.org/mozilla-central/rev/6c3ba1086317
https://hg.mozilla.org/mozilla-central/rev/543c9847cc28
https://hg.mozilla.org/mozilla-central/rev/ae0acd4fa39c
https://hg.mozilla.org/mozilla-central/rev/af074fe74bd9
https://hg.mozilla.org/mozilla-central/rev/a1bd5de92497
https://hg.mozilla.org/mozilla-central/rev/88009dbfaf57
https://hg.mozilla.org/mozilla-central/rev/f63df5aa379b
https://hg.mozilla.org/mozilla-central/rev/45ae405157e2
https://hg.mozilla.org/mozilla-central/rev/ab05c4f378df
Perfherder has detected a awsy performance change from push ab05c4f378df2225e26149a3fd8fe1e08886482e.
Improvements:
| Ratio | Test | Platform | Options | Absolute values (old vs new) |
|---|---|---|---|---|
| 4% | JS | windows11-64-2009-shippable-qr | fission tp6 | 170,187,023.94 -> 162,785,355.84 |
| 2% | JS | windows11-64-2009-shippable-qr | fission tp6 | 166,389,041.85 -> 162,804,663.42 |
Details of the alert can be found in the alert summary, including links to graphs and comparisons for each of the affected tests.
If you need the profiling jobs you can trigger them yourself from treeherder job view or ask a sheriff to do that for you.
You can run these tests on try with ./mach try perf --alert 43303
For more information on performance sheriffing please see our FAQ.
Description
•