Skip to content

CI duration log: budget, measurement, and repacking backlog #336

Backlog

Description

@KyleAMathews

This issue is the running log for CI duration work. An agent that is asked to "rebalance CI", "repack the shards" or "speed up CI" starts here. Read the budget, measure the current state with the commands below, fix the worst job, and append a dated log entry as a comment. Keep the issue open.

Budget

From maintainer decision M 2026-11-17, "Pack CI jobs to about 9 min" (P12: never over 10), and R43 / M-4:

  • Every job in the PR workflow (.github/workflows/pr.yml) finishes in about 9 minutes, and never in more than 10.
  • The whole workflow should finish in 15 minutes, ideally 10 (R43, M-4).
  • A job's time is measured from startedAt to completedAt. Queue time comes from runner concurrency, and repacking cannot fix it. Still, watch it: more jobs can make the queue longer.

Layout

  • The slow suites are split into partitions by packages/oracles/scripts/pr-shards.mjs. Each pr.yml matrix job runs node scripts/pr-shards.mjs pattern <partition> "$SHARD" to get its -t pattern.
  • The end-to-end gap oracle has four partitions: fixed seed, random seed, determinism and Windows fixed seed. Their shards are generated into scripts/ci-packed-shards.mjs by scripts/pack-shards-from-ci.mjs, from the CI test times in scripts/ci-durations.json. Do not edit the generated file by hand.
  • scripts/e2e-shards.mjs lists the end-to-end tests. Its check keeps that list equal to vitest list.
  • node scripts/pr-shards.mjs check fails in three cases:
    • a test is in no shard, or in two;
    • a pr.yml matrix leaves out a shard of its partition;
    • a job name's /<n> does not match the length of its matrix.
  • The other partitions (framework self-oracle, the static gap oracle and its Windows twin) still use hand-written patterns.

How to measure

Job durations for one run (replace the run id):

gh run view <run-id> --repo TanStack/oracles --json createdAt,jobs --jq '.createdAt as $c | .jobs[] | select(.completedAt!=null and .conclusion!="skipped") | "\(.name)\tqueued \((((.startedAt|fromdate)-($c|fromdate))/60)|floor)m\trun \((((.completedAt|fromdate)-(.startedAt|fromdate))/60)|floor)m"' | sort -t$'\t' -k3 -rn | head -20

Recent runs (pr.yml runs on pull requests and on pushes to main):

gh run list --repo TanStack/oracles --workflow pr.yml --branch main --limit 10 --json databaseId,headSha,createdAt,conclusion

Per-test times for the end-to-end partitions, and a repack. Run these from packages/oracles. The jobs run Vitest with --reporter=verbose, so their logs give each test's time:

node scripts/pack-shards-from-ci.mjs fetch <runId> <runId> ...   # rewrites scripts/ci-durations.json
node scripts/pack-shards-from-ci.mjs pack                         # rewrites scripts/ci-packed-shards.mjs

pack prints the following for each partition:

  • the shard count;
  • the setup charge;
  • the calibration factor and the job that set it;
  • each job's predicted time;
  • each test that is past the target by itself;
  • each test that CI has not measured yet.

Then do these steps:

  1. Change each partition's pr.yml matrix and job name to the printed count.
  2. Raise the floor in pack-shards-from-ci.mjs's partitions to the same count.
  3. Run prettier on the changed files.
  4. Run node scripts/pr-shards.mjs check and node scripts/e2e-shards.mjs check.

