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

Re: Re-Transmission of blobs?

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 10, 2013, 17:51 UTC
Message-ID
<xmqqsixcy395.fsf@gitster.dls.corp.google.com>
In-Reply-To
<20130910130837.GA14259@raven.wolf.lan>
Josef Wolf <jw@raven.inka.de> writes:
> as we all know, files are identified by their SHA. Thus I had the impression
> that when transfering files, git would know by the SHA whether a given file is
> already available in the destination repository and the transfer would be of
> no use.

That is unfortunately not how things work. It is not like the receiving end sends the names of all objects it has, and the sending end excludes these objects from what it is going to send.

Consider this simple history with only a handful of commits (as usual, time flows from left to right):

              E
             /   
    A---B---C---D

where D is at the tip of the sending side, E is at the tip of the receiving side. The exchange goes roughly like this:

    (receiving side): what do you have?
    (sending side): my tip is at D.
    (receiving side): D?  I've never heard of it --- please give it
                      to me.  I have E.
    (sending side): E?  I don't know about it; must be something you
                    created since you forked from me.  Tell me about
                    its ancestors.
    (receiving side): OK, I have C.
    (sending side): Oh, C I know about. You do not have to tell me
                    anything more.  A packfile to bring you up to
                    date will follow.

At this point, the sender knows that the receiver needs the commit D, and trees and blobs in D. It does also know it has the commit C and trees and blobs in C. It does the best thing it can do using these (and only these) information, namely, to send the commit D, and send trees and blobs in D that are not in the commit C.

You may happen to have something in E that match what is in D but not in C. Because the sender does not know anything about E at all in the first place, that information cannot be used to reduce the transfer.

The sender theoretically _could_ also exploit the fact that any receiver that has C must have B and A and all trees and blobs associated with these ancestor commits [*1*], but that information is not currently discovered nor used during the object transfer.

There may happen to be a tree or a blob in A that matches a tree or a blob in D. But because the common ancestor discovery exchange above stops at C, the sender does not bother enumerating all the objects that are in the ancestor commits of C when figuring out what objects to send to ensure that the receiving end has all the objects necessary to complete D. If you modified a blob at B (or C) and then resurrected the old version of the blob at D, it is likely that the blob is going to be sent again when the receiving end asks for D.

There are some work being done to optimize this further using various techniques, but they are not ready yet.

[Footnote]

*1* only down to the shallow boundary, if the receiving end is a shallow clone.

Previous: Josef WolfNext: Josef Wolf
Message 2 of 19 in “Re-Transmission of blobs?”
  1. Josef WolfSep 10, 2013
  2. Junio C HamanoSep 10, 2013
  3. Josef WolfSep 11, 2013
  4. Junio C HamanoSep 11, 2013
  5. Josef WolfSep 12, 2013
  6. Jeff KingSep 12, 2013
  7. Josef WolfSep 12, 2013
  8. Jeff KingSep 12, 2013
  9. Josef WolfSep 13, 2013
  10. Jeff KingSep 16, 2013
  11. Josef WolfSep 20, 2013
  12. Jeff KingSep 24, 2013
  13. Josef WolfSep 24, 2013
  14. Pyeron, Jason J CTR (US)Sep 12, 2013
  15. Jeff KingSep 12, 2013
  16. Pyeron, Jason J CTR (US)Sep 12, 2013
  17. Josef WolfSep 13, 2013
  18. Jason PyeronSep 13, 2013
  19. Duy NguyenSep 13, 2013

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.