DEVOURED
Wasmi 2.0 - Engineering of the Fastest Wasm Interpreters
Wasmi 2.0 achieves 2.2x faster performance than its predecessor by introducing threaded-code dispatch and specialized accumulator registers.
What: The Wasmi 2.0 interpreter redesign features four instruction dispatch modes, a new lock-free CodeMap, and optimized instance access, largely driven by full-time sponsorship from the Stellar Development Foundation.
Why it matters: This shift towards specialized execution handlers and register-based instruction dispatch shows how portable Wasm interpreters can rival high-performance runtimes by minimizing stack-slot overhead and optimizing for modern CPU branch prediction.
Deep dive
- Performance: 2.2x speedup (geometric mean) vs Wasmi 1.0 on Apple M2 Pro.
- Dispatch: Added direct-threaded and indirect-threaded code modes to reduce dispatch overhead.
- Registers: Introduced ireg, freg32, and freg64 accumulator registers to avoid constant stack loading.
- Concurrency: Implemented lock-free CodeMap for concurrent function lookup.
- Optimization: Fixed unintended Rust 1.92 MIR optimization issues that previously collapsed branch handlers.
Decoder
- Wasm (WebAssembly): A binary instruction format for a stack-based virtual machine, often used for high-performance execution outside the browser.
- Interpreter: A program that executes Wasm bytecode directly without first compiling it to machine code, prioritizing portability over raw execution speed.
- Threaded Code: A technique where code consists of a sequence of function pointers, allowing for fast instruction dispatch by tail-calling the next handler.
Original article
Full article content is not available for inline reading.
Explore all 56 articles in today's digest
Fresh dev news, AI-digested daily. Never miss a trend at devoured.fyi