How the prediction works (#323):

  • Each test is charged its longest measured time, a passing time if any run passed it.
  • Each job is charged its longest measured setup.
  • The tests' time is multiplied by the partition's calibration factor, which is the worst error of the same rule on a held-out run. Each run is predicted from the other runs, and the factor is the largest ratio of a passing job's Vitest time to its tests' charges.
  • fetch needs two runs or more. Use runs of the same code: a run from an older base, with other tests or no verbose output, gives a wrong factor.

Ways to fix a slow job, in order of preference:

  1. Repack from fresh measurements: fetch the newest main runs, then pack. A new test is charged the partition's mean until CI measures it. A new test that repeats a measured test's work can borrow that test's time through weighsAs.
  2. Cut a single test's cost (P12: "cost paid by cutting cost, sharding second"; M-28). More shards cannot shorten a test that is already past the target by itself.
  3. Add shards. The packer does this when a job of two tests or more is predicted past 9 minutes.

Do not lower or remove an oracle run budget without saying so in the PR.

Current state, 2026-12-03

On main at fee6439 (#99, run 46930652313), five end-to-end jobs ran over 10 minutes:

Job Time
random seed 4/7 15m10s
fixed seed 6/6 11m01s
Windows 11/11 10m34s
fixed seed 4/6 10m26s
fixed seed 3/6 10m17s

The old packer did not allow for variation between runs, and its data left 64 tests unmeasured, so they were charged the mean. A random-seed test's slowest run is typically twice its fastest.

#323 calibrates the prediction and repacks.

Partition Jobs before Jobs after Factor
fixed seed 6 9 ×1.05
random seed 7 13 ×1.38
determinism 14 20 ×1.22
Windows fixed seed 11 11 ×1.09

That is 53 end-to-end jobs, up from 38. A typical job runs at 0.65–0.80 of its prediction, which is about 6–7 minutes. One job sets the random-seed factor: main's 15m10s random 4/7.

On #323's runs before the merge of main, which had 51 end-to-end jobs, every end-to-end job ran under 10 minutes:

Run Slowest job Slowest job, any kind
46959838128 Windows fixed seed 3/11, 8m41s
46979272177 Windows fixed seed 3/11, 8m09s 8m09s

The budget for the whole workflow is not met. Runner queueing decides that time, not job length.

Run Jobs Median queue Created to last update
46959838128 19.6 min 67 min
46979272177 84 47 min 92 min

Other PRs were running at the same time.

Backlog

Log

Append one entry per repack as a comment. Give the date, the PR, what moved, the factors, the job counts before and after, and the measured times.

  • 2026-11-17. M decision "Pack CI jobs to about 9 min" (P12: never over 10).
  • fix(oracle-gaps): no wall-clock cut decides an outcome #99 (fee6439). End-to-end partitions at 6/7/14/11 jobs. On main's run 46930652313, five jobs ran over 10 minutes, the slowest being random seed 4/7 at 15m10s.
  • 2026-12-03, ci: pack the end-to-end jobs from a calibrated prediction, under 10 minutes #323. The packer is calibrated by its worst held-out error. When one test is past the target by itself, it gets a shard of its own; before, the pack never ended. pr-shards.mjs check now also checks the pr.yml matrices. The counts are 9/13/20/11 after the merge of main (9/12/19/11 before it). Before the merge, every end-to-end job ran under 10 minutes on two runs. The results on the merged head will be added in a comment.

Activity

  1. KyleAMathews commented on Dec 3, 2026

    @KyleAMathews
    ContributorAuthor

    Log: 2026-12-03, #323 merged (8e3b88c)

    What moved.

    • The end-to-end partitions are packed from a calibrated prediction.
    • The counts go from 6/7/14/11 to 9/13/20/11 (fixed seed, random seed, determinism, Windows fixed seed). That is 53 end-to-end jobs, up from 38.
    • Calibration factors: ×1.05, ×1.38, ×1.22 and ×1.09.
    • The merge of main (fix(oracle-gaps): a mid-run edit lands, and the driver sees that it landed (#165) #326) adds five tests that CI has not measured yet. They are charged the partition's mean, which moves random seed from 12 to 13 jobs and determinism from 19 to 20.

    Measured on the merged head (run 47127688160, a9ae67e).

    • All 85 test jobs passed.
    • All 53 end-to-end jobs ran under 10 minutes. The slowest was Windows fixed seed 2/11 at 8m58s.
    • The slowest other jobs were Framework self-oracle 7/9 at 8m35s and Windows static gap oracle 1/2 at 7m48s.
    • No job of any kind ran over 10 minutes.

    Not met. The whole workflow time (R43, M-4): the median queue was 57 minutes, with other PRs running at the same time.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions