scalar: add --[no-]prefetch - #979
Open
Derrick Stolee (derrickstolee) wants to merge 1 commit into
Open
Conversation
When using the GVFS protocol with 'scalar clone', the first 'git fetch' uses the prefetch endpoint to download commits and trees so history operations are usable immediately after cloning. Some users want to optimize for the initial usability of the repository, and they don't need the full history available right away. They are prepared to wait for future fetches (perhaps in the background) doing that work for them. Add a new --no-prefetch option that skips the initial prefetch. This is implemented by using '-c core.gvfs=X' arguments in the underlying fetch operation to temporarily avoid the prefetch operation for that subcommand only. It's important that this does not actually stop prefetches forever, though that can be adjusted by flipping the appropriate bit in the core.gvfs config option. Signed-off-by: Derrick Stolee <stolee@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.
When using the GVFS protocol with
scalar clone, the firstgit fetchissues a
/gvfs/prefetchrequest to download the commits and trees thatback the checked-out branch, so history operations are usable immediately
after cloning. For large repositories this prefetch can dominate the clone
time.
Some users would rather optimize for the initial usability of the working
tree and do not need full history right away; they are content to let a
later fetch (including background maintenance) download the prefetch data
for them.
This PR adds a
--[no-]prefetchoption toscalar clone. With--no-prefetch, the initial/gvfs/prefetchrequest is skipped so theworktree becomes ready as quickly as possible.
Implementation
The prefetch-during-fetch behavior is gated by the
GVFS_PREFETCH_DURING_FETCHbit (
1 << 7) incore.gvfs, whichscalar clonesets as part of thevalue
150. Rather than persisting a differentcore.gvfsvalue (whichwould disable prefetching forever),
--no-prefetchonly clears that bitfor the single
git fetchinvocation performed during the clone, bypassing
-c core.gvfs=<value without the prefetch bit>.The persisted
core.gvfsis left untouched, so:git fetch-- including the background maintenanceprefetchtask -- still performs the prefetch, hydrating the objectcache shortly afterward.
The option has no effect when the GVFS Protocol is not in use.
Documentation
Documentation/scalar.adocdocuments--[no-]prefetch, making clear thatit only affects the clone's initial fetch and that the prefetch data is
still downloaded by the next fetch.
Tests
t/t9210-scalar.shgains a test against the GVFS-enabled test server whichasserts that:
prefetch/sincetrace event,--no-prefetchclone does not,core.gvfsremains150, andgit fetchperforms the deferred prefetch.