Skip redundant commit pack download during clone when prefetch packs exist#1995
Draft
tyrielv wants to merge 2 commits into
Draft
Skip redundant commit pack download during clone when prefetch packs exist#1995tyrielv wants to merge 2 commits into
tyrielv wants to merge 2 commits into
Conversation
When gvfs clone runs with a shared cache that already has prefetch packs (e.g., from a previous clone), defer the commit+trees pack download. If the commit is already present in the prefetch packs, the download is skipped entirely. If it is not, the fallback path downloads on demand when branch creation, gitattributes lookup, or checkout requires it. This avoids redundantly re-downloading trees that are already in prefetch packs when the tip commit happens to be covered by the existing cache. Assisted-by: Claude Opus 4.6 Signed-off-by: Tyrie Vella <tyrielv@gmail.com>
Two tests that manufacture specific shared-cache states to verify clone behavior when prefetch packs exist: 1. SecondCloneSucceedsWithMissingTreesAndPrefetchPacks: commit and root tree are present as loose objects, a fake prefetch pack exists, but subtrees are missing. Verifies the checkout fallback re-downloads the commit pack. 2. SecondCloneWithPrefetchPacksButMissingCommit: the target commit is completely absent but a fake prefetch pack exists. Exercises the deferred-download path (skippedCommitDownload) that falls back through CreateBranchWithUpstream/TryDownloadRootGitAttributes. Both tests create a temp bare repo to run git pack-objects without VFS hooks, producing a minimal prefetch-named pack in the shared cache's pack directory. Assisted-by: Claude Opus 4.6 Signed-off-by: Tyrie Vella <tyrielv@gmail.com>
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.
Summary
When
gvfs cloneruns with a shared cache that already has prefetch packs (e.g., from a previous clone), defer the commit+trees pack download. This avoids redundantly re-downloading trees that are already available in the cache.Changes
CloneVerb.cs— Clone optimizationCommitAndRootTreeExists), or if usable prefetch packs are present in the shared cache (HasUsablePrefetchPacks).CreateBranchWithUpstreamorTryDownloadRootGitAttributesfails because the commit is needed, download on demand and retry."unable to read tree"→ force re-download) handles missing subtrees.GitObjects.cs— Shared helpersIsUsablePrefetchPack(packPath)— checks a pack has a matching.idxand no.incompletemarker.HasUsablePrefetchPacks()— returns true if at least one usable prefetch pack exists.PrefetchStep.TryGetMaxGoodPrefetchTimestamprefactored to useIsUsablePrefetchPackinstead of inline checks.SharedCacheTests.cs— Functional testsTwo tests that manufacture specific shared-cache states via "cache surgery" (creating fake prefetch packs with
git pack-objects):SecondCloneSucceedsWithMissingTreesAndPrefetchPacks— commit+root tree present as loose objects, fake prefetch pack exists, but subtrees are missing. Verifies the checkout fallback re-downloads the commit pack.SecondCloneWithPrefetchPacksButMissingCommit— target commit is completely absent but a fake prefetch pack exists. Exercises the deferred-download path (skippedCommitDownload) that falls back throughCreateBranchWithUpstream/TryDownloadRootGitAttributes.Scenarios
CommitAndRootTreeExists→ true → skip download