09 — Phase 3 benchmarks
Branch phase-3-bench. Harness: bench/ (cell, run, report, impls, mini/). Raw data:
bench/results/bench-results-t{4,8}.jsonl, one line per cell with the Node version, CPU
and 1-min load before and after.
Method
- Machine: Apple M4 Pro (12 cores, 8P+4E), 48 GB, Node v22.23.3. Every cell runs in a fresh process.
- Gate (before and after every cell): 1-min load < 15 and no GitHub Actions
Runner.Workerprocess. A cell that fails the gate afterwards is discarded and re-run. In this run 250 of 250 cells were kept, the gate never closed, and load stayed between 2.2 and 3.7. Both gate conditions were negative-controlled: a limit of 0.01 blocked every cell, and a decoy process namedRunner.Workerblocked every cell. Both were restored byte-identical by sha256. - Fixed iterations: echo 200,000 tasks, obj 100,000 and spin50 40,000, each with 1,024 in flight; latency is 20,000 sequential round trips. Every cell has a warmup and 5 repetitions, with implementations interleaved within each repetition. Pools run at min = max = threads, with library defaults otherwise.
- Implementations:
- Full pools: vortex 0.1.0 (master 301a246, push,
atomics: 'sync'default), piscina 5.3.2, tinypool 2.2.0 and workerpool 10.0.3. - Ablation pools share one minimal engine (
bench/mini/): least-busy placement of one task per idle worker, a singleAtomics.waitAsyncfor completions, lane-1 values only, and no async resources, abort, queue limits or port. Three backends:- mini-wasm-push: the shipped Rust/wasm core, push.
- mini-wasm-pull: the same core with pull and prefetch (256-slot ring).
- mini-js-push: the same push algorithms in plain JS Atomics over a SharedArrayBuffer.
- Full pools: vortex 0.1.0 (master 301a246, push,
Results (median of 5, min–max in brackets)
Throughput is in tasks/s. Latency is a sequential round trip.
| workload | threads | vortex | piscina | tinypool | workerpool | mini-wasm-push | mini-wasm-pull | mini-js-push |
|---|---|---|---|---|---|---|---|---|
| echo | 4 | 121k (121–124k) | 130k (127–134k) | 205k (202–211k) | 181k (178–184k) | 1.62M (1.60–1.64M) | 1.70M (1.69–1.76M) | 1.74M (1.64–1.84M) |
| echo | 8 | 99k (98–99k) | 106k (105–109k) | 178k (177–179k) | 164k (164–166k) | 1.42M (1.41–1.42M) | 1.11M (1.11–1.12M) | 1.79M (1.76–1.82M) |
| obj | 4 | 107k (106–109k) | 122k (120–124k) | 204k (196–205k) | 176k (170–178k) | — | — | — |
| obj | 8 | 90k (90–91k) | 104k (99–106k) | 177k (176–177k) | 156k (155–158k) | — | — | — |
| spin50 | 4 | 50.3k | 55.6k | 56.7k | 55.7k | 53.7k | 77.4k | 53.6k |
| spin50 | 8 | 67.6k | 83.6k | 98.6k | 90.3k | 90.0k | 154.0k | 90.8k |
| latency p50/p99 µs | 4 | 18.3 / 36.6 | 11.7 / 19.7 | 10.3 / 16.7 | 9.5 / 16.9 | 14.6 / 27.3 | 17.3 / 30.8 | 14.5 / 27.0 |
| latency p50/p99 µs | 8 | 18.7 / 41.2 | 13.7 / 23.9 | 10.5 / 17.5 | 9.5 / 17.6 | 14.6 / 27.2 | 22.8 / 56.6 | 14.6 / 24.3 |
spin50's ideal is threads / 50 µs, which is 80k (4 threads) and 160k (8 threads). obj returns an object, which the ablation pools cannot carry.
What this proves (on this machine, these workloads, Node 22)
- vortex as shipped is not fast. It is the slowest of the four full pools in every cell: below piscina by 7–19% on throughput, and its p50 latency is about 1.6× piscina's and about 1.9× workerpool's. tinypool leads throughput and workerpool leads latency.
- The cost is in the JS shim, not the core. The same core under a minimal engine runs
echo 13–14× faster than vortex. Profile of the vortex echo cell:
- Main thread: 16% self time in the per-dispatch
get interfaceobject (inherited from piscina's balancer contract), plus microtask and resource overhead. - Worker: two-thirds of samples are
performance.nowcalls made from the wasm idle spin through thevortex_now_usimport.
- Main thread: 16% self time in the per-dispatch
- Rust/wasm contributes nothing measurable here. mini-js-push is equal to or faster than mini-wasm-push in every cell (echo at 8 threads: 1.79M vs 1.42M). Both carry the same algorithms, so the difference is the JS↔wasm call boundary and imports.
- Push vs pull:
- Pull with prefetch wins CPU-bound throughput clearly. It is near ideal: 77k of 80k and 154k of 160k, against about 54k and 90k for push.
- Push wins latency (14.6 vs 17.3–22.8 µs p50) and empty-task throughput at 8 threads.
- The push engine places one task per idle worker, so a worker idles for one round trip between tasks. That is a property of push without per-worker depth.
- Futex wake vs port message: even the minimal shared-memory engine's single round trip (14.6 µs) is slower than workerpool's and tinypool's port round trip (9.5–10.5 µs), so the waitAsync + wait32 wake path does not beat MessagePort for isolated tasks.
What this does not prove
- No "fastest" claim of any kind. The measured shared-memory engines beat the full pools only on trivial-task throughput. They are not drop-in pools (no async hooks, abort, queues, transfer or arbitrary values), so their numbers bound what a shim could reach. They are not results for a product.
- One machine, one Node version, one OS. Linux/x86, Node 20 or 24, and E-core scheduling effects were not measured. No large payloads, transfers, many-pool or long-running mixed workloads were measured.
- Library defaults only. No tuning was done for any library, including vortex's spin cap.
Consequences for the plan (for the coordinator to decide)
- 2d (lane 2, wasm-side codecs): the data argues against putting more on the JS↔wasm boundary. Every move so far has lost to plain JS.
- Push vs pull: keep push for placement and latency, add per-worker prefetch depth (≥2) so CPU-bound workers never idle a round trip. Alternatively make pull the throughput mode; the ablation shows it reaching about 96% of ideal.
- Shim:
- Remove the per-dispatch interface allocation (cache it per worker).
- Stop calling
performance.nowper spin iteration from wasm (count spins, or read a shared clock word). - Re-measure after each change.
- Language: the honest options are a plain-JS core (measured equal or faster), or keeping Rust only if a later workload shows a wasm win.
Fix series (after the coordinator's go)
Each fix was measured on its own: every step's dist/ was snapshotted
(steps/<label>/, run as vortex@<label>) and interleaved with the step before it and
with piscina inside the same gated repetitions, because load on the bench machine
drifts between runs. Same machine, Node v22.23.3, same gate, 5 repetitions, medians.
| Step | Change | echo 4t | echo 8t | obj 4t | spin50 4t | spin50 8t | p50 µs 4t | p99 µs 4t |
|---|---|---|---|---|---|---|---|---|
| s0 → s1 | balancer view built once per worker | 120k → 166k | 99k → 127k | 106k → 137k | 50.5k → 52.2k | 67.6k → 86.8k | 17.7 → 16.8 | 37.4 → 34.4 |
| s1 → s2 | clock read every 64 spin iterations | 166k → 163k | 127k → 127k | 137k → 139k | 52.2k → 52.1k | 86.8k → 88.8k | 16.8 → 16.0 | 34.4 → 30.6 |
| s2 → s3 | push prefetch | 164k → 252k | (load spike) | 137k → 196k | 52.5k → 76.2k | (load spike) | 16.0 → 16.0 | 31.1 → 31.3 |
| s3 → s4 | per-task path trimmed | 255k → 297k | 166k → 187k | 201k → 230k | 75.4k → 76.6k | 126k → 139k | 16.0 → 17.1 | 39.7 → 31.0 |
| s4 → s5 | hybrid completion wake | 300k → 404k | 187k → 256k | 231k → 290k | 76.6k → 76.2k | 143k → 144k | 16.3 → 6.4 | 30.6 → 29.8 |
The s2 → s3 8-thread cells ran during a load spike (up to 14.9, one cell discarded, piscina itself fell about 30 %). The final run below measures s3's effect inside s0 → s5.
Before and after (one run, all implementations interleaved)
Raw: bench/results/final-t{4,8}.jsonl. Load 2.6–4.5, no cell discarded.
| workload | thr | vortex before (s0) | vortex after (s5) | piscina | tinypool | workerpool | mini push | mini pull | mini JS push | mini push + port completion |
|---|---|---|---|---|---|---|---|---|---|---|
| echo | 4 | 122k | 397k | 130k | 211k | 182k | 1.60M | 1.66M | 1.70M | 1.53M |
| echo | 8 | 99k | 259k | 106k | 182k | 165k | 1.38M | 1.10M | 1.82M | 1.29M |
| obj | 4 | 107k | 289k | 122k | 209k | 176k | — | — | — | — |
| obj | 8 | 90k | 208k | 105k | 179k | 157k | — | — | — | — |
| spin50 (ideal 80k) | 4 | 50.2k | 76.4k | 55.6k | 56.6k | 55.7k | 52.9k | 77.6k | 53.3k | 62.5k |
| spin50 (ideal 160k) | 8 | 68.1k | 144.1k | 83.2k | 98.7k | 90.1k | 90.2k | 154.2k | 91.0k | 108.2k |
| latency p50 / p99 µs | 4 | 17.4 / 37.0 | 6.5 / 30.0 | 11.8 / 19.6 | 10.4 / 16.8 | 9.6 / 17.1 | 14.6 / 26.3 | 17.3 / 27.4 | 14.6 / 26.5 | 3.3 / 7.0 |
| latency p50 / p99 µs | 8 | 18.7 / 42.5 | 6.9 / 29.0 | 13.7 / 24.2 | 10.5 / 17.1 | 9.5 / 17.8 | 14.6 / 26.5 | 23.7 / 49.5 | 14.6 / 26.5 | 3.4 / 7.9 |
What this shows, and what it does not
- On these four workloads, on this machine, vortex after the fixes has the highest throughput of the four full pools in every cell: 1.4–3.1× piscina, 1.2–1.9× tinypool. It also has the lowest median latency (6.5 µs against 9.6–11.8 µs).
- Its p99 latency (29–30 µs) is still the worst of the four (piscina 19.6–24.2, workerpool 17.1–17.8).
- Its median latency is not stable across repetitions: one of five repetitions per thread count measured 13.9 / 13.2 µs, so a run can land near piscina's figure.
- The minimal engines are still 4–7× faster on empty tasks. The remaining cost is the piscina-compatible layer (TaskInfo AsyncResource, promises, events, the balancer contract), most of it in native async-resource code that cannot be removed without changing what async_hooks users observe.
- Rust/wasm still contributes nothing measurable over plain JS (mini JS push equals or beats mini wasm push in every cell). This is unchanged from the first run.
- Pull mode stays an ablation. Push with prefetch reaches 95 % (4t) and 90 % (8t) of ideal on spin50, against 97 % and 96 % for the stripped-down pull engine. That gap is not enough to justify a second placement mode that would bypass custom balancers.
- Not measured: other machines, OSes and Node versions; payloads over 240 bytes beyond
obj; transfers; abortable tasks (never staged); custom balancers orconcurrentTasksPerWorker > 1(prefetch off);atomics: 'async'; long mixed workloads. The claim stops at these cells.
Two cores, step by step (owner decisions of 2026-11-27)
One gated run, all builds and pools interleaved in every repetition: Apple M4 Pro, Node.js
v22.23.3, five repetitions, load 4.8–10.3 (gate 15), no cell discarded or failed. Raw data:
bench/results/cores-t4.jsonl, cores-t8.jsonl. Medians; latency is p50 / p99 µs.
| build (commit) | change | echo t4 | echo t8 | obj t4 | obj t8 | spin50 t4 | spin50 t8 | latency t4 | latency t8 |
|---|---|---|---|---|---|---|---|---|---|
| c0:js (3a57cf9) | two cores, JS core | 387k | 255k | 277k | 200k | 76.2k | 142k | 6.7 / 29.5 | 6.7 / 29.5 |
| c0:rust (3a57cf9) | two cores, Rust core | 395k | 262k | 282k | 204k | 76.3k | 144k | 6.7 / 29.9 | 13.9 / 29.9 |
| ca:rust (2411acb) | 2a: idle path reads no clock | 402k | 290k | 291k | 209k | 76.3k | 143k | 9.4 / 29.9 | 6.7 / 29.0 |
| cc:rust (b78c85f) | 2c: i32 hot path | 402k | 349k | 287k | 214k | 76.2k | 142k | 10.9 / 28.7 | 6.5 / 29.2 |
| cb:rust (45ecfcd) | 2b: one release per drain | 435k | 304k | 307k | 233k | 76.1k | 142k | 12.1 / 28.3 | 6.5 / 28.5 |
| cd:rust (9a39534) | spin calibration; main-wait fix | 432k | 238k | 308k | 193k | 76.2k | 141k | 13.6 / 28.3 | 13.8 / 29.0 |
| ce:rust (e90e5f4) | main wakes on MSG_WAKE alone | 686k | 559k | 428k | 355k | 74.7k | 142k | 4.4 / 10.7 | 4.5 / 12.1 |
| ce:js (e90e5f4) | the same, JS core | 622k | 274k | 405k | 227k | 74.9k | 143k | 4.4 / 12.1 | 4.5 / 13.2 |
| piscina 5.3.2 | 131k | 107k | 123k | 102k | 55.7k | 80.9k | 11.7 / 19.9 | 13.7 / 24.3 |
What this shows:
- The Rust core's call-cost steps (2a, 2c, 2b) moved echo at 4 threads from 395k to 435k (+10 %) and obj from 282k to 307k (+9 %). At 8 threads the builds before ce varied by up to 1.5× between repetitions (cb echo 266k–340k), so no step there is resolved.
- p50 latency before ce was bimodal: each repetition measured either about 6.5 µs or about 14 µs, so the medians of c0–cd move with how many repetitions fell in each mode, not with the change. ce removed the second mode (4.3–4.5 µs in all ten repetitions).
- ce is the largest single step: dropping the main thread's
Atomics.waitAsync, so that the main thread wakes on the worker's port message alone, raised echo at 4 threads from 432k to 686k and cut p99 from 28 µs to 11 µs, on both cores. - spin50 lost 2 % at 4 threads in ce (76.2k → 74.7k; ideal 80k); not investigated.
The gap between the cores, honestly: after these steps the Rust core is not behind the
JS core on any cell. At 4 threads it is 10 % ahead on echo, 6 % on obj, level on spin50
and p50, 1.4 µs better at p99. At 8 threads it is 2.0× the JS core on echo and 1.6× on
obj, and the JS core varied widely there (echo 270k–381k); why the JS core falls behind
at 8 threads has not been investigated. The calls that remain per task on the Rust core:
reserve, assign, next, finish_assigned and, with recordTiming, two histogram
records.