Per-request compileStreaming vs pre-compiled Module shared to workers for tail latency
0 reputation · 01 Nov 2025, 15:49 UTC
Goal is to keep tail latency stable for a WebAssembly service under concurrent requests. Single-request benchmarks hide contention that appears when multiple requests trigger compilation and instantiation at the same time.
Approach A uses per-request WebAssembly.compileStreaming and instantiateStreaming to compile while bytes arrive. Approach B compiles once with WebAssembly.compile and transfers the resulting WebAssembly.Module to workers, creating a new WebAssembly.Instance per request.
The WebAssembly specification defines no cross-isolate compilation cache and no performance guarantees. Whether a transferred Module avoids recompilation, and how instantiation contends under load, is implementation-defined and varies by engine.
Does transferring a WebAssembly.Module to workers guarantee compiled code reuse without recompilation under concurrent instantiation? How does instantiation contention behave under load for per-request compileStreaming versus a shared pre-compiled Module? What engine-specific guarantees exist for compiled code sharing across isolates?