How We Measure
Measurement Methodology and Scopes
The same workload can take 0.08 ms as a warm in-memory loop and 35 ms as an end-to-end Web Worker task. This page explains where every timer starts and stops, why Worker Wasm can look slower than kernel compute, and how Track A parity stays separate from Track B optimizations.
1. Four Measurement Scopes
Every results table declares its scope. Ratios are only calculated inside the same table; the runner never divides a kernel median by a worker task or DOM journey time.
| Scope | Timer Starts | Timer Stops | What It Counts |
|---|---|---|---|
| Delivery & First Use | First new Worker() and postMessage() |
First verified result reaches the main thread | Worker startup, network fetch(), decompression, SHA-256 checks, module compile/instantiate, first run, and verification. |
| Task Pipeline (Worker JS / Worker Wasm) | Main thread calls worker.postMessage(cmd) |
Main thread receives worker.onmessage |
Structured-clone dispatch, any per-task asset load or instantiation inside the worker, fixture setup, memory copies, compute, and output verification. |
| Kernel Compute (Groups 1, 2, 3) | Right before calling the exported JS or Wasm function | Immediately after the function returns | Pure CPU work and linear-memory reads/writes on an already-instantiated module with pre-allocated buffers. No worker IPC, network, or recompile. |
| Real-DOM Journey | Host sends the frozen action trace to a live iframe | Iframe finishes applying DOM updates and forced layout | Engine compute, JS/Wasm bridge marshalling, real DOM API calls (createElement, insertBefore, classList, form state), and synchronous layout commit (getBoundingClientRect()), split into Compute, DOM Apply, and Layout phases. |
2. Why Worker Wasm Can Look Slower Than Expected
On several pages, Worker Wasm takes 5 ms to 60 ms per task while the same algorithm in Kernel Compute takes 0.05 ms to 2 ms. That gap comes from worker lifecycle behavior, not from WebAssembly running slower inside a worker thread.
Is Wasm slower inside a Web Worker?
No. Dedicated Web Workers use the same V8 Liftoff and TurboFan compilers
as the main thread. When a worker keeps a cached WebAssembly.Instance across
messages, inner kernel speed matches main-thread Kernel Compute.
Is postMessage the bottleneck?
Usually not for small control messages. Sending a small command object
and summary back across threads costs roughly 0.05-0.30 ms. Messaging only
dominates when an app structured-clones megabytes of data per call instead of transferring
ArrayBuffer ownership or keeping state inside the worker.
Why many contract workers show higher Worker Wasm time
JavaScript and WebAssembly are loaded differently in many of the self-attesting contract workers:
-
Worker JavaScript loads once per worker: A top-level ES
importparses JS once when the worker starts and keeps optimized code warm across every iteration. -
Per-task Wasm instantiation: Many contract workers run
fetch(wasmUrl, { cache: "no-store" }), SHA-256 verification, andWebAssembly.instantiate()insideonmessageon each task so every run is self-verifying. That adds compilation and linear-memory allocation to every sample. The 6 custom DOM workers, the 3 game workers, andsum-u32cache their Wasm instance across messages; see the worker lifecycle audit (worker-lifecycle.v1.json) for per-worker details. -
Full output verification inside the task: Some workers load multi-MB
reference fixtures and verify every output element inside
onmessage. Compare Task Pipeline against Kernel Compute on each page to see how much time went to compute vs setup.
How to ship fast Worker Wasm in production
- Instantiate once per worker: Cache
const wasmReady = WebAssembly.instantiateStreaming(fetch(url))at module scope soonmessagereuses the same instance. - Reuse a scratch arena: Keep linear-memory buffers allocated between calls instead of creating a new instance or growing memory per task.
- Batch small calls: Send a batch of frames, records, or edits per
postMessageinstead of crossing the thread boundary thousands of times. - Transfer buffers zero-copy: Pass
ArrayBuffers in the transfer list ofpostMessage, or share memory withSharedArrayBufferunder COOP/COEP.
3. Track A (Controlled) vs Track B (Optimized)
Inside Kernel Compute, each multi-language benchmark keeps baseline parity separate from target-specific tuning:
-
Group 1 (JS vs Raw WAT):
Compares plain JavaScript against handwritten WebAssembly Text (
.wat) with no optimizing C or Rust compiler involved. -
Group 2 (Track A: Controlled Compilers):
Runs the same algorithm and data layout in C (
clang -O3), C++ (clang++ -O3), Rust (rustc -O), AssemblyScript (asc -O3), and Dart (dart compile wasm) without manual SIMD intrinsics or algorithm swaps. -
Group 3 (Track B: Tuned & SIMD128):
Tests JavaScript loop/layout optimizations (
js-opt), Wasm SIMD128 (-msimd128 -funroll-loops), loop tiling, and arena reuse. Each Track B variant is compared only against its own language's Track A baseline. Pre-built offline SIMD binaries under/artifacts/autoresearch/(autoresearch-log.v1.json) were measured in standalone V8 CLI on Apple M4 Pro and are always tagged as non-browser reference numbers.
4. Four Workload Patterns
Across the suite, relative JS and Wasm performance falls into four clear patterns:
- Data-Parallel Numeric & SIMD: Tight typed-array loops without loop-carried dependencies (
ml-gemm,audio-fir,numeric-polybench-panel,sum-u32). Cache-friendly memory strides help both JS and Wasm, while Wasmv128SIMD adds 2-4× lane parallelism that plain JS does not expose. - Sequential State Machines & Parsing: Branch-heavy codecs, hashes, regex engines, and wire parsers (
archive-zip-workspace,crypto-file-integrity,text-markdown-cms). Loop-carried branches limit SIMD; V8 JIT and scalar Wasm often land close together unless 64-bit integer bitwise math dominates. - Graphs, Spatial Trees & WasmGC: Pointer-chasing BVHs, mesh repair, physics solvers, and managed object graphs (
graphics-cpu-path-tracer,cad-mesh-repair,text.gc-document-edit). Data layout (flat slot arrays vs allocated structs, and nativef32vsf64) matters more than compiler choice. - Real-DOM & Host Boundary: Interactive UI benchmarks driving live DOM trees in an iframe (all 11 real-DOM stages, including TodoMVC, virtualized grids, keyed lists, tables, forms, and tree mutations). String marshalling, DOM API calls, and browser layout often dominate total frame time.
5. Distributions and Charts
- Payload size stays separate: Binary and JS byte counts are reported next to timings, never mixed into compute latency.
- Cold vs warm stay separate: First-run startup latency is recorded separately from warm steady-state median, min, p90, max, MAD, and 95% confidence intervals.
- Four standard charts: Median execution bar chart (with 95% CI whiskers), break-even amortization chart, per-iteration warm-up trajectory, and binary size vs speed scatter plot.
6. Source Links and Output Verification
Every benchmark page links directly to its executed JS and Wasm source files and GitHub commits. Before timing runs, each target executes an output check (FNV-1a hash, SHA-256 digest, or exact DOM/state snapshot) and fails visibly if outputs disagree.
- WebAssembly build & equivalence guide: build commands and verification checks across all compiled
.wasmbinaries. - Worker lifecycle audit (
worker-lifecycle.v1.json): per-worker breakdown of JS/Wasm loading, fetching, and instantiation behavior. - Track B SIMD128 reference log (
autoresearch-log.v1.json):-msimd128 -funroll-loopsbinaries,v128counts, and CLI reference timings across 45 manifests. - Kernel build provenance JSON: compiler flags, SHA-256 hashes, and rebuild checks.
- Source-rebuild oracle equivalence JSON: rebuild verification against JS reference oracles.