Repository navigation
perf(ci): make the test-lane planner fast on a very large diff - #10786
Conversation
On a 1041-file change (#10719) plan-test-lanes.sh --base took 5m25s and both select-tests jobs hit their 3-minute timeout. The planner ran the selector twice over almost the same files (once for the change, once for its Windows subset), and each selector run spent about 170 s on a fixed cost per walk level: a `git grep --untracked` of the whole tree, a token filter that reloaded the tree index and every Python import line, and a fork per frontier path. - plan-test-lanes.sh selects the Windows files and the inert files once each and unions them, since the selector walks each file on its own. - affected-tests.sh drops --untracked when no untracked code file exists, hands the token filter only the index files a level reads, reads co-located suites through a file instead of a fork, and after 16 tree greps reads every code line naming a file once and greps those lines for later levels. The plan is byte-identical: #10719 and seven merged main commits, and a 30-commit --replay --against the old selector shows no difference. #10719 now plans in 37 s, on 4 cores too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
claude-security-review reviewed No security issues found in this pull request. critical-findings: 0 Scope read: all four changed files in What the change does: it speeds up the test-lane planner on very large diffs.
Checks made:
The PR description reports byte-identical output against the old scripts and zero differing suites on a 30-commit replay. I did not re-run any of that. Spend: the change reduces CI wall time and adds no paid resource, so there is no cost hold. |
|
claude-review reviewed No findings. I read all four changed files in the diff, plus the surrounding code in What I checked by reading the code:
Author-claimed and unverified by me: the timings in the table, the byte-identical output comparisons, the |
Post-merge mutation testingKilled 0, survived 0, timeout 0, no coverage 0, invalid 0, not run 7.
The run's summary has the full report. |
No related issue: a CI defect found while driving #10719; fixed in place (no new issues, per the owner's standing direction)
Summary
select-tests(pr-require-checks.yml,timeout-minutes: 3) andselect-tests-windows(pr-test-windows.yml,timeout-minutes: 3) were cancelled at their timeout on #10719, whose diff changes 1041 files (runs 40775980620 and 40775980621). Locally,scripts/plan-test-lanes.sh --base origin/maintook 5m25s on that diff, so any very large change failsci-statuson every run. A normal PR'sselect-teststakes about 30 s.Fix
Profiled with timestamped xtrace:
plan-test-lanes.shran the selector twice, once for the whole change and again for its Windows subset: 162 s each, almost all of the time. It now selects the Windows files and the inert files once each and unions the results, which is exact because the selector walks each file independently.unmappedis the sum of both runs.affected-tests.shpaid a fixed cost per walk level about 1100 times:--untrackedfrom the treegit grepwhen no untracked code file exists (always the case on a CI checkout): about 94 ms against 37 ms a call.token_hitsno longer reloads index files a level does not read.AFFECTED_TESTS_TREE_GREPSoverrides), it reads every code line that names a file once and greps those lines on later levels, falling back togit grepwhen a level's names are not covered.The plan output is unchanged. A whole-tree short-circuit was rejected because it changes
windows_stepson #10719 (38 steps against 27).Verification
taskset -c 0-3)--base <parent>.affected-tests.sh --replay dce531e~30..dce531e --against dce531e: 30 commits, zero suites differ.scripts/affected-tests.test.sh: PASS=139 FAIL=0, with a new case that counts tree greps through a git shim and requires identical output.scripts/plan-test-lanes.test.sh: PASS=52 FAIL=0, with a new case for unmapped files on both sides of the inert split. Each new case fails against a deliberate mutation of the code it covers.Related
select-testscannot finish inside 3 minutes without it.🤖 Generated with Claude Code