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

Re: [PATCH 3/3] pack-bitmap.c: use commit boundary during bitmap traversal

From
Derrick Stolee <derrickstolee@github.com>
Date
Apr 25, 2023, 18:53 UTC
Message-ID
<a143150d-7cf5-c697-0e48-0f7af1c6de8f@github.com>
In-Reply-To
<91ed8c70f22dd2c47c60d650323579fc42cc7f2d.1682380788.git.me@ttaylorr.com>
On 4/24/2023 8:00 PM, Taylor Blau wrote:
> When reachability bitmap coverage exists in a repository, Git will use a
> different (and hopefully faster) traversal to compute revision walks.
Before getting into the code...
> Consider a set of positive and negative tips (which we'll refer to with
> their standard bitmap parlance by, "wants", and "haves"). In order to
> figure out what objects exist between the tips, the existing traversal
> in prepare_bitmap_walk() looks something like:
Show 6 quoted lines
>   4. Construct a reachability bitmap for the "haves" side by walking
>      from the revision tips down to any existing bitmaps, OR-ing in any
>      bitmaps as they are found.
> 
>   5. Then do the same for the "wants" side, stopping at any objects that
>      appear in the "haves" bitmap.

One important thing about this older algorithm is that it will avoid including trees and blobs that are reachable from the "haves" that are not reachable from the boundary between "haves" and "wants". The most obvious case is that someone force-pushed a branch after rewording the commit messages but keeping the trees and blobs identical.

This case is rare, and usually the objects that would be repeated are low enough in count and size (with deltas) that it's not a big deal, but it is worth bringing up. I didn't see a reference to this side of the difference in your message.

Show 6 quoted lines
> One of the benefits, however, is that even if the walk is slower, bitmap
> traversals are guaranteed to provide an *exact* answer. Unlike the
> traditional object traversal algorithm, which can over-count the results
> by not opening trees for older commits, the bitmap walk builds an exact
> reachability bitmap for either side, meaning the results are never
> over-counted.

So the new algorithm is a new, third state of "not overcounting things reachable beyond the commit-walk boundary" and "overcounting things reachable from the wants..haves commit region".

> But producing non-exact results is OK for our traversal here (both in
> the bitmap case and not), as long as the results are over-counted, not
> under.

True, our response will not create a pack-file that cannot be applied locally, but it might be larger than required.

For these reasons, I'm surprised that this patch completely replaces the old algorithm for the new one. I would prefer to see a config option that enables this new algorithm. It would be safer to deploy that way, too.

> The new result performs significantly better in many cases, particularly
> when the distance from the boundary commit(s) to an existing bitmap is
> shorter than the distance from (all of) the have tips to the nearest
> bitmapped commit.
Aside: we may even gain benefits by adjusting the commits selected for
bitmaps by trying for this data shape. One way to attempt this is to
not focus on refs but on history common to "most refs" using first-
parent history as a good heuristic. If a commit appears in a lot of
first-parent histories, then it is more likely to be helpful to these
kinds of walks.
 
Show 10 quoted lines
> Note that when using the old bitmap traversal algorithm, the results can
> be *slower* than without bitmaps! Under the new algorithm, the result is
> computed faster with bitmaps than without (at the cost of over-counting
> the true number of objects in a similar fashion as the non-bitmap
> traversal):
>
>     # (Computing objects unique to 'master' among all branches, not
>     # using bitmaps).
>     $ time git rev-list --count --objects master --not --exclude=master --branches
>     54

I like how you included the output of --count here. It might be interesting to demonstrate the different forms of overcounting in a carefully constructed test case, which would help us be sure that we are using the desired algorithm during a test case.

>     real	0m1.012s  (no bitmaps)
>     real	0m29.571s (bitmaps, old)
>     real	0m2.279s  (bitmaps, new)
> The new algorithm is still slower than not using bitmaps at all, but it
> is nearly a 13-fold improvement over the existing traversal.
> In a more realistic setting (using my local copy of git.git), I can
> observe a similar speed-up:
...
> Here, the new algorithm is also still slower than not using bitmaps, but
> represents a 4-fold improvement over the existing traversal in a more
> modest example.
Interesting that the new bitmap algorithm is worse in all presented cases.

