You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
wasmtime works extremely slow on kotlin benchmarks #13279
Using Wasmtime 44.0.1 we are having very slow benchmark execution.
The benchmark allocates and copies a lot of gc arrays and seems Wasmtime works inefficient with that (other engines, like v8, works much more faster).
To reproduce this one can use .wasm file and benchmark's config attached to this issue.
To run benchmark you need to execute the following cli command:
Thanks for filing an issue! It is expected that we won't be on-par with engines that have put hundreds more engineering years into the GCs than we have, but at the same time we shouldn't be multiple order of magnitude slower in general. Can you provide relative timings here? (That's generally a good bit of information to provide when filing performance-related issues).
Probably much faster with the copying collector (-Ccollector=copying) but I don't think that has made it into a release yet, and only exists on main currently.
In any case, I'll get around to taking a closer look soon ish.
(never prints anything). I waited for ~1 minute where node fully completed in 8s.
and with -Ccollector=copying
$ cargo run --release -- -C collector=copying --dir / -Wgc,function-references,exceptions kotlin-wasm-benchmarks-wasmWasiBenchmark.wasm STUB $PWD/config 5 microBenchmarks.ArrayCopyBenchmark.copyInSameArray
Finished `release` profile [optimized] target(s) in 0.11s
Running `target/release/wasmtime -C collector=copying --dir / -Wgc,function-references,exceptions kotlin-wasm-benchmarks-wasmWasiBenchmark.wasm STUB /home/alex/code/wasmtime/config 5 microBenchmarks.ArrayCopyBenchmark.copyInSameArray`
thread 'main' (1052828) panicked at crates/environ/src/gc.rs:507:32:
invalid `VMGcKind`: 0b000000000000000000000000000000
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
(after a few seconds)
Also, @igoriakovlev there's a typo in the node reproduction above which uses cissueopyInSameArray instead of copyInSameArray like in the Wasmtime snippet, and I'm assuming copyInSameArray is what's intended. I stay this because pasting the node command as-is completes instantaneously which looks like it's just not running anything.
A quick perf record of the drc collector shows that 70% of the time is in the array.copy libcall. That's known to be extremely slow in Wasmtime as it's lifting and lowering between high-level and VM types, so I suspect the lion's share of the improvement here is "optimize array.copy"
With the optimizations from #13382, plus the bug fixes in #13381, I've got the following results. The results in this table are total runtime for the entire wasm module to finish running. The module itself prints information and timing information but I'm not entirely sure what it is. I figure this is all indicative though:
runtime
time
wasmtime gc=null
3.455
wasmtime gc=drc
14.424
wasmtime gc=copying
3.407
node
6.984
so, effectively, I believe that #13382 solves this issue
Activity
fitzgen commentedon May 5, 2026
Thanks for filing an issue! It is expected that we won't be on-par with engines that have put hundreds more engineering years into the GCs than we have, but at the same time we shouldn't be multiple order of magnitude slower in general. Can you provide relative timings here? (That's generally a good bit of information to provide when filing performance-related issues).
Probably much faster with the copying collector (
-Ccollector=copying) but I don't think that has made it into a release yet, and only exists onmaincurrently.In any case, I'll get around to taking a closer look soon ish.
alexcrichton commentedon May 5, 2026
@fitzgen FWIW I get, with
node24.15.0:and with current main:
(never prints anything). I waited for ~1 minute where
nodefully completed in 8s.and with
-Ccollector=copying(after a few seconds)
Also, @igoriakovlev there's a typo in the node reproduction above which uses
cissueopyInSameArrayinstead ofcopyInSameArraylike in the Wasmtime snippet, and I'm assumingcopyInSameArrayis what's intended. I stay this because pasting the node command as-is completes instantaneously which looks like it's just not running anything.alexcrichton commentedon May 5, 2026
A quick
perf recordof the drc collector shows that 70% of the time is in thearray.copylibcall. That's known to be extremely slow in Wasmtime as it's lifting and lowering between high-level and VM types, so I suspect the lion's share of the improvement here is "optimizearray.copy"Add separate libcalls for array.copy w/ vs. w/out GC ref elems (bytec…
alexcrichton commentedon May 15, 2026
With the optimizations from #13382, plus the bug fixes in #13381, I've got the following results. The results in this table are total runtime for the entire wasm module to finish running. The module itself prints information and timing information but I'm not entirely sure what it is. I figure this is all indicative though:
so, effectively, I believe that #13382 solves this issue
Fix the copying collector bug(s) triggered by the Kotlin benchmarks (b…
Optimize `array.fill` and `array.copy` (bytecodealliance#13382)