perf(test): cap vitest worker fan-out to keep dashboard responsive
On high-core dev machines (e.g. 28-core M-series), per-package vitest defaulted to cpus().length - 1 workers (27), and `pnpm test` ran 4 workspace packages concurrently — easily 100+ vitest threads per sweep. When the dashboard had agents running tests, 2+ concurrent sweeps would saturate CPU and the UI became sluggish. - Cap defaultMaxWorkers to min(6, cpus()-1) in cli/dashboard/desktop/ mobile/plugin-sdk vitest configs (engine and core were already capped) - Lower root `pnpm test` workspace-concurrency 4 → 2 - VITEST_MAX_WORKERS override still respected for explicit fast runs Worst-case fan-out drops from ~108 workers to ~12 per `pnpm test`. CI runners with fewer cores are unaffected (cap doesn't bind). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
5
.changeset/cap-vitest-fanout.md
Normal file
5
.changeset/cap-vitest-fanout.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@runfusion/fusion": patch
|
||||
---
|
||||
|
||||
Cap per-package Vitest worker fan-out to 6 (from `cpus().length - 1`) and lower the root `pnpm test` workspace concurrency from 4 to 2. On high-core developer machines this prevents `pnpm test` from spawning 100+ worker threads, which was saturating CPU and slowing the dashboard while agents ran tests. Override is still available via `VITEST_MAX_WORKERS`.
|
||||
@@ -24,7 +24,7 @@
|
||||
"verify:workspace": "pnpm lint && pnpm test && pnpm build",
|
||||
"build:exe": "pnpm build && pnpm --filter @runfusion/fusion build:exe",
|
||||
"build:exe:all": "pnpm build && pnpm --filter @runfusion/fusion build:exe:all",
|
||||
"test": "pnpm sync:fusion-skill:check && pnpm -r --workspace-concurrency=4 test",
|
||||
"test": "pnpm sync:fusion-skill:check && pnpm -r --workspace-concurrency=2 test",
|
||||
"test:serial": "pnpm -r --workspace-concurrency=1 test",
|
||||
"test:fast": "pnpm -r --workspace-concurrency=4 test",
|
||||
"test:build": "pnpm --filter @fusion/dashboard test:build",
|
||||
|
||||
@@ -2,9 +2,11 @@ import { defineConfig } from "vitest/config";
|
||||
import { resolve } from "node:path";
|
||||
import { cpus } from "node:os";
|
||||
|
||||
// Use all-but-one core by default. Override with VITEST_MAX_WORKERS for
|
||||
// constrained environments (CI runners, laptops on battery, etc.).
|
||||
const defaultMaxWorkers = Math.max(1, cpus().length - 1);
|
||||
// Cap fan-out to 6 so high-core dev machines don't spawn 27+ workers per
|
||||
// package — that saturates the box when multiple workspace packages test
|
||||
// concurrently or when the dashboard has agents running tests in parallel.
|
||||
// Override with VITEST_MAX_WORKERS for explicit fast/serial runs.
|
||||
const defaultMaxWorkers = Math.min(6, Math.max(1, cpus().length - 1));
|
||||
const requestedMaxWorkers = Number.parseInt(process.env.VITEST_MAX_WORKERS ?? String(defaultMaxWorkers), 10);
|
||||
const maxWorkers = Math.max(1, Number.isFinite(requestedMaxWorkers) ? requestedMaxWorkers : defaultMaxWorkers);
|
||||
process.env.VITEST_MAX_WORKERS = String(maxWorkers);
|
||||
|
||||
@@ -3,7 +3,9 @@ import react from "@vitejs/plugin-react";
|
||||
import { resolve } from "node:path";
|
||||
import { cpus } from "node:os";
|
||||
|
||||
const defaultMaxWorkers = Math.max(1, cpus().length - 1);
|
||||
// Cap fan-out to 6 so high-core dev machines don't spawn 27+ workers per
|
||||
// package — that saturates the box when workspace packages test concurrently.
|
||||
const defaultMaxWorkers = Math.min(6, Math.max(1, cpus().length - 1));
|
||||
const requestedMaxWorkers = Number.parseInt(process.env.VITEST_MAX_WORKERS ?? String(defaultMaxWorkers), 10);
|
||||
const maxWorkers = Math.max(1, Number.isFinite(requestedMaxWorkers) ? requestedMaxWorkers : defaultMaxWorkers);
|
||||
process.env.VITEST_MAX_WORKERS = String(maxWorkers);
|
||||
|
||||
@@ -2,7 +2,8 @@ import { defineConfig } from "vitest/config";
|
||||
import { cpus } from "node:os";
|
||||
import { resolve } from "node:path";
|
||||
|
||||
const defaultMaxWorkers = Math.max(1, cpus().length - 1);
|
||||
// Cap fan-out to 6 to avoid saturating high-core machines under workspace concurrency.
|
||||
const defaultMaxWorkers = Math.min(6, Math.max(1, cpus().length - 1));
|
||||
const requestedMaxWorkers = Number.parseInt(process.env.VITEST_MAX_WORKERS ?? String(defaultMaxWorkers), 10);
|
||||
const maxWorkers = Math.max(1, Number.isFinite(requestedMaxWorkers) ? requestedMaxWorkers : defaultMaxWorkers);
|
||||
process.env.VITEST_MAX_WORKERS = String(maxWorkers);
|
||||
|
||||
@@ -2,7 +2,8 @@ import { defineConfig } from "vitest/config";
|
||||
import { cpus } from "node:os";
|
||||
import { resolve } from "node:path";
|
||||
|
||||
const defaultMaxWorkers = Math.max(1, cpus().length - 1);
|
||||
// Cap fan-out to 6 to avoid saturating high-core machines under workspace concurrency.
|
||||
const defaultMaxWorkers = Math.min(6, Math.max(1, cpus().length - 1));
|
||||
const requestedMaxWorkers = Number.parseInt(process.env.VITEST_MAX_WORKERS ?? String(defaultMaxWorkers), 10);
|
||||
const maxWorkers = Math.max(1, Number.isFinite(requestedMaxWorkers) ? requestedMaxWorkers : defaultMaxWorkers);
|
||||
process.env.VITEST_MAX_WORKERS = String(maxWorkers);
|
||||
|
||||
@@ -3,7 +3,8 @@ import { cpus } from "node:os";
|
||||
import { resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const defaultMaxWorkers = Math.max(1, cpus().length - 1);
|
||||
// Cap fan-out to 6 to avoid saturating high-core machines under workspace concurrency.
|
||||
const defaultMaxWorkers = Math.min(6, Math.max(1, cpus().length - 1));
|
||||
const requestedMaxWorkers = Number.parseInt(process.env.VITEST_MAX_WORKERS ?? String(defaultMaxWorkers), 10);
|
||||
const maxWorkers = Math.max(1, Number.isFinite(requestedMaxWorkers) ? requestedMaxWorkers : defaultMaxWorkers);
|
||||
process.env.VITEST_MAX_WORKERS = String(maxWorkers);
|
||||
|
||||
Reference in New Issue
Block a user