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

Re: How to resume broke clone ?

From
Shawn Pearce <spearce@spearce.org>
Date
Dec 5, 2013, 15:11 UTC
Message-ID
<CAJo=hJuRTHEO6Mpaaa7b=_ozDq3UfVNEx6iabKP4xRVoRZLcUw@mail.gmail.com>
In-Reply-To
<52A07DC5.5090508@alum.mit.edu>
On Thu, Dec 5, 2013 at 5:21 AM, Michael Haggerty <mhagger@alum.mit.edu> wrote:
Show 13 quoted lines
> This discussion has mostly been about letting small Git servers delegate
> the work of an initial clone to a beefier server.  I haven't seen any
> explicit mention of the inverse:
>
> Suppose a company has a central Git server that is meant to be the
> "single source of truth", but has worldwide offices and wants to locate
> bootstrap mirrors in each office.  The end users would not even want to
> know that there are multiple servers.  Hosters like GitHub might also
> encourage their big customers to set up bootstrap mirror(s) in-house to
> make cloning faster for their users while reducing internet traffic and
> the burden on their own infrastructure.  The goal would be to make the
> system transparent to users and easily reconfigurable as circumstances
> change.
I think there is a different way to do that.
Build a caching Git proxy server. And teach Git clients to use it.

One idea we had at $DAY_JOB a couple of years ago was to build a daemon that sat in the background and continuously fetched content from repository upstreams. We made it efficient by modifying the Git protocol to use a hanging network socket, and the upstream server would broadcast push pack files down these hanging streams as pushes were received.

The original intent was for an Android developer to be able to have his working tree forest of 500 repositories subscribe to our internal server's broadcast stream. We figured if the server knows exactly which refs every client has, because they all have the same ones, and their streams are all still open and active, then the server can make exactly one incremental thin pack and send the same copy to every client. Its "just" a socket write problem. Instead of packing the same stuff 100x for 100x clients its packed once and sent 100x.

Then we realized remote offices could also install this software on a local server, and use this as a fan-out distributor within the LAN. We were originally thinking about some remote offices on small Internet connections, where delivery of 10 MiB x 20 was a lot but delivery of 10 MiB once and local fan-out on the Ethernet was easy.

The JGit patches for this work are still pending[1].

If clients had a local Git-aware cache server in their office and ~/.gitconfig had the address of it, your problem becomes simple.

Clients clone from the public URL e.g. GitHub, but the local cache server first gives the client a URL to clone from itself. After that is complete then the client can fetch from the upstream. The cache server can be self-maintaining, watching its requests to see what is accessed often-ish, and keep those repositories current-ish locally by running git fetch itself in the background.

Its easy to do this with bundles on "CDN" like HTTP. Just use the office's caching HTTP proxy server. Assuming its cache is big enough for those large Git bundle payloads, and the viral cat videos. But you are at the mercy of the upstream bundler rebuilding the bundles. And refetching them in whole. Neither of which is great.

A simple self-contained server that doesn't accept pushes, but knows how to clone repositories, fetch them periodically, and run `git gc`, works well. And the mirror URL extension we have been discussing in this thread would work fine here. The cache server can return URLs that point to itself. Or flat out proxy the Git transaction with the origin server.

[1] https://git.eclipse.org/r/#/q/owner:wetherbeei%2540google.com+status:open,n,z
Previous: Michael HaggertyNext: Jeff King
Message 15 of 34 in “How to resume broke clone ?”
  1. zhifeng huNov 28, 2013
  2. Trần Ngọc QuânNov 28, 2013
  3. zhifeng huNov 28, 2013
  4. Duy NguyenNov 28, 2013
  5. Karsten BleesNov 28, 2013
  6. Duy NguyenNov 28, 2013
  7. zhifeng huNov 28, 2013
  8. Duy NguyenNov 28, 2013
  9. Jeff KingNov 28, 2013
  10. Duy NguyenNov 28, 2013
  11. Shawn PearceNov 28, 2013
  12. Jeff KingDec 4, 2013
  13. Shawn PearceDec 5, 2013
  14. Michael HaggertyDec 5, 2013
  15. Shawn PearceDec 5, 2013
  16. Jeff KingDec 5, 2013
  17. Jeff KingDec 5, 2013
  18. Junio C HamanoDec 5, 2013
  19. Jeff KingDec 5, 2013
  20. pack-objects: name pack files after trailer hashJeff King, Dec 5, 2013
  21. Shawn PearceDec 5, 2013
  22. Junio C HamanoDec 5, 2013
  23. Jeff KingDec 6, 2013
  24. Michael HaggertyDec 16, 2013
  25. Jeff KingDec 16, 2013
  26. Jonathan NiederDec 16, 2013
  27. Jeff KingDec 16, 2013
  28. Junio C HamanoDec 16, 2013
  29. Junio C HamanoDec 16, 2013
  30. Jeff KingDec 16, 2013
  31. Tay Ray ChuanNov 28, 2013
  32. zhifeng huNov 28, 2013
  33. Shawn PearceNov 28, 2013
  34. Jakub NarebskiNov 28, 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.