From 4d830af2c832870934e83bceabb9b51e1196da8b 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 00000000..adc09d4c --- /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 a0d750dd..5c20ce43 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -134,7 +134,7 @@ these for that generator alone, except `markdown`, which it adds to. Top-level, alongside `target` and `global`: - `threads` {number} Worker threads used for generation. Defaults to your - CPU count. Each worker's heap is limited to 512MB; to raise the limit, run + CPU count, up to 6. Each worker's heap is limited to 512MB; to raise the limit, run Node.js with `--max-old-space-size` (directly or through `NODE_OPTIONS`). - `chunkSize` {number} Items processed per worker thread. **Default:** `10`. diff --git a/packages/core/src/threading/constants.mjs b/packages/core/src/threading/constants.mjs index 1ea409ec..fd923dab 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