Repository navigation
perf(server): a remote fetch no longer makes a branch list read twice - #1027
Merged
Merged
Conversation
Every branch listing starts a background fetch of remote branches (at most every two minutes per repository). When that fetch finished it used the same invalidation as a change made through the app, bumping the generation, so a listing that was reading when it landed threw its read away and read again: traces showed a listing paying 3.2s and then 1.1s. A finished background fetch now only bumps the epoch, so later listings read fresh, and drops the shared fresh-read entry for the current generation, so the next fresh listing (shared for a few seconds) doesn't reuse the read from before the fetch. A listing already reading keeps its answer, as if it had come a moment sooner. Changes made through the app still bump the generation and force a re-read.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
This branch was previously deployed
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.
Every branch listing (
listRefs) starts a background fetch of remote branches, at most every two minutes per repository. When that fetch finished, it used the same invalidation as a change made through the app and bumped the list's generation. So a listing that was reading when the fetch landed threw its read away and read again. Server traces showed a listing paying for both reads, 3.2s and then 1.1s.A finished background fetch now calls
markRemoteRefsFetchedByCommonDir, which:listRefsRefreshCache(fresh reads are shared for 5s), so the next fresh listing doesn't reuse the read from before the fetchChanges made through the app (a branch created, switched or deleted) still bump the generation and force a re-read.
Tests. New: "shows branches a background fetch brought in to the next fresh listing". It fails without the shared-entry drop (checked twice) and passed three times in a row with it. 75 driver tests and 260 git-related server tests pass, along with fmt, lint and typecheck.
Review. Reviewed by GPT-6.2-Astra: no defect found in the cache change. It flagged that the new test's first assertion could fail when the fetch beats the first read; that assertion is removed. It also noted the test doesn't prove the double read itself is gone. Proving that would mean holding a snapshot read open mid-flight through the driver's git calls, which isn't worth the hook.