Repository navigation
perf(source-control): index main's first-parent chain and batch pin reads in the post-merge check - #10406
Conversation
…eads in the post-merge check `_Context.contains` answers two commits on the local clone's first-parent chain of the branch from one `git rev-list --first-parent`, and spawns `git merge-base --is-ancestor` only for a commit off that chain. The pin read-back for every judged merge goes 20 pull requests to a GraphQL query (`read_pins`), paging a thread over 100 comments on its own. Verdicts are unchanged. Measured on a local run of `--lane-merges-only` over 154 merges: the merge-base spawns went from 38,634 calls taking 193.6 s to none, and the pin reads from 150 queries taking 71.4 s to 8 taking 7.7 s. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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-review reviewed No findings. I read the full diff, the surrounding Ancestry index (
Batched pin reads (
Tests. The new tests cover the risky edges:
Manifests and cost. The change touches no plugin manifest and uses a changelog fragment with
|
|
claude-security-review reviewed No security findings in #10406. critical-findings: 0 Scope. The change is in What the trusted path gates. Ancestry index (
Batched pin reads (
Spend. No billable change. The change reduces API and CPU use per tick. |
No related issue: efficiency plan item 1 alternative (GitHub Support hub), per-tick post-merge check cost
Summary
babysit_postmerge.py check()runs as pr-merge's "Check earlier lane merges" step on every 15-minute post-merge-dispatch tick. In dispatch job 121959899053 that step took 543 s (01:46:45 to 01:55:47) over 154 merges and made 248 gh calls, 199 of them GraphQL. It made nocompareREST calls, so everycontainsmiss went to a localgit merge-base --is-ancestorspawn.A local run of the same check (
--lane-merges-only, 154 merges, instrumented by a throwaway wrapper that is not committed) put the time here:_local_containscalls (each agit merge-basespawn before)Both runs gave the same verdict: readable, ok, 154 of 154 verified. The local run took 484-485 artifact-listing reads (about 166 s) because it had no lane records file. CI passes that file, so CI made 2 such reads. That cost exists only locally and this change leaves it alone.
Fix
_Context._chain_containsreadsgit rev-list --first-parentof the first full-history clone's copy of the branch (refs/remotes/origin/<branch>, elserefs/heads/<branch>, the same lookup_tip_bridgeuses, now shared as_local_branch). It reads it once per check, throughpolicy._git, so replace refs and graft files are ignored. If both commits are on that chain, the older one is the other's ancestor and the newer one is not. If either commit is off the chain (reachable only through a merge's second parent, or absent), the method returns None and today'smerge-basepath, bridge and compare fallback answer it. It never returns False for such a commit. With no branch, no clone, a shallow clone or an unreadable list, there is no index.read_pinsreads the first comment page of up to 20 pull requests in one aliased GraphQL query (PostMergeHeadPins), in the alias shapebabysit_merge_skip.pyuses. A thread with more pages continues one pull request at a time on the unchangedPIN_QUERY, and the batched page counts towardPIN_PAGE_LIMIT.read_pinis split into_pin_thread(page walk) and_pin_sha(evaluation), which both paths share, so an edited newest pin is still no pin. Anyerrors, or a pull request the response leaves out, raisesPostMergeReadError, so the verdict is unreadable as before.pin_readernow returns aPinReader.check()calls itsprefetchwith exactly the merges whose pin it reads, fresh on every check.read_pin(alone=True)in the merge policy is unchanged.Verification
pytestoverplugins/source-control/skills/babysit-prs/scripts/tests: 3151 passed.FirstParentChaintests, on a fixture with--no-ffmerges, second-parent-only commits and an unmerged commit. For every pair, the result equals git's ownmerge-base --is-ancestor. Pairs on the chain spawn nomerge-base, and off-chain pairs do. The chain is read once. A graft file does not shape the chain. With no branch, no chain is read. Flipping the comparison to<=turns these tests red.test_babysit_postmerge_pins.pytests:read_pinfor each pull request.errorsraises.prefetchreads afresh.PostMergeHeadPinsquery, and a merge missing from the batch makes the verdict unreadable.scripts/check-affected.sh --uncommitted: 12 passed, 5 skipped.check-fixture-git-isolation.shandcheck-cant-fail-scan.shpass. Ruff runs throughscripts/run-ruff.sh.Related
publish-promotion-evidence.mjsmirrorsPIN_QUERY, which is unchanged.🤖 Generated with Claude Code