Consider using BufferAllocator for OOL data for wasm GC objects
Categories
(Core :: JavaScript: WebAssembly, enhancement, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox145 | --- | fixed |
People
(Reporter: rhunt, Assigned: jonco)
References
(Blocks 3 open bugs)
Details
Attachments
(4 files)
The GC now has support for a BufferAllocator [1] which can be used to allocate variable sized extra data and associate it with a GC object. This looks like it could replace our use of the Malloc'edBlockCache [2]. We should see how well it performs if we were to switch.
[1] https://searchfox.org/mozilla-central/rev/387160feb07b75ae76bfc12df035a10f58d25168/js/src/gc/BufferAllocator.h#195
[2] https://searchfox.org/mozilla-central/rev/387160feb07b75ae76bfc12df035a10f58d25168/js/src/gc/MallocedBlockCache.h#19
| Assignee | ||
Comment 1•2 months ago
|
||
| Assignee | ||
Comment 2•2 months ago
|
||
| Assignee | ||
Comment 3•2 months ago
|
||
| Assignee | ||
Updated•2 months ago
|
| Assignee | ||
Comment 4•2 months ago
|
||
I ran some benchmarks on these patches in the shell, testing on x64 Linux and arm64 macOS. This used nightly builds where the poisoning behaviour is the same for both jemalloc and the buffer allocator.
Linux macOS
Score Major Minor Score Major Minor
time time time time
Dart-flute-complex-wasm +5.5% -13% -18% +6.6% -8.4% -28%
Dart-flute-todomvc-wasm +3.1% +5% -28% +3.7% +50% -32%
Kotlin-compose-wasm +3.2% - -2.8% -1% +6.6% -12%
I did some profiling on a browser build (macOS) to check nothing untoward was happening. These show a significant reduction in main thread minor GC time due to not sweeping trailer blocks there and reduction in helper thread time calling object finalizers, with a smaller increase in helper thread time for buffer allocator sweeping.
I don't know why Dart-flute-todomvc-wasm shows increased major GC time in the shell. This didn't happen in browser testing.
| Assignee | ||
Comment 5•2 months ago
|
||
I had to limit the maximum buffer size to allocate directly in the nursery because j2cl-box2d-wasm was filling the nursery with these leading to longer nursery collections which lead to reducing the nursery size to compensate. Updated results with this change:
macOS Linux
Score Total GC Score Total GC
time time
Dart-flute-complex-wasm +6.7% -24% +5.3% -17%
Dart-flute-todomvc-wasm +3.1% -24% +3.3% -22%
Kotlin-compose-wasm +3.1% -5.8% +4.4% -5.6%
j2cl-box2d-wasm - -12% - -18%
| Assignee | ||
Comment 6•2 months ago
|
||
Wasm GC allocations tend to get tenured more often than regular JS objects
which means minor GCs can spend a lot of time moving these directly allocated
buffers. This increases minor GC time which also means we keep the nursery size
smaller, affecting performance. This adds an option to set the maximum size of
buffer allocations made directly in the nursery. For Wasm GC allocations we'll
make this smaller than the regular size.
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Comment 8•1 month ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/9be0b8b761ee
https://hg.mozilla.org/mozilla-central/rev/19e4500ea7f6
https://hg.mozilla.org/mozilla-central/rev/0a7420a74a64
https://hg.mozilla.org/mozilla-central/rev/9aaf56b12eab
Updated•1 month ago
|
Description
•