git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Git 2.26 fetches many times more objects than it should, wasting gigabytes

From
Jeff King <peff@peff.net>
Date
Apr 22, 2020, 10:30 UTC
Message-ID
<20200422103011.GA545254@coredump.intra.peff.net>
In-Reply-To
<20200422095702.GA475060@coredump.intra.peff.net>
On Wed, Apr 22, 2020 at 05:57:02AM -0400, Jeff King wrote:
Show 9 quoted lines
> I'm attaching for-each-ref output before and after the xo fetch. That
> should be sufficient to recreate the situation synthetically even once
> these repos have moved on.
> 
> I have GIT_TRACE_PACKET output showing the whole negotiation, but it's
> pretty hard to look at. I _think_ a lot more is said in the v0
> conversation, but it's difficult to sort out because there's a lot of
> extra packet framing as we shuttle bits back and forth between
> remote-curl and fetch-pack.

Here's what I did manage to pull out if it. In both versions we send a bunch of "have" lines, and get a bunch of NAKs back. Which makes sense. We have a bunch of refs that the other side doesn't know about.

In the v0 http session, we finally get an ACK on 8f3d9f354286745c751374f5f1fcafee6b3f3136, which is Linus's 5.7-rc1. We send that commit as a "have" in the 9th batch.

In the v2 session, we never get an ACK at all (which unsurprisingly leads to the other side sending the full history). But that commit id is nowhere to be found in the trace! We appear to give up after 5 rounds.

So it really just seems like v2 does not try hard enough. I think the culprit is the MAX_IN_VAIN setting. If I do this:

diff --git a/fetch-pack.c b/fetch-pack.c
index 1734a573b0..016a413d49 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -46,7 +46,7 @@ static struct strbuf fsck_msg_types = STRBUF_INIT;
  * After sending this many "have"s if we do not get any new ACK , we
  * give up traversing our history.
  */
-#define MAX_IN_VAIN 256
+#define MAX_IN_VAIN 20000
 
 static int multi_ack, use_sideband;
 /* Allow specifying sha1 if it is a ref tip. */

then I get that same 48k objects, 23MB fetch that v0 does.

-Peff
Previous: Jeff KingNext: Jeff King
Message 3 of 18 in “Git 2.26 fetches many times more objects than it should, wasting gigabytes”
  1. Lubomir RintelApr 22, 2020
  2. Jeff KingApr 22, 2020
  3. Jeff KingApr 22, 2020
  4. Jeff KingApr 22, 2020
  5. Junio C HamanoApr 22, 2020
  6. Jeff KingApr 22, 2020
  7. Jonathan TanApr 23, 2020
  8. Junio C HamanoApr 23, 2020
  9. Jeff KingApr 24, 2020
  10. Jonathan NiederApr 22, 2020
  11. Jeff KingApr 22, 2020
  12. Revert "fetch: default to protocol version 2"Jonathan Nieder, Apr 22, 2020
  13. Junio C HamanoApr 22, 2020
  14. Jeff KingApr 22, 2020
  15. Jeff KingApr 22, 2020
  16. Jonathan NiederApr 22, 2020
  17. Junio C HamanoApr 22, 2020
  18. Jeff KingApr 22, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.