---
title: "vortex: design · vortex"
description: "vortex is a worker thread pool whose core (queues, scheduling, worker accounting, backpressure, timing) is Rust compiled to wasm32-unknown-unknown with shared…"
canonical: "https://vortex.avarok.net/docs/design/"
lastmod: "2026-11-27T17:37:04Z"
tokens: 1055
---

# vortex: design

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

vortex is a worker thread pool whose core (queues, scheduling, worker accounting, backpressure, timing) is Rust compiled to `wasm32-unknown-unknown` with shared memory, and whose public interface is a drop-in replacement for [piscina](https://github.com/piscinajs/piscina) **5.3.2**.

Status: phases 2a–2c done (core, Node.js shim; piscina 5.3.2's suite passes unmodified). Behaviour differences: [COMPAT.md](https://vortex.avarok.net/docs/compat/).

## Chapters

1. [The interface vortex matches](https://vortex.avarok.net/docs/design/01-interface/): pinned version, every export, option, method, event, property, static, worker convention and error string, with defaults and validation.
2. [Architecture](https://vortex.avarok.net/docs/design/02-architecture/): one shared `WebAssembly.Memory`, the Rust core (`no_std`, lock-free, no allocator, survives a worker killed at any instruction), the JS shim and why each JS piece cannot be Rust, task lifecycle, scheduling modes, the three-lane codec, browsers.
3. [Where the speed comes from](https://vortex.avarok.net/docs/design/03-speed/): piscina's per-task costs read from its source, the techniques that remove them, their risks, and honest limits.
4. [Proof plan](https://vortex.avarok.net/docs/design/04-proof/): piscina's own test suite run unmodified against vortex, the benchmark harness and its rules, Rust concurrency tests (loom, death injection).
5. [Phased plan and owner decisions](https://vortex.avarok.net/docs/design/05-plan/).
6. [Where piscina spends per-task time](https://vortex.avarok.net/docs/design/06-piscina-profile/): CPU-profile shares (not benchmarks) behind the scheduling decisions.
7. [The Rust core as built](https://vortex.avarok.net/docs/design/07-core/): protocols, why SeqCst fences, histograms, verification record with negative controls, gaps for phase 2c.
8. [The Node.js shim as built](https://vortex.avarok.net/docs/design/08-node-shim/): push placement through per-worker inboxes (and why it replaced pull for now), the per-task path, worker waits, worker records, verification record with negative controls.

## Decisions in one place

- Reference: piscina `v5.3.2` (commit `6c7e546`); 6.x is a later additive layer.
- Shared state lives in one shared wasm memory; the main thread is the only allocator; workers never allocate and the core never takes a lock.
- The balancer (default or custom) places every task, as in piscina; the worker receives it through its own shared-memory inbox. Pull from the shared ring with prefetch stays in the core as a phase 4 ablation (chapter 8.1).
- The main thread never blocks: one `Atomics.waitAsync` drains completions in batches.
- Idle workers spin for an adaptive, capped budget, then park with `memory.atomic.wait32`.
- Values move through a fast shared-memory lane when exactness against `structuredClone` is proven, otherwise through `postMessage`, which is also the only lane for transfers and `SharedArrayBuffer`.
- Every performance claim is measured with machine load beside the number.

```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": {
        "@type": "Organization",
        "name": "Avarok",
        "url": "https://avarok.net"
      }
    },
    {
      "@id": "https://vortex.avarok.net/docs/design/",
      "@type": "WebPage",
      "author": {
        "@id": "https://thomaspbraun.com/#person"
      },
      "dateModified": "2026-11-27T17:37:04Z",
      "description": "vortex is a worker thread pool whose core (queues, scheduling, worker accounting, backpressure, timing) is Rust compiled to wasm32-unknown-unknown with shared…",
      "inLanguage": "en",
      "isPartOf": {
        "@id": "https://vortex.avarok.net/#website",
        "@type": "WebSite",
        "name": "vortex",
        "url": "https://vortex.avarok.net/"
      },
      "name": "vortex: design · vortex",
      "url": "https://vortex.avarok.net/docs/design/"
    }
  ]
}
```
