perf(test): parallelize unit test files to halve validate wall time - #849
Merged
Merged
Conversation
Drop the shared fileParallelism: false so node-unit and workers-unit files run across all cores. The serialized run spent 180s of its 310s CI duration on module imports alone; parallel workers cut the suite from ~196s to ~82s locally. The mcp-e2e project keeps fileParallelism disabled explicitly because each file boots a real Wrangler dev server against the shared seeded e2e database.
The worker:test and worker:test-mcp targets only hashed project files, so edits to vitest*.ts configs or tools/ (which hold vite plugins and root-level test files picked up by the runner) returned stale cache hits.
📝 WalkthroughWalkthroughNx test targets now track Vitest and tooling inputs. CI worker limits, MCP e2e file sequencing, and Playwright web-server startup timeouts are updated to coordinate test execution and startup. ChangesTest configuration
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
kody-bot
marked this pull request as ready for review
July 22, 2026 05:42
Contributor
|
🔎 Preview deployed: https://kody-pr-849.kody-a99.workers.dev Worker: Mocks:
|
…t tests The parallel unit test workers saturate all 4 CI cores at the start of validate, and the Playwright webServer (client build + D1 migrations + Wrangler boot) timed out at the default 60s. Raise the webServer budget to 180s in CI and cap vitest at 3 workers there so Wrangler startup is not starved.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
npm run validatein CI takes ~5m20s, and the whole job ~6.5min. Per-check completion times inside a recent run (29892110417) show the unit test suite is the entire critical path:The vitest summary explains why: 327 files, 310s total, of which 180s is module import time and only 62s is actual test time — all serialized by
fileParallelism: falseinvitest-shared.ts(present since the original projects migration with no stated rationale).Change
fileParallelism: falsefrom the shared vitest project config, sonode-unit(289 files) andworkers-unit(37 files) run files across all cores. In CI, cap vitest at 3 workers so the concurrent Wrangler/Playwright startups are not starved on 4-core runners.mcp-e2eexplicitly serial with a comment: each file boots a real Wrangler dev server against the shared seeded e2e database.webServerstartup budget to 180s in CI: with unit tests using all cores, the e2e server (client build + D1 migrations + Wrangler boot) exceeded the default 60s on the first CI attempt.worker:test/worker:test-mcponly hashed project files, so edits to the rootvitest*.tsconfigs ortools/(vite plugins + root-level test files the runner picks up) returned stale cache hits. Both targets now include those paths in their inputs.Measurements
npm run validatelocally withCI=true, cold cache: 1m54s, all 8 checks green.Follow-up candidates (not in this PR)
workers: 1due to documented SQLITE_BUSY contention on the shared local D1 file). Per-worker databases would unlock parallelism there.isolate: falsefornode-unitcould cut the remaining per-file import cost further, but risks cross-file state leakage; not worth the flake risk without more investigation.System recap — composes existing primitives (low risk)
Mode: recap · Base:
main@36d84e2e· Head:e52169dfClassification: composes — no primitives added or changed. The diff touches only test-runner configuration (
vitest-shared.ts,vitest.mcp-e2e.config.ts,playwright.config.ts) and nx cache inputs (nx.json); the primitives classifier matches zero primitives, the lowest-risk outcome. No runtime, storage, or surface code changes.Primitives touched
None. All four changed files are repo tooling outside the primitives map.
Summary by CodeRabbit