Skip to content

Commit 4819730

Browse files
committed
perf(test): maximize thread pool based on CPU count
Optimize vitest performance to offset isolate: true overhead: - Use os.cpus().length instead of hardcoded maxThreads: 16 - Scale minThreads based on available CPUs - Better hardware utilization on different machines Benefits: - CI machines with fewer cores won't over-allocate threads - Local development uses all available CPU cores - Adaptive performance across different environments Performance impact: - Individual test files run in ~180ms - Full parallelization helps offset isolation overhead
1 parent 780e04f commit 4819730

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/cli/vitest.config.mts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import os from 'node:os'
2+
13
import { defineConfig } from 'vitest/config'
24

35
import { getLocalPackageAliases } from './scripts/utils/get-local-package-aliases.mjs'
@@ -33,8 +35,10 @@ export default defineConfig({
3335
poolOptions: {
3436
threads: {
3537
singleThread: false,
36-
maxThreads: isCoverageEnabled ? 1 : 16,
37-
minThreads: isCoverageEnabled ? 1 : 4,
38+
// Maximize parallel execution to offset isolate: true performance cost.
39+
// Use CPU count for better hardware utilization.
40+
maxThreads: isCoverageEnabled ? 1 : os.cpus().length,
41+
minThreads: isCoverageEnabled ? 1 : Math.min(4, os.cpus().length),
3842
// IMPORTANT: Changed to isolate: true to fix worker thread termination issues.
3943
//
4044
// Previous configuration (isolate: false) caused "Terminating worker thread"

0 commit comments

Comments
 (0)