Performance
All benchmarks were measured with Knitting 0.1.77.
- HTTP latency: one worker reduced
/pingp99 by 86% at 6,000 requests per second, with similar CPU usage. - Worker calls: lower round-trip overhead than
postMessageon Node.js, Deno and Bun. - CPU throughput: 3.5× faster on Node.js with the main thread and four workers processing the same prime search.
- Typesetting: four workers were 1.86× faster on Node.js and 1.77× on Bun after warm-up. Cold runs were slower.
- Tokio comparison: Knitting on Node.js and Bun took 2–23% less time for 32–512 KiB payloads. Tokio led at 1–16 KiB and 1 MiB.
HTTP latency
Section titled “HTTP latency”In a Hono server, /ssr renders React, /jwt signs a token, and /ping
returns a small JSON object. Moving /ssr and /jwt to one worker leaves
/ping on the main thread, where it no longer waits behind that CPU work.
Both servers received 2,000 requests per second on each route.
Setup: Bun 1.4.0, Intel Xeon Platinum 8168, 16 dedicated cores, Ubuntu 24.04. A separate machine generated the load. Full report.
- Hono only
- Hono with one Knitting worker
/ping
- Hono only 16.93 ms
- One worker 2.31 ms
/ssr
- Hono only 14.32 ms
- One worker 8.71 ms
/jwt
- Hono only 25.18 ms
- One worker 9.76 ms
/ping p99 fell by 86%, /ssr by 39%,
and /jwt by 61%. Here, p99 is the response time within
which 99% of requests completed.
Both servers handled all 6,000 requests per second successfully. CPU usage was similar:
- Hono only
- Hono with one Knitting worker
- Hono only 1.08 cores
- One worker 1.10 cores
The fixed-rate repeat used 1.06 cores, close to the 1.08-core baseline.
Under saturating load, the same change raised total throughput from 8,208 to 18,014 requests per second, and CPU use from 1.19 to 1.79 cores.
Worker call overhead
Section titled “Worker call overhead”This test measures the time to send an empty task to one worker and receive its reply. It isolates the overhead of a worker call.
Setup: Apple M3 Ultra, macOS arm64; Node.js 24.12.0, Deno 2.6.6 and Bun 1.3.6. Bars show average elapsed time.
- postMessage
- Knitting
Node.js
- postMessage 11.01 µs
- Knitting 1.24 µs
Deno
- postMessage 21.57 µs
- Knitting 4.99 µs
Bun
- postMessage 10.86 µs
- Knitting 2.49 µs
For one call at a time, Knitting was 8.9× faster on Node.js, 4.3× faster on Deno, and 4.4× faster on Bun. With 100 calls in flight, it was 5.9× faster on Node.js, 26.0× faster on Deno, and 6.3× faster on Bun. The batched results compare throughput; an individual call may take longer than the average time per call.
With payloads, both paths also spend time encoding and decoding values.
Knitting was ahead on all 20 payload types compared, on every runtime, at both batch sizes.The smallest advantage was 1.2× for
a large stringon Node.js, with 100 calls in flight.
The saved reports include both the empty-call and payload comparisons for each runtime.
CPU throughput
Section titled “CPU throughput”The task finds primes up to 10,000,000 in chunks of 250,000 and returns them to the main thread. The main thread processes chunks too: four workers means five threads doing the search.
Setup: Apple M3 Ultra, macOS arm64; Node.js 24.12.0, Deno 2.6.6 and Bun 1.3.6. Bars show average time to finish the search.
- Main thread only
- Main thread plus Knitting workers
- Main thread only 959 ms
- 1 extra thread 538 ms · 1.8×
- 2 extra threads 402 ms · 2.4×
- 3 extra threads 318 ms · 3.0×
- 4 extra threads 274 ms · 3.5×
With four extra threads the run finished 3.5× faster on Node.js, 3.8× on Deno and 3.6× on Bun. These timings include sending the results back to the main thread. The reports include the other worker counts.
Typesetting a document
Section titled “Typesetting a document”knit-tex typesets a 216-page copy of Pride and Prejudice to PDF. Four workers reduced warm completion time on both runtimes:
| Runtime | Main thread | Four workers | Speedup |
|---|---|---|---|
| Node.js 24.19.0 | 427 ms | 229 ms | 1.86× |
| Bun 1.4.0 | 449 ms | 254 ms | 1.77× |
Setup: Intel Core i5-1135G7, four physical cores. Each result is the median of five runs using an already initialized pool. Output hashes matched the main-thread output on each runtime.
Four workers used more total CPU time. Cold runs and runs that started a new CLI process were slower than the main thread, so this gain matters when the pool handles repeated work. See Results and methodology for CPU times, work-stealing results and source reports.
Binary round trips against Tokio
Section titled “Binary round trips against Tokio”This test compares copying a binary payload to one worker and back. Tokio
clones a Vec<u8> on send and reply; Knitting sends a Uint8Array through
preallocated shared memory. Timings include allocation and worker coordination.
Setup: AMD Ryzen 7 4700U, Ubuntu 23.10 x86_64. Runtime versions were not recorded. Full comparison.
- Tokio (Rust)
- Knitting
- Tokio 11.92 ms
- Knitting on Bun 10.56 ms
- Knitting on Node.js 10.11 ms
- Knitting on Deno 11.96 ms
From 32 KiB to 512 KiB, Knitting on Bun and Node.js took 2% to 23% less time than Tokio. On Deno it ranged from 5% less to 10% more.
From 1 KiB to 16 KiB, Tokio was up to 3.2× faster. At 1 MiB it was 1.6–1.9× faster. The Tokio page has every size and explains how copying differs from its separate shared-ownership test.
Reproduce
Section titled “Reproduce”| Test | Harness |
|---|---|
| HTTP latency | Hono report: server in Appendix B, harness in Appendix C. |
| Worker calls | bench/latency.ts in mimiMonads/knitting; run ./run.sh from the repository root. |
| CPU throughput | bench/withload.ts in the same repository; run ./run.sh. |
| Tokio comparison | The latency suite in mimiMonads/knitting-vs-tokio-bench: node scripts/bench.mjs latency. |
Use Knitting 0.1.77 to match the tested release. Measure on your target
hardware: payload size, runtime and worker count affect the result.
For the full tables and additional measurements, see Benchmark results and methodology. For choosing buffers and worker counts, see Performance tuning.