fix(test): preserve one-worker budgets under moderate load (#156258)

Co-authored-by: Peter Steinberger <steipete@gmail.com>
This commit is contained in:
Peter Steinberger 2026-09-23 00:34:51 -07:00 • committed by GitHub
parent 75fe4fec44
commit da98b092e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 2 deletions

View file

@ -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,
};
}

View file

@ -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 },