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

Re: Question: How to execute git-gc correctly on the git server

From
Jeff King <peff@peff.net>
Date
Dec 8, 2022, 06:59 UTC
Message-ID
<Y5GLWe4Kdaz+T5P8@coredump.intra.peff.net>
In-Reply-To
<221208.86a63y9309.gmgdl@evledraar.gmail.com>
On Thu, Dec 08, 2022 at 12:57:45AM +0100, Ævar Arnfjörð Bjarmason wrote:
Show 7 quoted lines
> Is this for a very large hosting site that's anywhere near GitHub,
> GitLab's etc. scale?
> 
> A "git gc" on a "live" repo is always racy in theory, but the odds that
> you'll run into data corrupting trouble tends to approach zero as you
> increase the gc.pruneExpire setting, with the default 2 weeks being more
> than enough for even the most paranoid user.

I'm a bit less optimistic than "tends to approach zero" here. The objects themselves might be older, but they may become referenced or unreferenced in an immediate racy way. E.g., intending to move branch Z to branch A, a client asks to add A and remove Z. Since there is no atomic view of the ref namespace, a simultaneous gc might see Z gone, but A not yet existing (and of course it could also be _two_ clients, etc).

Show 5 quoted lines
> The "cruft pack" facility does many different things, and my
> understanding of it is that GitHub's not using it only as an end-run
> around potential corruption issues, but that some not yet in tree
> patches on top of it allow more aggressive "gc" without the fear of
> corruption.

I don't think cruft packs themselves help against corruption that much. For many years, GitHub used "repack -k" to just never expire objects. What cruft packs help with is:

  1. They keep cruft objects out of the main pack, which reduces the
     costs of lookups and bitmaps for the main pack.
  2. When you _do_ choose to expire, you can do so without worrying
     about accidentally exploding all of those old objects into loose
     ones (which is not wrong from a correctness point of view, but can
     have some amazingly bad performance characteristics).

I think the bits you're thinking of on top are in v2.39. The "repack --expire-to" option lets you write objects that _would_ be deleted into a cruft pack, which can serve as a backup (but managing that is out of scope for repack itself, so you have to roll your own strategy there).

-Peff
Previous: ZheNing HuNext: Ævar Arnfjörð Bjarmason
Message 12 of 14 in “Question: How to execute git-gc correctly on the git server”
  1. ZheNing HuDec 7, 2022
  2. Ævar Arnfjörð BjarmasonDec 7, 2022
  3. Michal SuchánekDec 8, 2022
  4. Jeff KingDec 8, 2022
  5. Michal SuchánekDec 9, 2022
  6. Jeff KingDec 9, 2022
  7. ZheNing HuDec 9, 2022
  8. Ævar Arnfjörð BjarmasonDec 9, 2022
  9. ZheNing HuDec 11, 2022
  10. Michal SuchánekDec 11, 2022
  11. ZheNing HuDec 9, 2022
  12. Jeff KingDec 8, 2022
  13. Ævar Arnfjörð BjarmasonDec 8, 2022
  14. Taylor BlauDec 14, 2022

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.