Compatibility with piscina 5.3.2
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.
- Transport. Arguments and results that are
undefined,null, booleans, numbers, or well-formed strings of up to 240 UTF-8 bytes, travel through the slot arena in shared memory (256 bytes per slot, 16 of them header). Everything else, and anything with atransferListor frommove(), travels through the worker'sMessagePort, which is structured clone itself. Errors always take the port. Lane 1 is tested againststructuredClonefor every kind of value it accepts (js/test/codec.test.mjs). Strings with lone surrogates take the port, because UTF-8 cannot carry them. - Placement. The balancer, the default
LeastBusyBalanceror a custom one, chooses the worker for every task, exactly as in piscina, including the skip queue for abortable tasks,stricterFIFO, and eager spawning. The chosen worker receives the task through its own inbox in shared memory and is woken only if it sleeps. - Prefetch. With the default balancer and queue and one task per worker, while every
worker is busy the head of the queue is staged in a busy worker's inbox, behind its
current task. The worker starts it only once nothing else is in flight, which is
exactly when piscina would dispatch it. Until then it still counts as queued
(
queueSize,maxQueue), it can be withdrawn and placed elsewhere (a worker that goes idle with nothing queued takes it; a worker that dies or is removed gives it back), anddestroy()and a forcedclose()reject it as they reject queued tasks. Tasks with an abort signal or a transfer list are never staged; a customloadBalancerortaskQueue, orconcurrentTasksPerWorker > 1, turns prefetch off. - Completion. Workers mark finished tasks in a shared bitmap. The main thread keeps
one
Atomics.waitAsyncoutstanding and settles every finished task in one batch, each inside its ownAsyncResource('Piscina.Task'). A worker whose completion finds the main thread waiting also posts a one-word wake on its port, which reaches the main thread sooner; while the main thread is busy no message is sent. - Wait and run time. The pool's
waitTimeandrunTimehistograms are recorded at the same points as in piscina: at dispatch, and when the task settles on the main thread. A staged task counts as dispatched when the task ahead of it settles. - Environment switches. Workers honour
PISCINA_DISABLE_ATOMICS=1andPISCINA_ENABLE_ASYNC_ATOMICS=1, as in piscina. - Handler lookup. As in piscina:
import()first, so a CommonJS module becomes a namespace andnameselects a property; then an ESM import of the file URL; either may export a promise of the handler.