Skip to content

Performance ​

SurfaceWeave treats performance as a measured compatibility property. The benchmark suite exercises the same public Core and React APIs used by hosts; it does not replace correctness, package, or release gates.

Commands ​

Run benchmarks with Node 22 and the repository-pinned pnpm version:

bash
pnpm benchmark
pnpm benchmark:smoke
pnpm benchmark:core -- --json
pnpm benchmark:react -- --json
pnpm benchmark:browser:install
pnpm benchmark:browser

The Core benchmark covers traversal, defensive cloning, validation, data updates, listener fan-out, and a deeply nested tree. The React benchmark uses jsdom to measure Store-to-commit latency, record render fan-out, and isolate Component Pack resolution. --sizes=50,500,2000 and --listeners=0,1,5 override the default Core matrix.

benchmark:smoke is a short wiring and correctness check run by CI. Wall-clock results remain informational because shared CI runners are noisy. Render-count and semantic assertions may be used as hard gates. The separate Chromium suite runs a production Vite build with one Playwright worker and enforces the 16.7 ms update p95 target; it also runs weekly and on manual dispatch.

RC.5 baseline ​

Recorded on 2026-08-11 with Node 22.23.1 on macOS arm64, using the recommended Surface resource policy. Times are milliseconds per operation after warm-up.

Core ​

NodesMetricp50p95
50validate Surface2.8016.484
50update data, 0 listeners2.9217.372
500validate Surface25.91727.462
500update data, 0 listeners26.54927.664
2,000validate Surface104.267105.933
2,000update data, 0 listeners110.672114.066
2,000update data, 1 listener114.102159.447
2,000update data, 5 listeners122.037145.236

At 2,000 nodes, traversal was 0.013 ms p50 and cloning was 2.011 ms p50. Validation therefore dominates the Core update path in this baseline. The depth-64 fixture raises maxJsonDepth to 256 explicitly because each tree level also introduces JSON object and array nesting.

React with jsdom ​

NodesInitial mount and unmount p50Update through commit p50Update p95Nodes rendered
506.7445.7686.97550
50030.36750.68176.858500
2,000113.009171.309197.8812,000

A one-path update renders the root, target, and every sibling in RC.5. The optimization target is one target component per mounted view, zero unrelated sibling renders, a 2,000-node Core update p50 no higher than 15 ms and p95 no higher than 20 ms on the reference machine, and at least a 5x improvement over this baseline. A real Chromium benchmark is required before making browser frame-budget claims; jsdom is only the deterministic local diagnostic layer, and the optimized result below includes that browser gate.

Compatibility constraints ​

Performance work must preserve Wire Protocol 1.0, the single global baseRevision, atomic commits, deterministic events, listener isolation, resource policy enforcement, and Core's framework independence. Existing custom SurfaceStore implementations must keep compiling and receive a compatible fallback path when optional optimized observation capabilities are not present.

InMemorySurfaceStore exposes that optimization through the separate SurfaceObservationSource capability. Capability consumers receive shared, deeply frozen snapshots and event-only notifications, while the stable SurfaceStore.subscribe() API continues to provide a separate mutable event and Surface copy to every listener.

Optimized result ​

Recorded on the same Node 22.23.1 macOS arm64 reference machine after the Schema, Pack resolution, index, copy-on-write, and node subscription changes.

2,000-node scenariop50p95Change from RC.5 p50
Core one-path update, 0 legacy listeners10.59915.90610.4x faster
React jsdom update through commit9.93710.80217.2x faster
React jsdom initial mount and unmount74.90479.68633.7% faster

The React update renders exactly one target component, no root component, and no unrelated sibling. Because cached full validation now remains inside the Core target, data updates continue to run the complete Surface validation path; no incremental-validation bypass was introduced.

The production Chromium 151 benchmark measured five warmed initial mounts and 20 warmed one-path updates:

2,000-node Chromium scenariop50p95
Initial mount38.60043.200
Update through layout-effect commit5.8006.200

The browser test hard-fails if the target renders other than once, if the root or an unrelated sibling renders, or if update p95 exceeds 16.7 ms. The JSON and HTML reports are retained as workflow artifacts for 30 days.

Released under the MIT License.