Skip to content

Commit 5a15f4b

Browse files
committed
perf(core): end idle workers after 500ms instead of a second
A worker only ended a second after its last task, so the `jsx-ast` workers and their heaps (~800MB on the Node.js docs) were still there while the main thread bundled the site, which is when the build peaked. They now end half a second after running out of work: soon enough to be gone while the site is bundled, but not in the short gaps between two generators, where ending and starting workers again costs time. On Node core's build with 4 threads on Node 26, the peak goes from ~2.31GB to ~1.91GB. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 257e25b commit 5a15f4b

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ export default function createWorkerPool(threads) {
2424
filename: workerScript,
2525
minThreads: 0,
2626
maxThreads: threads,
27-
idleTimeout: 1_000,
27+
// A worker idle for half a second ends, so its heap is gone during a long
28+
// stretch of work on the main thread, such as bundling the site, while the
29+
// short gaps between generators leave it running
30+
idleTimeout: 500,
2831
resourceLimits: { maxOldGenerationSizeMb: WORKER_HEAP_SIZE },
2932
workerData: { logLevel: logger.getLogLevel() },
3033
});

0 commit comments

Comments
 (0)