Skip to content

Commit ad5bde5

Browse files
committed
perf: use up to 6 threads by default
With generators streaming into each other, more threads now pay off. On Node.js's docs, medians of 5 runs, the site build took 7.64s at 4 threads, 6.48s at 6 and 6.66s at 8, peaking at 1.9GB, 2.3GB and 2.7GB. The legacy build kept getting faster at 8, but by only another 5% for 320MB more. Machines with fewer CPUs are unaffected, as the default is the CPU count up to this ceiling. Keeping Rolldown and Rayon at 4 threads while doc-kit used 6 or 8 was slower and saved no memory, so the bundler still gets doc-kit's count. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 36b4da5 commit ad5bde5

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

‎.changeset/six-threads.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@doc-kit/core': minor
3+
---
4+
5+
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.

‎docs/configuration.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ these for that generator alone, except `markdown`, which it adds to.
134134
Top-level, alongside `target` and `global`:
135135

136136
- `threads` {number} Worker threads used for generation. Defaults to your
137-
CPU count. Each worker's heap is limited to 512MB; to raise the limit, run
137+
CPU count, up to 6. Each worker's heap is limited to 512MB; to raise the limit, run
138138
Node.js with `--max-old-space-size` (directly or through `NODE_OPTIONS`).
139139
- `chunkSize` {number} Items processed per worker thread. **Default:** `10`.
140140

‎packages/core/src/threading/constants.mjs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
/**
44
* The default `threads` ceiling. Each worker holds a heap of its own, with the
55
* libraries and the pages it is working on, so past a few threads memory, not
6-
* CPU, is what runs out. `--threads` raises it.
6+
* CPU, is what runs out: on the Node.js docs, 8 threads were no faster than 6,
7+
* for ~15% more memory. `--threads` raises it.
78
*/
8-
export const DEFAULT_MAX_THREADS = 4;
9+
export const DEFAULT_MAX_THREADS = 6;
910

1011
/**
1112
* The heap size limit of each worker thread (V8's old space), in MB. V8 lets a

0 commit comments

Comments
 (0)