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

Re: [PATCH] check_everything_connected: assume alternate ref tips are valid

From
Derrick Stolee <stolee@gmail.com>
Date
Jun 28, 2019, 12:51 UTC
Message-ID
<601d8561-6e24-559c-6fbb-fa25a7389fa0@gmail.com>
In-Reply-To
<20190628101131.GA22862@sigill.intra.peff.net>
On 6/28/2019 6:11 AM, Jeff King wrote:
Show 9 quoted lines
> When we receive a remote ref update to sha1 "X", we want to check that
> we have all of the objects needed by "X". We can assume that our
> repository is not currently corrupted, and therefore if we have a ref
> pointing at "Y", we have all of its objects. So we can stop our
> traversal from "X" as soon as we hit "Y".
> 
> If we make the same non-corruption assumption about any repositories we
> use to store alternates, then we can also use their ref tips to shorten
> the traversal.

I was confused by this paragraph, because I didn't know about for_each_alternate_ref() and how refs_From_alternate_cb() will strip the "/objects" and append "/refs" to check refs if they exist. All of that logic is in transport.c but used by fetch-pack.c and builtin/receive-pack.c. But now we are adding to revision.c, so the restriction to "this helps data transfer" is getting murkier.

Is this something that should be extracted to the object-store layer? Or is it so tricky to use that we shouldn't make it too easy to fall into a bad pattern?

Show 13 quoted lines
> This is especially useful when cloning with "--reference", as we
> otherwise do not have any local refs to check against, and have to
> traverse the whole history, even though the other side may have sent us
> few or no objects. Here are results for the included perf test (which
> shows off more or less the maximal savings, getting one new commit and
> sharing the whole history):
> 
> Test                        HEAD^             HEAD
> --------------------------------------------------------------------
> [on git.git]
> 5600.3: clone --reference   2.94(2.86+0.08)   0.09(0.08+0.01) -96.9%
> [on linux.git]
> 5600.3: clone --reference   45.74(45.34+0.41)   0.36(0.30+0.08) -99.2%
It's really hard to argue with numbers like these. Kudos!
Show 8 quoted lines
> 
> Signed-off-by: Jeff King <peff@peff.net>
> ---
>  Documentation/rev-list-options.txt |  8 ++++
>  connected.c                        |  1 +
>  revision.c                         | 30 +++++++++++++++
>  t/perf/p5600-clone-reference.sh    | 27 ++++++++++++++
>  t/t5618-alternate-refs.sh          | 60 ++++++++++++++++++++++++++++++

Other than the high-level questions above, the code and tests look good to me.

Thanks, -Stolee

Previous: Jeff KingNext: Jeff King
Message 3 of 20 in “check_everything_connected: assume alternate ref tips are valid”
  1. check_everything_connected: assume alternate ref tips are validJeff King, Jun 28, 2019
  2. Jeff KingJun 28, 2019
  3. Derrick StoleeJun 28, 2019
  4. Jeff KingJun 29, 2019
  5. Derrick StoleeJul 1, 2019
  6. Jeff KingJul 1, 2019
  7. Jeff KingJul 1, 2019
  8. 1/2 object-store.h: move for_each_alternate_ref() from transport.hJeff King, Jul 1, 2019
  9. Derrick StoleeJul 1, 2019
  10. 2/2 check_everything_connected: assume alternate ref tips are validJeff King, Jul 1, 2019
  11. SZEDER GáborJul 3, 2019
  12. Jeff KingJul 3, 2019
  13. Junio C HamanoJul 3, 2019
  14. SZEDER GáborJul 3, 2019
  15. Junio C HamanoJul 3, 2019
  16. Taylor BlauJul 1, 2019
  17. Jeff KingJul 2, 2019
  18. Junio C HamanoJun 28, 2019
  19. Jeff KingJun 29, 2019
  20. Derrick StoleeJul 1, 2019

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.