How "atypical" do we need to be in order for bitmaps to outperform the tree-parsing algorithm? Do we need to try "--branches --not master~1000" to replicate a stale single-branch clone getting every latest commit?

(I'll leave code review to a separate reply.)

Thanks, -Stolee

Previous: Junio C HamanoNext: Junio C Hamano
Message 19 of 51 in “pack-bitmap: boundary-based bitmap traversal”
  1. 0/3 pack-bitmap: boundary-based bitmap traversalTaylor Blau, Apr 25, 2023
  2. 1/3 revision: support tracking uninteresting commitsTaylor Blau, Apr 25, 2023
  3. Derrick StoleeApr 25, 2023
  4. Taylor BlauMay 3, 2023
  5. Derrick StoleeMay 4, 2023
  6. Taylor BlauMay 3, 2023
  7. Derrick StoleeMay 4, 2023
  8. Taylor BlauMay 5, 2023
  9. Junio C HamanoApr 25, 2023
  10. Taylor BlauApr 25, 2023
  11. 2/3 pack-bitmap.c: extract `fill_in_bitmap()`Taylor Blau, Apr 25, 2023
  12. Junio C HamanoApr 25, 2023
  13. Taylor BlauApr 25, 2023
  14. 3/3 pack-bitmap.c: use commit boundary during bitmap traversalTaylor Blau, Apr 25, 2023
  15. Junio C HamanoApr 25, 2023
  16. Felipe ContrerasMay 2, 2023
  17. Taylor BlauMay 3, 2023
  18. Junio C HamanoMay 3, 2023
  19. Derrick StoleeApr 25, 2023
  20. Junio C HamanoApr 25, 2023
  21. Derrick StoleeApr 25, 2023
  22. Taylor BlauApr 25, 2023
  23. Derrick StoleeApr 25, 2023
  24. Taylor BlauMay 3, 2023
  25. Derrick StoleeApr 25, 2023
  26. Taylor BlauApr 25, 2023
  27. Derrick StoleeApr 25, 2023
  28. Junio C HamanoMay 1, 2023
  29. Taylor BlauMay 2, 2023
  30. 0/2 pack-bitmap: boundary-based bitmap traversalTaylor Blau, May 5, 2023
  31. 1/2 pack-bitmap.c: extract `fill_in_bitmap()`Taylor Blau, May 5, 2023
  32. 2/2 pack-bitmap.c: use commit boundary during bitmap traversalTaylor Blau, May 5, 2023
  33. Derrick StoleeMay 5, 2023
  34. Taylor BlauMay 5, 2023
  35. Junio C HamanoMay 5, 2023
  36. Derrick StoleeMay 5, 2023
  37. Taylor BlauMay 5, 2023
  38. Derrick StoleeMay 5, 2023
  39. 0/3 pack-bitmap: boundary-based bitmap traversalTaylor Blau, May 8, 2023
  40. 1/3 object: add object_array initializer helper functionTaylor Blau, May 8, 2023
  41. 2/3 pack-bitmap.c: extract `fill_in_bitmap()`Taylor Blau, May 8, 2023
  42. 3/3 pack-bitmap.c: use commit boundary during bitmap traversalTaylor Blau, May 8, 2023
  43. Derrick StoleeMay 8, 2023
  44. Taylor BlauMay 8, 2023
  45. Junio C HamanoMay 10, 2023
  46. Taylor BlauMay 10, 2023
  47. Derrick StoleeMay 11, 2023
  48. 0/3 pack-bitmap: boundary-based bitmap traversalTaylor Blau, Jun 8, 2023
  49. 1/3 object: add object_array initializer helper functionTaylor Blau, Jun 8, 2023
  50. 2/3 pack-bitmap.c: extract `fill_in_bitmap()`Taylor Blau, Jun 8, 2023
  51. 3/3 pack-bitmap.c: use commit boundary during bitmap traversalTaylor Blau, Jun 8, 2023

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.