Back to Lab Process Guides

Lab Note #042: Benchmarking WebAssembly vs V8 JIT in Edge Isolate Runtimes

Experimental performance comparison of Rust-compiled WASM modules vs optimized V8 JavaScript JIT execution for cryptographic hash verification and JSON transformations.

Experiment Overview

In this lab benchmark, we isolated computational performance within Cloudflare V8 Workers. We compared an idiomatic TypeScript implementation against a Rust WASM compilation target executing identical mathematical tasks:

  1. Test A: 100,000 iterations of HMAC-SHA256 signature verification.
  2. Test B: Parsing, transforming, and filtering a 15MB nested JSON document.

Benchmark Results

WorkloadTypeScript (V8 JIT)Rust (WASM Target)Delta / Speedup
HMAC-SHA256 (100k)482 ms117 ms4.12x faster (WASM)
Argon2 Password Hashing1,240 ms290 ms4.27x faster (WASM)
JSON Parse & Filter (15MB)34 ms41 ms1.20x faster (TS)
Memory Footprint12.4 MB1.8 MB6.8x lower memory (WASM)
graph TD
    A[Input Data Payload] --> B{Workload Type?}
    B -->|Heavy Math / Cryptography| C[Rust WebAssembly Engine<br/>~117ms]
    B -->|DOM / JSON / String I/O| D[V8 JavaScript Engine<br/>~34ms]

Lab Conclusion & Recommendations

  • Use WebAssembly (Rust/C++) for: image manipulation, vector search math, cryptography, signature verification, and compression.
  • Use Native JavaScript for: simple request routing, HTTP header mutations, and light JSON manipulation to avoid WASM linear memory marshalling overhead.