wasm-tools: `wasmparser`: Performance regressions since `v0.100.2`
Due to technical reasons I had to use the (by now) ancient wasmparser 0.100.2 in Wasmi and was using a fork called wasmparser-nostd. The fork had no significant impact on the performance.
Recently I updated Wasmi to use the newest wasmparser v0.214.0 and unfortunately saw massive performance regressions, especially for Wasm validation. Many Wasmi benchmarks regressed by 15-35% and some even by 45% compared to the Wasmi that uses the ancient wasmparser v0.100.2.
The Wasmi upgrade PR is here: https://github.com/wasmi-labs/wasmi/pull/1141
Maybe I did some mistakes when upgrading which explain the performance regressions.
Since Wasmi is very focused on speedy translation times those performance regressions unfortunately are a show stopper for using the new wasmparser versions.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 23 (8 by maintainers)
I just tested this PR on Wasmi’s
wasmparserupdate PR with the following results:tiny_keccak.wasmeager/checkedeager/checked+meteredeager/uncheckedlazy-translation/checkedlazy/checkedlazy/uncheckedspidermonkey.wasmeager/checkedeager/checked+meteredeager/uncheckedlazy-translation/checkedlazy/checkedlazy/uncheckedSummary: Still not ideal for small Wasm files, but much better compared to v0.220.
(sorry still recovering from jetlag so responding to the rest of your comment now too)
Makes sense to me! I’d prefer to lean on “detect a recursive type” if possible and only use
WasmFeaturesas a last resort as well, but I agree that the ultimate decision maker there will be benchmarks one way or another.Thanks for measuring this @Robbepop! That intuitively makes sense to me and we historically have spent most of our time looking at optimizing the operator validator rather than the general module validator.
Would you be able to extract an example module or two that showcases this slowdown? For example a module that only has a type section should be sufficient to showcase the slowdown and additionally track improvements.
If it helps, here is the implementation in SpiderMonkey [1]. We do an upfront check for if the local index is less than where the first non-nullable local is and skip any boolean checking after that. Then we consult a bitmap. For setting a local, we also skip any consultation of the bitmap in the case where the local has been set [2].
So for applications that are not using any GC types, the only cost on local.get/set is the upfront check against the first non-nullable local index (which will always fail).
[1] https://searchfox.org/mozilla-central/rev/dd421ae14997e3bebb9c08634633a4a3e3edeffc/js/src/wasm/WasmOpIter.h#347-352 [2] https://searchfox.org/mozilla-central/rev/dd421ae14997e3bebb9c08634633a4a3e3edeffc/js/src/wasm/WasmOpIter.h#2283-2285