diff --git a/scripts/lib/vitest-local-scheduling.mts b/scripts/lib/vitest-local-scheduling.mts index beaa44b396f0..d49460c52bec 100644 --- a/scripts/lib/vitest-local-scheduling.mts +++ b/scripts/lib/vitest-local-scheduling.mts @@ -234,13 +234,13 @@ export function resolveLocalVitestScheduling( } if (loadRatio >= 0.75) { - const loadWorkers = Math.max(2, Math.ceil(inferred * 0.75)); + const loadWorkers = Math.ceil(inferred * 0.75); const maxWorkers = memoryPressureLimit === null ? loadWorkers : Math.min(loadWorkers, memoryPressureLimit); return { maxWorkers, fileParallelism: maxWorkers > 1, - throttledBySystem: maxWorkers < inferred || maxWorkers < loadWorkers, + throttledBySystem: maxWorkers < inferred || memoryPressureLimit === 1, }; } diff --git a/test/scripts/vitest-local-scheduling.test.ts b/test/scripts/vitest-local-scheduling.test.ts index 18bd77dced97..508cdce39b45 100644 --- a/test/scripts/vitest-local-scheduling.test.ts +++ b/test/scripts/vitest-local-scheduling.test.ts @@ -65,6 +65,20 @@ describe("vitest scheduling host snapshot", () => { describe("local Vitest scheduling", () => { it.each([ + [ + "does not raise a single-core inferred budget under moderate load", + { cpuCount: 1, loadAverage1m: 0.75 }, + {}, + 1, + false, + ], + [ + "does not raise a four-core inferred budget under moderate load", + { cpuCount: 4, totalMemoryBytes: 16 * 1024 ** 3, loadAverage1m: 3 }, + {}, + 1, + false, + ], [ "caps total memory by the process constraint", { constrainedMemoryBytes: 16 * 1024 ** 3 },