From da98b092e44dce52a4e466f4d20afaf1bdbebc69 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Wed, 23 Sep 2026 00:34:51 -0700 Subject: [PATCH] fix(test): preserve one-worker budgets under moderate load (#156258) Co-authored-by: Peter Steinberger --- scripts/lib/vitest-local-scheduling.mts | 4 ++-- test/scripts/vitest-local-scheduling.test.ts | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) 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 },