vortex

Compatibility with piscina 5.3.2

@avarok/vortex 0.1.0 · Updated

Vortex is a drop-in replacement for piscina 5.3.2. piscina's own test suite runs unmodified against vortex (compat/piscina-5.3.2/, files pinned by compat/piscina-5.3.2.sha256):

npm run build && node scripts/compat.mjs vortex 4     # vortex
node scripts/compat.mjs piscina 4                     # the reference, same harness

Result on Node.js 22.23.3 (macOS, arm64): 154 tests, 149 pass, 5 skipped, 0 fail, both for vortex and for piscina itself. 15 runs in a row were green; the last 5 ran on the final code. The suite skips 5 tests by its own conditions: two nice tests (Linux or Windows only), two Explicit Resource Management tests (Node.js 24 only), and one thread-count test (runs only on machines with at most 8 CPUs). The same counts hold on Node.js 20.20.2 (vortex and piscina) and 25.1.0 (vortex). The Node.js 24-only tests have not been run against vortex yet.

This page lists every behaviour difference we know of. The tests do not observe any of them. If you find another one, it is a bug in this page or in vortex.

Additions

What Vortex piscina
Piscina.version vortex's own version (from its package.json) piscina's version
Piscina.compatibleWith new static, '5.3.2'; also a named ESM export absent
Option core 'js' by default: the pool runs on the JS core. core: 'rust' runs it on the Rust core compiled to wasm. Both implement one layout and protocol (design chapter 10) and both pass piscina's suite unmodified. Any other value: TypeError: options.core must be 'js' or 'rust'. absent
Option spin true by default: an idle worker spins briefly, up to 50 µs and adaptively, decaying to zero while idle, before it sleeps. spin: false turns this off. It must be a boolean (TypeError: options.spin must be a boolean). absent

Differences

Area Vortex piscina
maxThreads upper bound At most 2047 (RangeError: vortex: maxThreads must not exceed 2047), because each thread needs two worker records and the core has 4095. Infinity is refused. Any number ≥ 1, including Infinity.
Tasks in flight At most 4096 at once (each holds a slot until its result is read). If a custom loadBalancer places a task when no slot is free, the task goes back to the queue, as if the balancer had returned null. The default balancer never reaches the limit unless maxThreads × concurrentTasksPerWorker exceeds it. No limit.
Replacing a terminated worker The new Worker is created at once, so threads is up to date. If every record still belongs to a worker that has not emitted 'exit', its startup waits until one has. A record is never reused while a dying thread could still touch it. Starts at once.
atomics: 'disabled' An idle worker waits with Atomics.waitAsync on its own futex word, and never blocks its event loop. Observable behaviour is the same: timers and other async work run between tasks. An idle worker waits for a port message.
options.taskQueue undefined unless the caller passed one. The pool's queue is the caller's queue or a fresh FixedQueue, as in piscina. Reads back an unused ArrayTaskQueue instance shared by every pool.
Per-worker histogram (workerHistogram) Run time measured in the worker with microsecond resolution. Run time rounded to whole milliseconds before it is recorded.
Histogram percentiles Log-linear buckets: exact below 128 µs, then 64 sub-buckets per power of two, so values have at most 1.6 % relative error. Empty histograms read like empty Node.js histograms (min 9223372036854776, max 0, mean/stddev NaN, percentiles 0, all in ms). Node.js RecordableHistogram (HDR, 3 significant digits).
Results when a worker exits A result the worker finished before it exited is delivered (resolved), even if the 'exit' event arrives before the main thread has read it. The task is rejected with worker exited with code: N if the result message had not been processed yet.
An argument structured clone refuses, submitted while every worker is busy Rejected at once, when the task is staged behind a busy worker (see Prefetch below), with the same DataCloneError. Rejected later, when a worker frees up and the task is dispatched.
Result for an unknown task 'error' event with Unexpected result from Worker for slot N. vortex never expects to emit it. Unexpected message from Worker: …

Same behaviour, different mechanism

These are listed so that nobody mistakes them for differences.