scalar: add --[no-]prefetch - #979
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>
When a user uses the --no-prefetch option, they do not get batched commit and tree packfiles before attempting a checkout. Thankfully, the GVFS Protocol has a mechanism to help here: the /gvfs/objects POST endpoint can ask for a commit and that will trigger a download of all trees needed for a checkout of that commit. When using --no-prefetch and the GVFS protocol, run this extra POST request before running a checkout. Signed-off-by: Derrick Stolee <stolee@gmail.com>
Matthew John Cheetham (mjcheetham)
left a comment
There was a problem hiding this comment.
This seems like a reasonable addition! Looks good to me.
|
GVFS has had --no-prefetch for a long time, and I recently changed the background maintenance to continue honoring it - ie if a commit-graph prefetch has not been done before, don't do one in the background. A manual The reasoning was that our primary case for using --no-prefetch is in pipelines that won't ever need the history - they'll throw the enlistment away or even recycle the VM, so doing the prefetch in the background at a later point just slows down the pipeline work they're trying to do for no gain. I also have work pending to make the initial prefetch be asynchronous to clone completion for gvfs, even if --no-prefetch is not used (in tandem with the trust boundary realignment to index all received pack files instead of trusting the indexes from the cache server, since that adds 15+ minutes to first prefetch). Just food for thought, I don't know if similar reasoning would apply to your use-cases for scalar clones. |
If someone wants a similar setup, then they can do |
1eac8a6
into
microsoft:vfs-2.55.0
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.