Memory64 Benchmarks
Run the same Rust code built for wasm32 and for wasm64 (memory64) to see what 64-bit linear memory costs.
Why memory64 can be slower
- Bounds checks: On 64-bit hosts, engines reserve 4 GiB of address space for a wasm32 memory, so most bounds checks can be left out. A 64-bit index can't be handled that way, so every load and store pays for an explicit check. The SpiderMonkey team measured slowdowns ranging from 10% to over 100%, depending on the workload.
- Bigger pointers:
usizeand pointers grow from 4 to 8 bytes. Pointer-heavy data such asVecheaders, hash map entries, and ECS archetype and table metadata gets bigger, so it uses more memory and cache. The peak memory column shows this. - What you get in return: wasm32 can address at most 4 GiB. The WebAssembly JS API caps memory64 at 16 GiB.
Methodology
- Both modules come from the same crate, built with the same pinned nightly Rust compiler, flags, and
wasm-optpass. Both builds compile std from source with-Zbuild-std, becausewasm64-unknown-unknownis a tier 3 target with no prebuilt std. The target is the only difference. - Inputs come from a fixed seed, so both builds do the same work. The Output column checks that the checksums from every sample are identical.
- Each workload starts in a fresh worker. Both builds load and prepare their inputs untimed before either runs. A shared repetition count is then calibrated so each timed sample lasts tens of milliseconds, and the builds alternate untimed warm-up rounds (at least half a second in total) so the JIT can tier up. Timed samples also alternate which build goes first.
- Memory64 shipped in Chrome 133 and Firefox 134. Results differ between engines, so test the browsers you're targeting.