git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Ronan Pigott <ronan@rjp.ie>
Cc: git@vger.kernel.org
Subject: Re: Fetching too many tags?
Date: Fri, 11 Aug 2023 19:58:20 -0400	[thread overview]
Message-ID: <20230811235820.GA3311880@coredump.intra.peff.net> (raw)
In-Reply-To: <5a0544e570fb962c95840d99994bf45aa638faa8@rjp.ie>

On Fri, Aug 11, 2023 at 10:06:43PM +0000, Ronan Pigott wrote:

> > When you use "--no-tags", that explicitly says "do not bother with tags
> > at all". Recent versions of Git have a protocol extension where the
> > client can say "I am only interested in refs/heads/master; don't bother
> > telling me about other stuff". Since the client knows we do not care
> > about tags, it can use that extension to get a much smaller ref
> > advertisement from the server.
> 
> Do you mean the --negotiation-tip fetch option? In my experience, it doesn't
> appear to have much of an effect in this case.

No, the "negotiation" phase only happens when there are objects to
fetch, and the client and server have to agree on which ones. That's not
happening at all in your case (so --negotiation-tip won't have any
effect).

The feature I was thinking of is that in Git's "v2" protocol, the client
gets to speak first, and so it can say "btw, I am only interested in
these refs". v2 became the default in git v2.29 (of course both client
and server have to support it, but kernel.org is definitely up to date
there).

You can see it in action with something like this:

  GIT_TRACE_PACKET=1 git fetch --no-tags origin master

The "ref-prefix" lines are the client telling the server which prefixes
it's interested in (we have to ask for several variants because "master"
from the command line gets fully qualified based on what the other side
offers). Try it without --no-tags and you'll see a wider ref-prefix
request. If you try:

  GIT_TRACE_PACKET=1 git -c protocol.version=0 fetch --no-tags origin master

you'll see the full advertisement, even with --no-tags. In v0, the
server speaks first and just dumps its complete list of refs.

> > By default, Git will report, to the server, commits reachable from all local
> > refs to find common commits in an attempt to reduce the size of the
> > to-be-received packfile. If specified, Git will only report commits reachable
> > from the given tips. This is useful to speed up fetches when the user knows
> > which local ref is likely to have commits in common with the upstream ref being
> > fetched.
> 
> Now, if I understand correctly, the report does not include the tags that we
> already have? 

So there's no negotiation here at all, as I explained above. But when it
does happen, Git should use all refs, including tags and branches, to
try to reach a common point in the history graph. If you run with
GIT_TRACE_PACKET on a request that actually fetches objects, you'll see
"have" and "want" lines from the client.

For a vanilla fetch from a server you regularly fetch from, the
negotiation is pretty boring and fast (the client tells the server about
the old commit at the tip of the branch, and the server immediately says
"OK, I know about that").

A more interesting one is if you fetch the kernel from Linus's repo, and
then fetch from the stable kernel repo after that. Or maybe vice versa.
There you have two histories that share significant chunks, but also
have each diverged. So you should see the client and server dumping
sha1's at each other until they reach a common point. That's a case
where --negotiation-tip can sometimes speed things up.

-Peff

  reply	other threads:[~2023-08-11 23:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-10  6:08 Fetching too many tags? Ronan Pigott
2023-08-11 18:09 ` Jeff King
2023-08-11 22:06 ` Ronan Pigott
2023-08-11 23:58   ` Jeff King [this message]
2023-08-12  1:04   ` Ronan Pigott

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230811235820.GA3311880@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=ronan@rjp.ie \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).