Skip to content

Try cached trees before downloading the clone commit pack - #2180

Merged
Tyrie Vella (tyrielv) merged 3 commits into
masterfrom
tyrielv/clone-cache-prototype
Nov 13, 2026
Merged

Tyrie Vella (tyrielv) merged 3 commits into
masterfrom
tyrielv/clone-cache-prototype

Conversation

@tyrielv

@tyrielv Tyrie Vella (tyrielv) commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Problem and Context

Clone downloads a commit pack when a loose copy of the target commit exists.
This also happens when packed copies and all required trees already exist in the shared cache.
Repeated clones can therefore download the same commit pack again.

A recursive tree check adds another traversal before checkout.
Checkout already needs those trees, so it can also detect an incomplete cache.

Changes

  • Add gvfs.optimistic-clone-checkout, with a default of false.
  • Read the flag through the shared Boolean config entry point.
    The reader uses libgit2 normally and Git when process config overrides require it.
    If the config read fails, log a warning and use false.
  • When the flag is enabled and the commit and root tree are local, try checkout without the initial commit pack download.
  • Send Clone_UseCachedCommit to telemetry when clone reuses a cached commit.
  • Recognize tree-read checkout errors, log the recovery, force one commit pack download, and retry checkout once.
  • If root .gitattributes discovery fails after cache reuse, force a commit pack download and retry discovery once.
    Root discovery and checkout share a limit of one recovery download.
  • Propagate failed downloads and remaining checkout failures. Unrelated errors do not trigger recovery on the enabled path.
  • Keep the existing clone path when the flag is disabled. Preserve root .gitattributes acquisition and background history prefetch.
  • Add unit tests for successful checkout, tree-read errors, unrelated errors, failed downloads, and the single-retry limit.
    The tests also assert final checkout failures with empty or filtered diagnostics.
    The tests assert root-discovery errors and the shared recovery-download limit.
  • Add functional tests that serve Git metadata locally, assert commit pack request bodies, and verify the target index.
    The tests exercise loose and packed caches, missing commits, missing root and nested trees, disabled mode, and failed recovery.
    The tests also assert conflicting global-file and process config overrides in both directions.
    The tests assert recovery from empty, zeroed, and truncated root trees, preserve disabled-mode behavior, and reject incomplete recovery packs.

Known gaps and deliberate decisions

  • Recovery recognizes English Git tree-read errors. The shared Git launcher sets LC_ALL=C so these diagnostics remain stable.
  • Cache-reuse events reach telemetry, but recovery warnings remain in local clone logs. No follow-up planned.
  • The flag also enables stricter checkout failure handling after an ordinary cache-miss download.

@KeithIsSleeping

Copy link
Copy Markdown

[KeithBot]: ⚠️ 1 issue · iteration 1 (11b1171)

  1. 🟡 Medium Optimistic clone fails on a corrupt cached root tree before any recovery

Approach: Right layer: widens clone's existing download-and-retry checkout recovery behind a default-off flag instead of adding a tree pre-check that checkout would repeat.

Validation

  • ❌ E2E clone, corrupt cached root tree
  • ✅ GVFS.UnitTests at source and merge base
  • ✅ CloneCachedTreesTests 14/14, CI 34 jobs
  • ✅ E2E gvfs clone, 15 cache/config states
  • ✅ NativeAOT publish of GVFS.csproj
  • ⏭️ Mounted functional tests, arm64 — not run

🤖 KeithBot · claude-opus-5.5, gpt-6.1-sol, gemini-4-argon + approach review · reply on a thread to dispute

Base automatically changed from tyrielv/libgit2-config-env-fallback to master November 13, 2026 17:56
Add a default-off optimistic clone checkout flag. When the commit and root
tree are local, try checkout without a commit pack download.

Download the commit pack and retry checkout once for tree-read errors.
Preserve the disabled path and return remaining checkout failures.

Reuse the shared Boolean config entry point. Keep normal reads in process
with libgit2 and use Git when process config overrides require it.

Add unit tests for retry limits and checkout diagnostics.
Add functional tests for loose and packed caches, missing objects, failed
recovery, and conflicting process config. The tests assert the requested
commit, the recovery diagnostic, and the final index tree.

Assisted-by: GPT-6.1 Sol
Signed-off-by: Tyrie Vella <[email protected]>
Mark Clone_UseCachedCommit with Keywords.Telemetry.
Keep the event metadata unchanged.

Assisted-by: GPT-6.1 Sol
Signed-off-by: Tyrie Vella <[email protected]>
Record whether clone skips the initial commit pack download.
If root attributes fail after that skip, download the commit pack and retry.
Share one recovery download between root attributes and checkout.
Preserve the disabled path and return download or repeated-read errors.

Add unit tests for root recovery, error propagation, and the shared limit.
Add functional tests for empty, zeroed, and truncated cached root trees.
The tests also assert failed downloads and incomplete recovery packs.

Assisted-by: GPT-6.1 Sol
Signed-off-by: Tyrie Vella <[email protected]>
@tyrielv
Tyrie Vella (tyrielv) force-pushed the tyrielv/clone-cache-prototype branch from 11b1171 to 7a699f9 Compare November 13, 2026 18:08
@KeithIsSleeping

Copy link
Copy Markdown

[KeithBot]: ✅ Resolved · iteration 2 (7a699f9)

  • Optimistic clone fails on a corrupt cached root tree before any recovery: fixed
  • New changes since iteration 1: no new issues

Validation

  • ✅ E2E clone, corrupt cached root tree
  • ✅ E2E clone, reuse, nested and flag off
  • ✅ Shared one-download recovery limit
  • ✅ CloneCheckoutTests and mutants
  • ✅ GVFS.UnitTests at source and merge base
  • ✅ CloneCachedTreesTests 23/23, no mount
  • ✅ CI run 43479770610, 34 jobs
  • ✅ NativeAOT ILC of GVFS.csproj (r3)

Approving.

🤖 KeithBot · claude-opus-5.5, gpt-6.1-sol, gemini-4-argon · reply on a thread to dispute

@tyrielv
Tyrie Vella (tyrielv) merged commit e8af937 into master Nov 13, 2026
71 of 73 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants