Repository navigation
Description
Problem
The CI shard planner (packages/vitest-config/src/shards.ts, driven by ci-shards.ts + the plan job in .github/workflows/ci.yml) LPT-packs packages into shards by summed wall-clock suite duration. But shards execute with TURBO_CONCURRENCY=100% on 4-vCPU runners, so a shard's real wall time is roughly max(longest single suite, Σ cpu-seconds / cores) — not the sum. When the planner packs many browser-test packages into one bin (each Chromium suite eats ~2+ cores), the bin looks fine by summed time yet oversubscribes CPU and individual tests cross vitest's 120s testTimeout while the shard "budget" (150s target) is untouched.
Observed instance: PR #335 run 31257561058, build + test (shard-2) co-scheduled 11 heavy packages (@conciv/bundle-size @conciv/extension @conciv/extension-compiler @conciv/extension-tanstack @conciv/extension-whiteboard @conciv/grab @conciv/mascot @conciv/plugin @conciv/solid @conciv/solid-diffs @conciv/ui-kit-tap) → extension-tanstack/test/router-adapter.it.test.ts timed out at 120s. Same file, same day, lighter shard: 7.3s. Locally: 10/10 green, 55ms–2.3s. Pure shard-density starvation. Same mechanism family as #322 (loaded-runner flake).
Why the current self-adjustment doesn't converge
- Learns from green runs only. The baseline fetch pins to the latest
status=successmain-push run. The runs that PROVE contention fail, so their evidence never entersci-test-timings. The blind spot is structural. - Additive model vs parallel execution. Load = Σ durations, execution = concurrent. The model can't predict oversubscription, so it can't avoid it.
- Contention-contaminated measurements. A package's measured duration depends on its bin neighbors. Measured light → packed dense → starves → fails → measurement discarded (see 1). The loop never sees the bad case.
DEFAULT_PACKAGE_MS = 5_000underweights new heavy packages until their first green.
Design (keep 100% intra-shard concurrency — no capping; speed is the point)
- Pack on CPU demand with the real makespan formula. Each package gets a weight in cpu-seconds; bin load =
max(longest member wall, Σ cpu-seconds / cores). LPT stays; only the load function changes. Dense browser bins become impossible by prediction: their cpu-sum blows the predicted makespan and the planner splits them. - Measure cpu-seconds. Preferred: real per-task CPU accounting in the shard run wrapper. Acceptable v1:
cpuWeight = wall × parallelismFactor, with a measured multiplier forbrowser: truepackages and 1 for node suites — one constant, replace with real accounting later. - Close the feedback blind spot. Publish timings from red runs too. A test/package timeout is a censored observation — record it as
≥ observed(inflate the weight), never discard. Aggregate a rolling p95 over the last N main runs instead of last-green-only, so one lucky fast run can't thin an estimate. - Self-verifying planner. Every run,
summarizecompares predicted shard makespan vs actual and writes the prediction error to the step summary. Error drift past a threshold = loud signal the model needs recalibration — no more silent degradation until a 120s timeout in an unrelated PR.
Scope
packages/vitest-config/src/shards.ts(load function, weights, sizing)packages/vitest-config/src/ci-shards.ts+summary.ts(timings publish from red runs, p95 aggregation, prediction-error report).github/workflows/ci.ymlplan/summarize steps (artifact contents; keep the fork-poisoning-safe main-pinned fetch exactly as is)
Non-goals
- No intra-shard concurrency caps, no
VITEST_MAX_FORKSin CI shards — rejected: wastes cores. - Not a fix for local-machine saturation flakes (Flaky under load: agent-page-tool.it.test.ts hits 30s timeout when the machine is saturated #311) — that's a different scheduler (the workstation).
Related: #322 (symptom instance), #335 (motivating occurrence), #314 rollout (where it bit).
Activity