Skip to content

ci: Change host shard weight measurement to use representative runs - #5850

Draft
backspace wants to merge 2 commits into
mainfrom
cs-12582-weights-from-pr-run
Draft

ci: Change host shard weight measurement to use representative runs#5850
backspace wants to merge 2 commits into
mainfrom
cs-12582-weights-from-pr-run

Conversation

@backspace

Copy link
Copy Markdown
Contributor

test-module-timings.json is used to balance host tests across shards, but it’s regenerated by runs on main, which differ timing-wise from PR runs because of Percy and index caching. This changes the balancing to use non-Percy PR runs when available.

Claude explanation`test-module-timings.json` is regenerated on every push to main and consumed by pull_request runs, and those two shapes differ by about 1.5x per test: Percy is always on for a non-PR event (~1.23x) and the index cache is deliberately skipped, so every realm indexes from scratch (the remaining ~1.21x, visible as `Import cached realm index` taking 0s on all 20 main shards against 27s on a PR run).

A uniform factor would not matter, since greedy packing is scale- invariant. This one is uneven — fixture-heavy acceptance modules pay far more of it than unit tests, per-module ratios running 0.86x to 3.40x — so the packer mis-assigns rather than mis-scales. On run 32406440696 it predicted a 1s spread across 20 shards and got 239s, with the slowest shard 19% over prediction. Regenerating from that run's own report drops the predicted slowest shard from 362s to 306s.

Take the report from the run of the PR that produced the merge, and only when that run was Percy-free, index-cached and fully green. Anything else leaves the file alone: stale-but-consistent weights balance better than fresh ones measured in the wrong environment, which is also why there is no fallback to this run's own report.

Over the last 25 PR-derived merges, 3 would have qualified — Percy is the binding filter, since most merged PRs touch UI. Weights move slowly and the existing drift gate already suppresses balance-equivalent rewrites, so roughly daily updates are enough; if that proves too sparse, the same check could scan back over recent merges for the newest qualifying run instead of only considering this one.

backspace and others added 2 commits August 21, 2026 13:18
`test-module-timings.json` is regenerated on every push to main and
consumed by pull_request runs, and those two shapes differ by about 1.5x
per test: Percy is always on for a non-PR event (~1.23x) and the index
cache is deliberately skipped, so every realm indexes from scratch (the
remaining ~1.21x, visible as `Import cached realm index` taking 0s on all
20 main shards against 27s on a PR run).

A uniform factor would not matter, since greedy packing is scale-
invariant. This one is uneven — fixture-heavy acceptance modules pay far
more of it than unit tests, per-module ratios running 0.86x to 3.40x — so
the packer mis-assigns rather than mis-scales. On run 32406440696 it
predicted a 1s spread across 20 shards and got 239s, with the slowest
shard 19% over prediction. Regenerating from that run's own report drops
the predicted slowest shard from 362s to 306s.

Take the report from the run of the PR that produced the merge, and only
when that run was Percy-free, index-cached and fully green. Anything else
leaves the file alone: stale-but-consistent weights balance better than
fresh ones measured in the wrong environment, which is also why there is
no fallback to this run's own report.

Over the last 25 PR-derived merges, 3 would have qualified — Percy is the
binding filter, since most merged PRs touch UI. Weights move slowly and
the existing drift gate already suppresses balance-equivalent rewrites, so
roughly daily updates are enough; if that proves too sparse, the same
check could scan back over recent merges for the newest qualifying run
instead of only considering this one.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Drop this commit before merging.

The updater only runs on push-to-main, so a PR run would prove nothing
about the new report selection. This makes the job run on this branch too,
replays #5834's merge commit (whose PR run was Percy-free, index-cached
and green — one the new logic should accept), and stops before pushing,
printing the change it would have committed instead.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Host Test Results

    1 files      1 suites   1h 57m 44s ⏱️
4 368 tests 4 354 ✅ 14 💤 0 ❌
4 387 runs  4 373 ✅ 14 💤 0 ❌

Results for commit 1e3831a.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant