bnjbvr opened PR #4181 from reuse-context
to main
:
cranelift-codegen has a context that may be reused to spare memory allocations, and it happens that it is not reused in wasmtime right now, but instead re-created for each function compilation. I've extended the sharing of the
FuncTranslator
data type during compilation tocranelift_codegen::Context
too.This causes tiny speedups of compile times, but in the noise range:
- parallel compilation with 32 cores: 2% on a UE4 game compiled to wasm; 1.1% slowdown on the Godot engine; 5.3% on clang
- mono-threaded compilation: 1.6% speedup on sqlite, 1.6% speedup on opencv
I've also implemented batch compilation, i.e. group functions together based on the bytecode size until it reaches some predefined threshold and send that as a unit of work per thread. That was something implemented in Spidermonkey and which helped lower the overhead cost of parallelization. But in wasmtime I only got slowdowns, independently of the benchmark, independently of the thresholds... so I guess rayon does already a great job with work stealing etc. I've removed the batch compilation from this PR, but the code is in this branch if people are interested.
cfallin submitted PR review.
bnjbvr merged PR #4181.
Last updated: Dec 23 2024 at 12:05 UTC