From d35dd5cdd8ca59e925fe4d915f18f0de85d4d22e Mon Sep 17 00:00:00 2001 From: Claudio Wunder Date: Tue, 3 Nov 2026 19:06:22 +0100 Subject: [PATCH] perf: use up to 6 threads by default With generators streaming into each other, more threads now pay off, so DEFAULT_MAX_THREADS goes from 4 to 6. On the Node.js API docs the site build is ~15% faster at 6 threads than at 4, for ~20% more memory; 8 threads were no faster than 6 and used ~15% more. Machines with fewer CPUs, like CI's 4, are unaffected, and --threads still sets any count. Assisted-by: Claude Opus 5.5 Assisted-by: Claude Sonnet 5.5 --- .changeset/six-threads.md | 5 +++++ docs/configuration.md | 2 +- packages/core/src/threading/constants.mjs | 5 +++-- 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 .changeset/six-threads.md diff --git a/.changeset/six-threads.md b/.changeset/six-threads.md new file mode 100644 index 000000000..adc09d4c7 --- /dev/null +++ b/.changeset/six-threads.md @@ -0,0 +1,5 @@ +--- +'@doc-kit/core': minor +--- + +Builds use up to 6 threads by default, instead of 4: with generators streaming into each other, more threads now pay off. On the Node.js API docs, the site build is ~15% faster at 6 threads than at 4, for ~20% more memory, while 8 threads were no faster than 6. `--threads` still sets any count. diff --git a/docs/configuration.md b/docs/configuration.md index 8d14a398e..7b52af6db 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -180,7 +180,7 @@ These sit at the top level, next to `target` and `global`: - `threads` {number} Worker threads to process with, at least 1. With `1`, everything runs on the main thread. **Default:** the number of CPUs, up to - 4 (`1` on riscv64). + 6 (`1` on riscv64). - `chunkSize` {number} Items each worker processes per task, at least 1. **Default:** `10`. - `discardResults` {boolean} Keep none of the requested generators' results, diff --git a/packages/core/src/threading/constants.mjs b/packages/core/src/threading/constants.mjs index 21f5178a2..6e2e08bfe 100644 --- a/packages/core/src/threading/constants.mjs +++ b/packages/core/src/threading/constants.mjs @@ -3,9 +3,10 @@ /** * The default `threads` ceiling. Each worker holds a heap of its own, with the * libraries and the pages it is working on, so past a few threads memory, not - * CPU, is what runs out. `--threads` raises it. + * CPU, is what runs out: on the Node.js docs, 8 threads were no faster than 6, + * for ~15% more memory. `--threads` raises it. */ -export const DEFAULT_MAX_THREADS = 4; +export const DEFAULT_MAX_THREADS = 6; /** * The heap size limit of each worker thread (V8's old space), in MB. V8 lets a