Make wasm-gc trailer sizes available to the tenured-heap's when-to-GC decision-making machinery
Categories
(Core :: JavaScript: WebAssembly, defect)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox120 | --- | fixed |
People
(Reporter: bvisness, Assigned: jseward)
References
Details
Attachments
(5 files)
Some elements of the Kotlin wasm benchmark suite allocate ridiculous amounts of memory (hundreds of gigabytes on my machine). V8 does not suffer the same.
For example, you can clone https://github.com/bvisness/kotlin-wasm-benchmarks and run gradle jsShell_wasmSingleBenchmark to run the microBenchmarks.ClassBaselineBenchmark suite in isolation with a high iteration count. This causes large amounts of memory usage in SpiderMonkey but not V8.
| Assignee | ||
Comment 1•2 years ago
|
||
Initial investigation suggests gradle jsShell_wasmSingleBenchmark uses
excessive memory while allocating gc-arrays with 80KB payload areas.
However, the following does not show the problem:
(type $tArrayI64 (array i64))
(func (export "go")
(local $i i32)
(loop $cont
(array.new $tArrayI64 (i64.const 1337) (i32.const 10000))
drop
(local.set $i (i32.add (local.get $i) (i32.const 1)))
(br_if $cont (i32.lt_u (local.get $i) (i32.const 10000000)))
)
)
| Assignee | ||
Comment 2•2 years ago
|
||
Here's a standalone test case constructed from a snapshot of
./gradlew jsShell_wasmSingleBenchmark.
Simply untar and run the command specified in HOWTO_RUN.txt.
Does not require the Kotlin framework.
| Assignee | ||
Comment 3•2 years ago
•
|
||
A standalone (and minimal) test case that shows the problem and that explains why the problem happens.
| Assignee | ||
Comment 4•2 years ago
|
||
| Assignee | ||
Comment 5•2 years ago
|
||
| Assignee | ||
Updated•2 years ago
|
| Assignee | ||
Comment 6•2 years ago
|
||
When applied to a tree that has the fix from the now-landed bug 1858200, the
patches in comment 4 and comment 5 fix the problem on all targets and fairly
accurately show the costs entailed by the fix. However, they are excessively
complex and so are unlikely to be the final implementation.
| Assignee | ||
Updated•2 years ago
|
| Assignee | ||
Comment 7•2 years ago
|
||
For trailer blocks whose owning Wasm{Struct,Array}Objects make it into the
tenured heap, we have to tell the tenured heap how big those trailers are in
order to get major GCs to happen sufficiently frequently. If we don't do
that, programs that allocate many such objects with big trailers can end up
with wildly excessive space use, because the tenured heap's when-to-GC
heuristics are unaware that each (relatively small) Wasm{Struct,Array}Object
is "shadowed" by a large amount of malloc'd space, and so major collection
happens far too infrequently.
The changes are simple -- they just notify the the tenured heap's accounting
system by calling AddCellMemory when an object enters the tenured heap and
GCContext::removeCellMemory when an object leaves the tenured heap (is
finalized).
Some comments have been updated.
As a ridealong, the bizarrely-misnamed MallocedBlockCache::allowSlow has
been renamed to ::allocSlow.
Comment 9•2 years ago
|
||
| bugherder | ||
Description
•