Skip to content

CI planner: derive shard counts and timeouts from measured durations and the 20-job pool (generalizes #5882) #5919

Closed

Description

@squid-protocol

Same pattern as #5882, generalized, and the CI half of squid-protocol/promoter-bot#34.

Problem

Every sharded workflow fixes its own shard count and timeout-minutes by hand. They are re-measured after something times out or crawls:

Only Ground Truth (ci_layout.py, #5616) and the det planner's narrow path size themselves. The pool is fixed (20 concurrent GitHub-hosted jobs) while cases and suites grow every day: Db2 cases went 45 -> 70 in 4 days.

Proposal: one planner, measured inputs

A small shared module (next to tests/tools/det_sweep_plan.py / ci_layout.py) that each sharded workflow's plan job calls:

Order

  1. Db2 in Det Sweep and Evidence Refresh. This is Det Sweep: db2 shards don't scale with the Db2 case count (fixed 4 shards, 6-min Db2 start per shard, 31 cases unbalanced) #5882's asks 1, 2 and 4 via the planner.
  2. CICS Crucible and Doom Rosetta.
  3. Smoke parts (CI critical path: rebalance full-suite part 3 (move evidence --deltas, refresh durations); measure ground-truth split #5133) and Full Suite Gate legs (Siblings of #5152: CI legs outgrowing their fixed timeout caps #5156).

Acceptance

  • No sharded PR workflow has a hand-set shard count or timeout-minutes for its shard jobs.
  • A 7-day window with case growth shows no shard timeouts and a slowest/fastest shard ratio ≤ 1.3.
  • Adding cases needs no YAML edit.

Related: #5882, #5869, #5156, #5133, #5135, #5616, #5262.

🤖 Generated with Claude Code

Plan (Opus rescue of PR #6081)

Already merged: #6037, #6059 (Db2 counts, timeouts and measured setup in Det Sweep and Evidence Refresh), #6050, #6068 (CICS Crucible and DOOM-rosetta). Closed: #6081. Its approach was to have det_sweep_plan.py read the live queue itself, and that was wrong.

Steps, in order. Each step is one Sonnet-sized PR of at most 5 hand-written files.

  1. Det Sweep queue depth comes from the workflow, not the planner. This is a workflow edit, so it needs an allow_workflows item or the owner.
    • Add actions: read to the plan job in .github/workflows/det-sweep.yml.
    • On a pull request, both plan steps ("Plan the sweep" and "Plan from the port diff") get the waiting count from python3 tests/tools/ci_layout.py with GH_TOKEN set. Add a small --print-waiting flag there if needed. Pass the count to det_sweep_plan.py with the existing --waiting. An empty value means calm.
    • Do not change det_sweep_plan.py's imports.
    • Acceptance: a test pins the step wiring; test_ground_truth_plan.py and test_det_sweep_fast.py stay green; the plan summary of a real PR run shows waiting.
  2. Det Sweep non-Db2 shard count from durations. Replace the fixed MAX_SHARDS = 6 / PER_SHARD = 3 in det_sweep_plan.py with ci_shard_plan sizing, which det_sweep_plan.py already imports.
    • Acceptance: unit tests at 45, 70 and 140 cases keep the slowest/fastest ratio at or below 1.3 and stay within the pool cap.
  3. Smoke parts (CI critical path: rebalance full-suite part 3 (move evidence --deltas, refresh durations); measure ground-truth split #5133). smoke-test.yml hard-codes --splits 3 and the part job's timeout-minutes: 30. Plan both from .test_durations with a planner module next to ci_shard_plan.py. This is a workflow edit, so it needs allow_workflows.
    • Acceptance: no literal split count or part timeout is left in smoke-test.yml, and a test asserts that.
  4. Full Suite Gate legs (Siblings of #5152: CI legs outgrowing their fixed timeout caps #5156). Replace the per-leg splits / timeout / step_timeout JSON in full-suite-gate.yml with a plan-job output. Per-OS slowdown factors come from the measured leg times. This is a workflow edit, so it needs allow_workflows.
    • Acceptance: no hand-set leg JSON is left.
  5. Calibration check (no code). Once steps 1–4 have run for 7 days, read the shard timings and confirm there are no shard timeouts and the slowest/fastest ratio is at or below 1.3. Post the numbers here. Then close the issue.

Pitfalls the failed attempts hit

  • test_ground_truth_plan.py follows tool module names as plain words through any file the ground-truth tests reach, and test_det_sweep_fast.py reaches det_sweep_plan.py. Naming or importing ci_layout, post_merge_dispatch and the like in det_sweep_plan.py, even in a comment, fails test_no_skippable_tool_is_reached_by_the_jobs_tests. Keep queue and API reads in the workflow.
  • det_sweep_plan.py --event defaults to pull_request. Any live read keyed on that event fires inside unit tests.
  • Evidence Refresh's lane uses a sparse checkout. Anything det_sweep_plan.py imports there must be in that checkout, or be imported lazily with a fallback.
  • Workflow edits need an allow_workflows item or the owner. Two runs here shipped Python changes that do nothing until a later workflow edit. Put the wiring and its test in the same PR.

What to reuse from the closed branch (churn/5919-20261022T2258Z): the test shape in test_ci_shard_plan.py (--waiting wins, an unreadable queue plans calm), moved to test the workflow step instead.

Activity

  1. added
    enhancement
    scope:core
    on Oct 21, 2026
  2. squid-protocol commented on Oct 22, 2026

    @squid-protocol
    OwnerAuthor

    Churn run 5919-20261022T2325Z (host melek) ended without a PR. RESTART verified: PR closed, plan in #5919; queued shard-sizing slice (non-workflow)

  3. 6 remaining items

  4. added
    ci-cd
    scope:infra
    on Oct 28, 2026
  5. added and removed
    scope:core
    on Oct 28, 2026
  6. squid-protocol commented on Nov 17, 2026

    @squid-protocol
    OwnerAuthor

    Step 5 calibration: 2026-11-06 .. 2026-11-16 (measured from CI)

    Verdict: FAIL on the slowest/fastest ratio; leave open. No shard timed out.

    Method: GitHub Actions job started_at/completed_at for the latest runs (up to 40 per workflow, created on or after 2026-11-06). Per run, the ratio is the slowest over the fastest successful sibling shard job (jobs under 60 s dropped). This is job wall time (setup + queue-free run), not the sweep-only time that det_sweep_timing.py reports, so it is a looser measure than the Db2 acceptance in #5882. Timeouts counted as jobs with conclusion timed_out.

    Workflow / shard group runs compared timed_out jobs median ratio max ratio runs > 1.3
    Smoke, full-suite part N 9 0 1.46 1.66 7
    Det Sweep, shard N (non-Db2) 4 0 2.19 2.47 4
    Det Sweep, db2 N 3 0 1.25 1.34 1
    CICS Crucible, measure (shard N) 30 0 1.35 1.63 21
    DOOM-rosetta, shard N 20 0 1.37 1.61 17
    Equivalence E2E, shard N 7 0 1.23 1.34 1
    Full Suite Gate, ubuntu legs 37 0 1.45 2.33 26
    Full Suite Gate, windows legs 39 0 1.72 2.33 33
    Full Suite Gate, macos legs 40 0 1.97 5.00 38
    Evidence Refresh, records N 20 0 1.85 2.25 20
    Evidence Refresh, sweep N 20 0 1.82 2.47 18
    Evidence Refresh, db2 N 20 0 1.34 1.52 14

    Read:

    • Acceptance part 1 (no shard timeouts): met, 0 timed_out jobs across 7 workflows (about 190 runs read).
    • Acceptance part 2 (ratio <= 1.3): not met by this measure. Only Equivalence E2E and the Det Sweep Db2 shards sit near 1.3 (their median is under it).
    • Caveats: job wall time includes fixed setup (Db2 start, venv, cache hits vs misses) and runner speed variance, which a case-balanced plan cannot remove. Det Sweep non-Db2 has only 4 comparable runs (most PRs plan one shard or none), and macOS legs include runner-speed outliers (max 5.0). So the true sweep-only ratio is probably better than this table, but I did not measure it, and per the CLAUDE.md rule I'm not reading a raw number as proof either way.

    Remaining slices (each <= 5 hand-written files)

    1. Measure the real number: have the det / crucible / smoke report jobs write per-shard test-phase seconds (setup split out) into the step summary, using the det_sweep_timing.py report shape; then re-read a week. Files: tests/tools/det_sweep_timing.py (or a sibling), tests/tools/ci_digest.py, one test, one workflow edit (needs the owner's allow_workflows).
    2. Smoke full-suite parts and Full Suite Gate legs: size by least_duration over .test_durations with a per-part fixed-cost term in suite_shard_plan.py; add a test at the current duration file asserting the planned ratio <= 1.3. Files: tests/tools/suite_shard_plan.py, its test.
    3. CICS Crucible / DOOM-rosetta shard balance: crucible_shard_plan.py plus its test, using LOC/case weights from the measured durations.
    4. Re-run this calibration after 1-3 for 7 days, then close.

    Script used (scratch, not committed): job durations via actions/workflows/<id>/runs and runs/<id>/jobs.

  7. squid-protocol commented on Nov 17, 2026

    @squid-protocol
    OwnerAuthor

    Churn run 5919-20261117T0419Z (host nyx) ended without a PR. calibration no-code: ratio fails 1.3, no timeouts; slices posted on issue; slice 2 queued

  8. squid-protocol commented on Nov 17, 2026

    @squid-protocol
    OwnerAuthor

    Claimed by promoter-bot host nyx, lease renewed 2026-11-17T04:41Z. It lapses after 6 h without a renewal. To take it back, assign someone or remove the claim:nyx label.

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-cdclaim:nyxenhancementpriority: mediumscope:infra

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions