Repository navigation
gitindex: diff delta build trees with git diff-tree - #1301
Closed
keegancsmith wants to merge 3 commits into
Closed
keegancsmith wants to merge 3 commits into
keegancsmith wants to merge 3 commits into
Conversation
prepareDeltaBuild diffed trees with go-git, whose Change.Files loads every changed blob, and then looked up each changed path in every branch's tree one at a time. git diff-tree reads trees only, and one git ls-tree per branch answers all the lookups. On kubernetes this is 5.5x faster for a 200 commit delta and 1.8x faster for a 5 commit one. Submodule entries are skipped, as go-git's Change.Files already did. Since blobs are no longer read, a size-filtered clone missing a changed blob now gets the same skipped document as a normal build, instead of falling back to a normal build or silently dropping the file. ZOEKT_DISABLE_CATFILE_BATCH =true keeps the go-git diff. Amp-Thread-ID: https://ampcode.com/threads/T-5b43e219-dc7b-4c53-85b0-8889c69ac42b Co-authored-by: Amp <amp@ampcode.com>
They now also set GIT_DIR, like rev-parse, and a diff-tree listing that doesn't end in a complete path is an error rather than silently ignored, as gitserver's parser checks. Amp-Thread-ID: https://ampcode.com/threads/T-5b43e219-dc7b-4c53-85b0-8889c69ac42b Co-authored-by: Amp <amp@ampcode.com>
Member
Author
|
Closing: delta builds only run for allowlisted repos and the saving is ~300 ms per delta build, not worth a second diff implementation alongside the go-git fallback. Revisit if go-git is removed once ZOEKT_DISABLE_CATFILE_BATCH is retired. |
An error occurred while trying to automatically change base from
k/gitindex-rev-parse
to
main
November 26, 2026 18:11
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.
Stacked on #1300, which adds the
repoGitDirandgitBinaryDisabledhelpers this uses.prepareDeltaBuilddiffed the last indexed and current trees with go-git, whoseChange.Files()loads every changed blob, and then looked up each changed path in every branch's tree one at a time. This switches togit diff-tree -r -z --no-renames, which reads trees only, plus onegit ls-tree -r -zper branch to answer all of those lookups at once. The rest of the delta logic is unchanged; both implementations produce the same list of file changes, andZOEKT_DISABLE_CATFILE_BATCH=truekeeps the go-git diff. Like go-git, git never fetches from a promisor remote here (GIT_NO_LAZY_FETCH=1).Benchmark on a kubernetes clone (32k files), Go side only, 5 runs each on a 2 vCPU orb, repository already open for go-git. Both produce identical changes and blob IDs for these pairs:
HEAD~5..HEAD(27 changes)HEAD~200..HEAD(1,624 changes)Most of the small delta's time is the full
ls-tree; passing the changed paths as pathspecs could cut that later if it matters.Two edge cases now behave like a normal build instead of differently. Submodule entries are skipped, which is what
Change.Files()already did. On a size-filtered clone where a changed blob is missing, go-git either failed the diff (falling back to a normal build) or treated the file as absent from the branch, which dropped it from the index; now its path and ID are known from the tree and cat-file indexes it as a skipped too-large document, like a normal build does.TestDiffTreeschecks both implementations against the same expected changes (modify, delete, add, mode change, file replaced by a directory, a gitlink, and a path with spaces and non-ASCII). The existing delta tests pass in both modes.