Skip to content

CI shard planner packs by summed wall time; parallel execution makes dense browser shards starve (makespan-model rework) #340

Open

Description

@omridevk

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

  1. Learns from green runs only. The baseline fetch pins to the latest status=success main-push run. The runs that PROVE contention fail, so their evidence never enters ci-test-timings. The blind spot is structural.
  2. Additive model vs parallel execution. Load = Σ durations, execution = concurrent. The model can't predict oversubscription, so it can't avoid it.
  3. 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.
  4. DEFAULT_PACKAGE_MS = 5_000 underweights new heavy packages until their first green.

Design (keep 100% intra-shard concurrency — no capping; speed is the point)

  1. 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.
  2. Measure cpu-seconds. Preferred: real per-task CPU accounting in the shard run wrapper. Acceptable v1: cpuWeight = wall × parallelismFactor, with a measured multiplier for browser: true packages and 1 for node suites — one constant, replace with real accounting later.
  3. 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.
  4. Self-verifying planner. Every run, summarize compares 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.yml plan/summarize steps (artifact contents; keep the fork-poisoning-safe main-pinned fetch exactly as is)

Non-goals

Related: #322 (symptom instance), #335 (motivating occurrence), #314 rollout (where it bit).

Activity

  1. added
    ci
    on Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ci

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions