Skip to content

scalar: add --[no-]prefetch - #979

Open
Derrick Stolee (derrickstolee) wants to merge 1 commit into
microsoft:vfs-2.55.0from
derrickstolee:no-prefetch
Open

scalar: add --[no-]prefetch#979
Derrick Stolee (derrickstolee) wants to merge 1 commit into
microsoft:vfs-2.55.0from
derrickstolee:no-prefetch

Conversation

@derrickstolee

Copy link
Copy Markdown

When using the GVFS protocol with scalar clone, the first git fetch
issues a /gvfs/prefetch request to download the commits and trees that
back 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-]prefetch option to scalar clone. With
--no-prefetch, the initial /gvfs/prefetch request is skipped so the
worktree becomes ready as quickly as possible.

Implementation

The prefetch-during-fetch behavior is gated by the GVFS_PREFETCH_DURING_FETCH
bit (1 << 7) in core.gvfs, which scalar clone sets as part of the
value 150. Rather than persisting a different core.gvfs value (which
would disable prefetching forever), --no-prefetch only clears that bit
for the single git fetch invocation performed during the clone, by
passing -c core.gvfs=<value without the prefetch bit>.

The persisted core.gvfs is left untouched, so:

  • the initial clone skips the prefetch and finishes sooner, and
  • the next git fetch -- including the background maintenance
    prefetch task -- still performs the prefetch, hydrating the object
    cache shortly afterward.

The option has no effect when the GVFS Protocol is not in use.

Documentation

Documentation/scalar.adoc documents --[no-]prefetch, making clear that
it only affects the clone's initial fetch and that the prefetch data is
still downloaded by the next fetch.

Tests

t/t9210-scalar.sh gains a test against the GVFS-enabled test server which
asserts that:

  • a normal clone emits a prefetch/since trace event,
  • a --no-prefetch clone does not,
  • the persisted core.gvfs remains 150, and
  • a subsequent git fetch performs the deferred prefetch.

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>
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.

1 participant