- All playbooks
- Slow tests
- Match test concurrency to the runner
Match test concurrency to the runner
Measure worker counts against available CPU and memory. More workers help only while the runner has capacity.
How companies used this technique
Read what each company changed and follow the original sources.
Set test worker width from the actual host
Bun removed the CPU and thread caps that held its Linux test agents to two usable cores, and sized the parallel test width from the available cores. A follow-up capped the width at four on macOS, where each M2 Ultra host runs two tart virtual machines and every coordinator forks its own workers.
- Use it when
- A fixed worker count has never been measured, or workers contend for memory, physical cores or a shared host.
- Before applying it
- Nested worker processes and other virtual machines on the same host count toward the width.
Fit test concurrency to the runner’s memory
The memory integration configuration capped Vitest threads at two after the source reported runner disconnects and memory pressure.
The source reports 61 failures in 771 runs. Source
The current Vitest configuration expresses the limit as maxWorkers: 2. Source
- Use it when
- Parallel tests and build output compete for limited runner memory.
- Before applying it
- Preserve the separate build heap requirement and measure peak memory, elapsed time and failures across worker counts.
Measure how many tests to run at once
Codex compared Windows Bazel shards at 4, 8 and 12 local test jobs in a forced-test-execution experiment, then set the CI default to 8 with one .bazelrc line. Sharding spreads work across runners; this tunes how much runs at once on each runner.
Slowest shard: 835.5s to 609.3s at 8 local test jobs, in the experiment the PR cites Source
- Use it when
- Test parallelism is a default or a guess for this runner.
- Before applying it
- More parallel workers can increase memory pressure and contention. Compare the same workload and runner, including reliability and total minutes.
Measure workers against the runner
Stripe iOS tried six simulator workers and kept four, which was faster and more reliable, and split Crypto UI tests into separate classes so Xcode could run them in parallel. Stripe Android sized individual device-heavy lanes and raised its managed-device ceiling to match its six shards. Metronome, a Stripe company, moved a publishing job whose doc build was timing out to an 8-core runner, on a suggestion from the Stainless team.
In the same combined runs, the Crypto UI test step went from about 10 to about 6 minutes. Source
- Use it when
- Tests run serially, or worker counts and runner sizes were chosen without measurement.
- Before applying it
- Isolate shared accounts and ports before adding workers, and keep tests that verify serial behavior in a serial lane. Measure each change separately; the source PRs changed workers and machines together.
Company Playbooks
- Read Anthropic’s playbookRun only affected tests
- Read DoorDash’s playbookRun build and test in parallel, sharded across CI agents
- Read Linear’s playbookBenchmark the same job on faster hardware
- Read Mastra’s playbookStarSling runners for the slowest test workflow
- Read OpenAI’s playbookRank CI fixes by the minutes they save
- Read Ramp’s playbookMove a CPU-bound test suite to a faster CPU
- Read Shopify’s playbookLet an agent iterate against one CI metric
- Read Spotify’s playbookBuild arm64 on native arm64 runners
- Read Stripe’s playbookRun only the tests a change can reach
- Read Uber’s playbookBuild the merge-queue speculations most likely to be needed