From 2fef2f3a3b85c8b8c9601ee633f185e7bebe7165 Mon Sep 17 00:00:00 2001 From: Yunfei He Date: Fri, 29 May 2026 11:28:36 +0800 Subject: [PATCH] perf(runtime-tests): run PTY tests file-parallel across forked workers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The PTY suite was the CI wall-clock bottleneck, run serially via fileParallelism:false. The original reason for serializing was a node-pty constraint — it needs child_process.fork(), not worker_threads — but that only dictates the pool TYPE, not single-file execution. Each test already spawns its own isolated PTY subprocess (helpers/term.ts, run.ts: no shared ports, temp files, or mutable globals; cwd is the read-only fixtures dir), so files parallelize safely. Set pool:"forks" explicitly (the real node-pty requirement) and fileParallelism:true. Measured: the PTY suite drops ~37s -> ~13s (~3x), and the full `vp run ci` graph drops ~41s -> ~20s cold (no task cache, no prebuilt dist). Verified stable across 9 isolated PTY runs (incl. maxForks capped to 4 to mimic a 4-core CI runner) and 3 cold full-graph runs — 110 PTY tests pass every time, zero flakes. testTimeout stays 15s (slowest test ~2s) to absorb CPU contention on smaller runners. --- packages/runtime-tests/vitest.pty.config.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/runtime-tests/vitest.pty.config.ts b/packages/runtime-tests/vitest.pty.config.ts index 4671883..8621453 100644 --- a/packages/runtime-tests/vitest.pty.config.ts +++ b/packages/runtime-tests/vitest.pty.config.ts @@ -5,7 +5,14 @@ export default defineConfig({ plugins: [vueJsx()], test: { include: ["integration/pty/**/*.test.{ts,tsx}"], - fileParallelism: false, + // node-pty requires child_process.fork(), not worker_threads, so the pool + // MUST be "forks". Each test spawns its own isolated PTY subprocess (no + // shared ports/files/global state), so test files parallelize safely across + // forked workers — ~3x faster than serial (the PTY suite is the CI's + // wall-clock bottleneck). testTimeout stays generous (15s vs ~2s slowest + // test) to absorb CPU contention on smaller CI runners. + pool: "forks", + fileParallelism: true, testTimeout: 15000, env: { FORCE_COLOR: "3" }, },