---
title: "vortex: a drop-in replacement for piscina 5.3.2"
description: "Drop-in replacement for piscina 5.3.2: a Node.js worker thread pool with a lock-free shared-memory core, in plain JS (default) or Rust/WebAssembly"
canonical: "https://vortex.avarok.net/"
lastmod: "2026-11-29T00:48:58Z"
tokens: 4429
---

# vortex

A drop-in replacement for piscina 5.3.2: a Node.js worker thread pool with a lock-free shared-memory core.

Same API, same options, same events. piscina's own test suite runs against it unmodified and passes. MIT OR Apache-2.0.

@avarok/vortex 0.1.0 · Updated 2026-11-28

- [@avarok/vortex on npm](https://www.npmjs.com/package/@avarok/vortex)
- [Source on GitHub](https://github.com/Avarok-Cybersecurity/vortex)
- [Design notes](https://vortex.avarok.net/docs/design/)
- [llms.txt](https://vortex.avarok.net/llms.txt)

**What it is.** vortex runs JavaScript functions on a pool of Node.js `worker_threads`, with the public interface of [piscina](https://github.com/piscinajs/piscina) 5.3.2: `run()`, `close()`, `destroy()`, abort signals, `move()`, task queues, custom load balancers, histograms and every option piscina accepts. Underneath, queues, placement, completion and worker accounting live in one `SharedArrayBuffer`. Workers take tasks from their own inbox in shared memory, and small arguments and results (`undefined`, `null`, booleans, numbers, strings up to 240 UTF-8 bytes) never touch a `MessagePort`.

**Status.** Version 0.1.0, [on npm](https://www.npmjs.com/package/@avarok/vortex). The shared-memory core comes in two implementations of one specification: plain JavaScript (the default) and Rust (`no_std`, no allocator, no locks) compiled to WebAssembly, chosen with `core: 'rust'`. piscina's suite passes on both, and every benchmark below is reported for both.

## Quick start

```sh
npm install @avarok/vortex   # Node.js 20 or newer
```

```js
// worker.js
module.exports = ({ a, b }) => a + b;

// main.mjs
import Piscina from '@avarok/vortex';
const pool = new Piscina({ filename: new URL('./worker.js', import.meta.url).href });
console.log(await pool.run({ a: 4, b: 6 })); // 10
await pool.close();
```

CommonJS works the same way: `const Piscina = require('@avarok/vortex')`. The named exports are piscina's: `Piscina`, `move`, `isWorkerThread`, `workerData`, `FixedQueue`, `ArrayTaskQueue` and the symbols.

## Migrating from piscina

Change the import. Nothing else.

```diff
- const Piscina = require('piscina');
+ const Piscina = require('@avarok/vortex');
```

```diff
- import { Piscina } from 'piscina';
+ import { Piscina } from '@avarok/vortex';
```

- **piscina options are unchanged.** Same names, same defaults, same validation and the same error messages; worker files written for piscina run as they are.
- **`spin`** (vortex only, default `true`): an idle worker spins briefly, adaptively and at most 50 µs, before it sleeps. `spin: false` turns that off.
- **`core`** (vortex only, default `'js'`): `'rust'` runs the pool on the Rust/wasm core instead. Both implement the same memory layout and protocol ([docs/design/10-core-spec.md](https://vortex.avarok.net/docs/design/10-core-spec/)); a differential test holds them to byte-identical results. On the measured cells the Rust core was as fast or faster, by up to 2× at 8 threads (below).
- **Known differences** are listed, every one, in [docs/COMPAT.md](https://vortex.avarok.net/docs/compat/). The two most likely to matter: `maxThreads` is capped at 2047, and at most 4096 tasks are in flight at once (the default balancer never reaches that limit unless `maxThreads × concurrentTasksPerWorker` exceeds it).

## Benchmarks

Measured on one machine: **Apple M4 Pro (12 cores, 8P + 4E), 48 GB, macOS, Node.js v22.23.3**, both vortex cores (build `ce`, commit e90e5f4). Fixed iterations (echo 200,000 tasks, obj 100,000, spin50 40,000, 1,024 in flight; latency 20,000 sequential round trips). Every cell runs in a fresh process, with a warmup and five repetitions, all implementations interleaved within each repetition. A load gate (1-minute load under 15, no CI job on the machine) was checked before and after every cell; none was discarded. Pools run at `minThreads = maxThreads = threads`, library defaults otherwise.

 ![Throughput in tasks per second, median of five, in the order vortex JS core, vortex Rust core, piscina, tinypool, workerpool. echo at 4 threads: 622k, 686k, 131k, 207k, 182k; at 8 threads: 274k, 559k, 107k, 182k, 163k. obj at 4 threads: 405k, 428k, 123k, 202k, 176k; at 8 threads: 227k, 355k, 102k, 181k, 155k. spin50 at 4 threads: 74.9k, 74.7k, 55.7k, 56.1k, 55.8k; at 8 threads: 143k, 142k, 80.9k, 97.6k, 89.7k.](https://vortex.avarok.net/assets/bench-throughput.svg) ![Sequential round-trip latency in microseconds, p50 / p99, in the order vortex JS core, vortex Rust core, piscina, tinypool, workerpool. 4 threads: 4.4 / 12.1, 4.4 / 10.7, 11.7 / 19.9, 10.3 / 17.2, 9.5 / 17.4. 8 threads: 4.5 / 13.2, 4.5 / 12.1, 13.7 / 24.3, 10.6 / 17.6, 9.5 / 18.0.](https://vortex.avarok.net/assets/bench-latency.svg)

Median of five repetitions. Bold marks the best in that row.

| workload                     | threads | vortex, JS core (default) | vortex, Rust/wasm core | piscina 5.3.2 | tinypool 2.2.0 | workerpool 10.0.3 |
| ---------------------------- | ------- | ------------------------- | ---------------------- | ------------- | -------------- | ----------------- |
| echo, tasks/s                | 4       | 622k                      | **686k**               | 131k          | 207k           | 182k              |
| echo, tasks/s                | 8       | 274k                      | **559k**               | 107k          | 182k           | 163k              |
| obj, tasks/s                 | 4       | 405k                      | **428k**               | 123k          | 202k           | 176k              |
| obj, tasks/s                 | 8       | 227k                      | **355k**               | 102k          | 181k           | 155k              |
| spin50, tasks/s (ideal 80k)  | 4       | **74.9k**                 | 74.7k                  | 55.7k         | 56.1k          | 55.8k             |
| spin50, tasks/s (ideal 160k) | 8       | **143k**                  | 142k                   | 80.9k         | 97.6k          | 89.7k             |
| latency p50, µs              | 4       | **4.4**                   | **4.4**                | 11.7          | 10.3           | 9.5               |
| latency p50, µs              | 8       | **4.5**                   | **4.5**                | 13.7          | 10.6           | 9.5               |
| latency p99, µs              | 4       | 12.1                      | **10.7**               | 19.9          | 17.2           | 17.4              |
| latency p99, µs              | 8       | 13.2                      | **12.1**               | 24.3          | 17.6           | 18.0              |

`echo` returns its argument, `obj` returns a small object (it travels through the port), `spin50` busy-waits 50 µs. On these workloads both vortex cores had higher throughput than the other three pools in every cell (1.3–5.2× piscina, 1.25–3.3× tinypool) and the lowest p50 and p99 latency. **The JS core is the slower of the two at 8 threads** (echo 274k against 559k, obj 227k against 355k) and its 8-thread throughput varies between runs (echo 270k–381k over five repetitions); the cause has not been investigated yet.

Raw data, one line per cell with CPU, Node version and load: [`bench/results/cores-t4.jsonl`](https://github.com/Avarok-Cybersecurity/vortex/blob/HEAD/bench/results/cores-t4.jsonl) and [`cores-t8.jsonl`](https://github.com/Avarok-Cybersecurity/vortex/blob/HEAD/bench/results/cores-t8.jsonl) (the run also measured every intermediate build). Method, fix series and step-by-step analysis: [docs/design/09-bench.md](https://vortex.avarok.net/docs/design/09-bench/). One script draws the charts and the table from the jsonl ([`bench/charts.json`](https://github.com/Avarok-Cybersecurity/vortex/blob/HEAD/bench/charts.json)); CI fails if they differ:

```sh
node scripts/bench-charts.mjs bench/charts.json assets
```

### How the four compare

|                  | vortex                                                        | piscina       | tinypool                    | workerpool    |
| ---------------- | ------------------------------------------------------------- | ------------- | --------------------------- | ------------- |
| API              | piscina 5.3.2's, tested by piscina's suite                    | its own       | piscina-like, not identical | its own       |
| Version measured | 0.1.0 (pre-release)                                           | 5.3.2         | 2.2.0                       | 10.0.3        |
| Licence          | MIT OR Apache-2.0                                             | MIT           | MIT                         | Apache-2.0    |
| Task transport   | shared-memory slots for small values, `postMessage` otherwise | `postMessage` | `postMessage`               | `postMessage` |

## What this does not prove

- **No "fastest" claim beyond these cells.** One machine (Apple M4 Pro), one OS (macOS), one Node.js version (22.23.3), four workloads, 4 and 8 threads, library defaults. Not measured: Linux or x86, Node.js 20 or 24, payloads over 240 bytes beyond `obj`, transfer lists, abortable tasks, custom balancers, `concurrentTasksPerWorker > 1`, `atomics: 'async'`, many pools in one process, long mixed workloads.
- **Most of the latest gain is one shim change, not the core.** Step by step: the Rust core's call-cost work took echo at 4 threads from 395k to 432k; waking the main thread by port message alone (no `Atomics.waitAsync`) took it to 686k and p99 from 28 to 11 µs.
- **Builds before commit 9a39534 can hang**: a lost wake-up in the main thread's completion wait (both cores; 2 of 40 cold `obj` cells). Fixed; modelled in `loom_main_wait.rs`.
- **Open defect: a terminated worker can survive `terminate()`.** With source maps enabled (`--enable-source-maps`, or the `tsx` loader piscina's test suite runs under) and a task that runs `eval`, a worker running a `while (true)` task occasionally keeps running after `terminate()`, so `destroy()` never settles: 3 of 100 cold runs of one piscina test; 0 of 100 without flags or without `eval`; 0 for piscina. Cause unknown: [docs/design/08-node-shim.md §8.8](https://vortex.avarok.net/docs/design/08-node-shim/).

## Compatibility

piscina 5.3.2's test suite is vendored unmodified in `compat/piscina-5.3.2/` (pinned by sha256) and runs against vortex and against piscina itself through the same harness. On Node.js 22.23.3 (macOS, arm64): **154 tests, 149 pass, 5 skipped, 0 fail**, for both. The skips are the suite's own conditions (`nice` tests that run only on Linux or Windows, Node.js 24-only dispose tests, a test for machines with at most 8 CPUs). The same counts hold on Node.js 20.20.2 and 25.1.0. The Node.js 24-only tests have not been run against vortex yet.

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

## How it works

- **`js/src/core`**: the core interface (`CoreApi`) and the JS core, the default.
- **`crates/vortex-core`**: the Rust core. `no_std`, no allocator, no locks, no I/O. A worker can die at any instruction and the core recovers its tasks. Checked with loom models, property tests and native stress tests in `crates/vortex-core-tests`.
- **`crates/vortex-wasm`**: the core compiled for `wasm32-unknown-unknown` with shared memory, behind a flat FFI. No wasm-bindgen.
- **`js/src`**: the TypeScript shim that is piscina's interface: options, queues, balancers, abort, histograms, async resources, close and destroy.

Design notes, proofs and measurements: [docs/DESIGN.md](https://vortex.avarok.net/docs/design/).

## Questions people ask

### Is vortex a drop-in replacement for piscina?

For piscina 5.3.2, yes: change the import. piscina's own suite passes unmodified; the differences we know of are in [docs/COMPAT.md](https://vortex.avarok.net/docs/compat/).

### Is it faster than piscina?

On the measured cells (Apple M4 Pro, Node.js 22.23.3, 4 and 8 threads), throughput was 1.3–5.2× piscina's, and p50 and p99 latency were the lowest of the pools measured. Nothing else has been measured.

### Which core should I use?

Both pass the same suite. `core: 'rust'` was as fast or faster on every measured cell, up to 2× at 8 threads.

### Does it need Rust at runtime?

No. The core ships as a `.wasm` file inside `dist/`. Rust is needed only to build from source.

### How do I build it from source?

`npm ci && npm run build` in a clone. That needs the Rust toolchain pinned in `rust-toolchain.toml`, with the `wasm32-unknown-unknown` target.

### Which Node.js versions?

20 and newer (`engines`). The piscina suite has been run on 20.20.2, 22.23.3 and 25.1.0.

## Contributing and security

See [CONTRIBUTING.md](https://github.com/Avarok-Cybersecurity/vortex/blob/HEAD/CONTRIBUTING.md) and the [code of conduct](https://github.com/Avarok-Cybersecurity/vortex/blob/HEAD/CODE_OF_CONDUCT.md). Report vulnerabilities privately, as described in [SECURITY.md](https://github.com/Avarok-Cybersecurity/vortex/blob/HEAD/SECURITY.md).

vortex is a project of **[Avarok Cybersecurity](https://github.com/Avarok-Cybersecurity)**.

## License

Licensed under either of

- Apache License, Version 2.0 ([LICENSE-APACHE](https://github.com/Avarok-Cybersecurity/vortex/blob/HEAD/LICENSE-APACHE) or [https://www.apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0))
- MIT license ([LICENSE-MIT](https://github.com/Avarok-Cybersecurity/vortex/blob/HEAD/LICENSE-MIT) or [https://opensource.org/licenses/MIT](https://opensource.org/licenses/MIT))

at your option. Material from piscina and Node.js is credited in [THIRD-PARTY-NOTICES.md](https://github.com/Avarok-Cybersecurity/vortex/blob/HEAD/THIRD-PARTY-NOTICES.md); see also [NOTICE](https://github.com/Avarok-Cybersecurity/vortex/blob/HEAD/NOTICE).

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

```json
{
  "@context": "https://schema.org",
  "@graph": [
    {
      "@id": "https://thomaspbraun.com/#person",
      "@type": "Person",
      "name": "Thomas Braun",
      "sameAs": [
        "https://github.com/tbraun96"
      ],
      "url": "https://thomaspbraun.com",
      "worksFor": {
        "@id": "https://avarok.net/#organization"
      }
    },
    {
      "@id": "https://avarok.net/#organization",
      "@type": "Organization",
      "name": "Avarok",
      "url": "https://avarok.net"
    },
    {
      "@id": "https://vortex.avarok.net/#website",
      "@type": "WebSite",
      "inLanguage": "en",
      "name": "vortex",
      "publisher": {
        "@id": "https://thomaspbraun.com/#person"
      },
      "url": "https://vortex.avarok.net/"
    },
    {
      "@id": "https://vortex.avarok.net/",
      "@type": "WebPage",
      "about": {
        "@id": "https://vortex.avarok.net/#software"
      },
      "author": {
        "@id": "https://thomaspbraun.com/#person"
      },
      "dateModified": "2026-11-28",
      "description": "Drop-in replacement for piscina 5.3.2: a Node.js worker thread pool with a lock-free shared-memory core, in plain JS (default) or Rust/WebAssembly",
      "inLanguage": "en",
      "isPartOf": {
        "@id": "https://vortex.avarok.net/#website"
      },
      "name": "vortex",
      "url": "https://vortex.avarok.net/"
    },
    {
      "@id": "https://vortex.avarok.net/#source",
      "@type": "SoftwareSourceCode",
      "author": {
        "@id": "https://thomaspbraun.com/#person"
      },
      "codeRepository": "https://github.com/Avarok-Cybersecurity/vortex",
      "description": "Drop-in replacement for piscina 5.3.2: a Node.js worker thread pool with a lock-free shared-memory core, in plain JS (default) or Rust/WebAssembly",
      "keywords": "piscina, worker-threads, thread-pool, worker-pool, workers, nodejs, multithreading, parallelism, shared-memory, sharedarraybuffer, atomics, lock-free, webassembly, wasm, rust",
      "license": [
        "https://opensource.org/licenses/MIT",
        "https://www.apache.org/licenses/LICENSE-2.0"
      ],
      "maintainer": {
        "@id": "https://thomaspbraun.com/#person"
      },
      "name": "@avarok/vortex",
      "programmingLanguage": [
        "TypeScript",
        "JavaScript",
        "Rust",
        "WebAssembly"
      ],
      "runtimePlatform": "Node.js &gt;=20",
      "sourceOrganization": {
        "@id": "https://avarok.net/#organization"
      },
      "targetProduct": {
        "@id": "https://vortex.avarok.net/#software"
      },
      "version": "0.1.0"
    },
    {
      "@id": "https://vortex.avarok.net/#software",
      "@type": "SoftwareApplication",
      "alternateName": "vortex",
      "applicationCategory": "DeveloperApplication",
      "applicationSubCategory": "Node.js library",
      "author": {
        "@id": "https://thomaspbraun.com/#person"
      },
      "description": "Drop-in replacement for piscina 5.3.2: a Node.js worker thread pool with a lock-free shared-memory core, in plain JS (default) or Rust/WebAssembly",
      "downloadUrl": "https://www.npmjs.com/package/@avarok/vortex",
      "isAccessibleForFree": true,
      "license": [
        "https://opensource.org/licenses/MIT",
        "https://www.apache.org/licenses/LICENSE-2.0"
      ],
      "name": "@avarok/vortex",
      "offers": {
        "@type": "Offer",
        "price": "0",
        "priceCurrency": "USD"
      },
      "operatingSystem": "Node.js &gt;=20",
      "publisher": {
        "@id": "https://avarok.net/#organization"
      },
      "softwareVersion": "0.1.0",
      "url": "https://vortex.avarok.net/"
    }
  ]
}
```
