Repository navigation
Read only base commits that can match when comparing a branch to its base - #7079
Merged
ymichael merged 3 commits intoNov 5, 2026
Merged
Conversation
…base The merge-base status read `--raw` for every commit the branch was behind on each cold read, though only base commits touching the branch's paths can be cherry-picks or squash merges of it. Filter the behind commits with a literal pathspec (one path per ahead commit, one required path for the squash check) and read changes only for the matches. Commits that match no path are cached per path so warm recomputes stay process-free. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
force-pushed
the
bb/merge-base-check-reads-every-behind-commit-thr_jdbshu29pv
branch
from
November 5, 2026 00:45
5b8f96a to
745a217
Compare
…ning Git 2.55.0, which CI's Linux and Windows runners ship, ignores the pathspec when deciding which --no-walk commits to show, so the filter matched every behind commit. Read --name-only output instead: the diff is still path-limited, so a commit touches the paths when any name follows its header. Also use a test file name that is valid on Windows. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
force-pushed
the
bb/merge-base-check-reads-every-behind-commit-thr_jdbshu29pv
branch
from
November 5, 2026 00:50
6de6afe to
96793a5
Compare
The git plugin's server tests open a better-sqlite3 database through the SDK's fake plugin host, but its test task never depended on //#ensure-native-modules. Windows CI only passed when another affected package pulled that task into the same job; with the git plugin alone, all server tests failed with "Could not locate the bindings file". Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
deleted the
bb/merge-base-check-reads-every-behind-commit-thr_jdbshu29pv
branch
November 5, 2026 18:20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
What was wrong
The merge-base status (Git panel's "ahead/behind", committed changes) decides which branch commits are already in the base: cherry-picks via
readPatchEquivalentCommitsand squash merges viacomputeSquashMerge. Both calledreadCommitChangeson every behind commit, i.e.git log --rawover up to 1,000 base commits in 256-commit batches. Only base commits that touch the branch's paths can match, because a cherry-pick needs the same changed-path set and a squash needs every branch path. The per-commit cache lives in the git host worker and is lost on its idle stop, so every cold read paid the full cost. Finding #12 of the hot-path overreach audit (thr_384rg6d3n9perf-audit.md). This still held on origin/main 7775a0f.What changed
plugins/git/host/commit-cache.tsreadCommitsTouchingPaths: a singlegit log --no-walk=unsorted --stdin --name-only --format=%x01%H -- :(literal)<path>…over the behind commits. It returns those with at least one name under their header, i.e. those touching a given path. It reads the path-limited diff output, not git's commit pruning, because git 2.55.0 (the version on CI's Linux and Windows runners) ignores the pathspec when deciding which--no-walkcommits to show. Reproduced with a source build of 2.55.0; 2.50, 2.54 and 2.56 prune correctly. Both forms cost the same, ~230 ms vs ~700 ms for the full--rawread over 1,000 behind commits. Commits already in the--rawcache are classified in memory. Commits that match nothing are cached per(commit, path), so a warm recompute (HEAD or base moved) adds no process. Pathspecs over 16 KiB fall back to the old full read (Windows command-line limit).readPatchEquivalentCommitsreads the ahead side first. It then filters the behind side by one path per ahead commit (its longest; a matching commit must touch all of its paths) and reads--rawonly for the matches.plugins/git/host/workspace-reads.tscomputeSquashMergefilters the scanned behind commits by the longest required branch path (all branch paths when none qualify) before reading changes. The two checks usually pick the same path, so the squash check hits the per-path cache instead of re-filtering.turbo.jsonbb-plugin-bb--git#testnow depends on//#ensure-native-modules, like the other plugin test tasks that use the SDK's fake plugin host (which opens better-sqlite3). This was a latent gap. Windows CI only passed while another affected package pulled the native install into the same job. With the git plugin as the only affected package, everyserver.test.tscase failed with "Could not locate the bindings file".No wire, protocol or SDK changes. No visible behaviour change. The only theoretical difference: cherry-pick pairing used whitespace-stripped path keys, so two files whose names differ only in whitespace no longer count as the same file.
How you verified
Benchmark on real data. Real
~/Projects/bbworktrees (4.4k branches, 110 worktrees, 408k loose objects, 647 packs). A freshWorkspaceReads.getStatus({ mergeBaseBranch: "origin/main" })per process (cold worker), then a second read with a differentmaxFiles(warm recompute). Main and branch interleaved, 7 rounds each. Git time comes fromGIT_TRACE2_EVENT. Load average fell from ~50 to ~8 during the run. Medians:Re-traced at load ~7, bb-pr4-git-reads went from 1977 → 1317 ms cold (commit reads ~1.2 s → ~0.65 s). The remaining cold time is
log --left-rightand the two...diffs, which are out of scope here.The filter alone, wall/CPU against the full
--rawread of the same behind commits (low-load samples):Filtering by every ahead path instead of one per commit kept 61–280 commits and was no faster end to end, so I switched to one path per commit.
Tests
workspace-status-cache.test.tscase: a cherry-picked file namedpicked dir/[1] picked.txt(space and glob characters, which checks the literal pathspec; valid on Windows) plus 20 unrelated base commits. Status is unchanged (1 ahead, 20 behind, squash check complete), and--rawreads cover 3 commits. On origin/main the same test reads 23 and fails (expected 23 to be 3).pnpm exec turbo run test --filter=bb-plugin-bb--git -- host/workspace-status-cache.test.ts host/workspace-reads.test.ts host/git.test.ts: 60 passed. Full--filter=bb-plugin-bb--gitsuite: 277 passed.pnpm exec turbo run typecheck lint --filter=bb-plugin-bb--git: passed.🤖 Generated with Claude Code