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

[PATCH 0/5] PATH WALK III: Add 'git backfill' command

From
Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>
Date
Dec 6, 2024, 20:07 UTC
Message-ID
<pull.1820.git.1733515638.gitgitgadget@gmail.com>

This is based on v3 of ds/path-walk-1 [1] and an earlier version was part of my initial path-walk RFC [2].

[1] https://lore.kernel.org/git/pull.1818.v3.git.1733514358.gitgitgadget@gmail.com/

[2] https://lore.kernel.org/git/pull.1786.git.1725935335.gitgitgadget@gmail.com/

This series adds a new 'git backfill' command that uses the path-walk API to download missing blobs in a blobless partial clone. Users can specify interaction with the sparse-checkout using '--[no-]sparse' but the '--sparse' option is implied by the existence of a sparse-checkout.

The reason to use the path-walk API is to make sure that the missing objects are grouped by a common path, giving a reasonable process for batching requests and expecting the server to compress the resulting packfile nicely together.

I first prototyped this feature in June 2024 as an exploration and created the path-walk algorithm for this purpose. It was only my intuition that led me to believe that batching by path would lead to better packfiles. This has been proven out as a very important feature due to recent investigations to compressing full repositories by doing a better job of grouping objects by path. See the --name-hash-version series [3] or the 'git pack-objects --path-walk' series [4] (currently on hold as it conflicts with the --name-hash-version series).

[3] https://lore.kernel.org/git/pull.1823.v2.git.1733181682.gitgitgadget@gmail.com/

[4] https://lore.kernel.org/git/pull.1813.v2.git.1729431810.gitgitgadget@gmail.com/

This idea can be further demonstrated by the evidence in testing this feature: by downloading objects in small batch sizes, the client can force the server to repack things more efficiently than a full repack.

The example repository I have used in multiple places is the microsoft/fluentui repo [5] as it has many CHANGELOG.md files that cause name hash collisions that make the full repack inefficient.

[5] https://github.com/microsoft/fluentui

If we create a blobless clone of the fluentui repo, then this downloads 105 MB across two packfiles (the commits and trees pack, followed by the blobs needed for an initial checkout). Running 'git backfill --batch-size=' for different sizes leads to some interesting results:

| Batch Size      | Pack Count | Pack Size | Time   |
|-----------------|------------|-----------|--------|
| (Initial clone) | 2          | 105 MB    |        |
| 5K              | 53         | 348 MB    | 2m 26s |
| 10K             | 28         | 365 MB    | 2m 22s |
| 15K             | 19         | 407 MB    | 2m 21s |
| 20K             | 15         | 393 MB    | 2m 28s |
| 25K             | 13         | 417 MB    | 2m 06s |
| 50K             | 8          | 509 MB    | 1m 34s |
| 100K            | 5          | 535 MB    | 1m 56s |
| 250K            | 4          | 698 MB    | 1m 33s |
| 500K            | 3          | 696 MB    | 1m 42s |

The smaller batches cause the server to realize that the existing deltas cannot be reused and it finds better deltas. This takes some extra time for the small batches, but halves the size of the repo. Even in the 500K batch size, we get less data than the 738 MB of a full clone.

Implementing the --sparse feature is best done by augmenting the path-walk API to be aware of a pattern list. This works for both cone and non-cone mode sparse-checkouts.

There are future directions we could take this command, especially to run the command with a user-specified pathspec. The tricky case for that additional feature is trying to make the path-walk more efficient by skipping tree paths that would not lead to a match of the pathspec. It would likely need optimization in a small subset of pathspec features (such as prefix matches) to work as efficiently as possible. I did prototype a version that puts the pathspec match in the callback function within builtin/backfill.c, but I found that uninspiring and unnecessary for now.

Thanks, -Stolee
Derrick Stolee (5):
  backfill: add builtin boilerplate
  backfill: basic functionality and tests
  backfill: add --batch-size=<n> option
  backfill: add --sparse option
  backfill: assume --sparse when sparse-checkout is enabled
 .gitignore                                |   1 +
 Documentation/git-backfill.txt            |  60 ++++++++
 Documentation/technical/api-path-walk.txt |  11 +-
 Makefile                                  |   1 +
 builtin.h                                 |   1 +
 builtin/backfill.c                        | 147 ++++++++++++++++++
 command-list.txt                          |   1 +
 dir.c                                     |  10 +-
 dir.h                                     |   3 +
 git.c                                     |   1 +
 path-walk.c                               |  18 +++
 path-walk.h                               |  11 ++
 t/helper/test-path-walk.c                 |  22 ++-
 t/t5620-backfill.sh                       | 178 ++++++++++++++++++++++
 t/t6601-path-walk.sh                      |  32 ++++
 15 files changed, 488 insertions(+), 9 deletions(-)
 create mode 100644 Documentation/git-backfill.txt
 create mode 100644 builtin/backfill.c
 create mode 100755 t/t5620-backfill.sh
base-commit: e716672c041473dd2bf257b7532b86696fef32a0
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1820%2Fderrickstolee%2Fbackfill-upstream-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1820/derrickstolee/backfill-upstream-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/1820
-- 
gitgitgadget
Next: Derrick Stolee via GitGitGadget
Message 1 of 39 in “PATH WALK III: Add 'git backfill' command”
  1. 0/5 PATH WALK III: Add 'git backfill' commandDerrick Stolee via GitGitGadget, Dec 6, 2024
  2. 1/5 backfill: add builtin boilerplateDerrick Stolee via GitGitGadget, Dec 6, 2024
  3. Patrick SteinhardtJan 16, 2025
  4. Junio C HamanoJan 16, 2025
  5. Derrick StoleeFeb 3, 2025
  6. 2/5 backfill: basic functionality and testsDerrick Stolee via GitGitGadget, Dec 6, 2024
  7. Patrick SteinhardtDec 16, 2024
  8. Derrick StoleeDec 18, 2024
  9. 3/5 backfill: add --batch-size=<n> optionDerrick Stolee via GitGitGadget, Dec 6, 2024
  10. Patrick SteinhardtDec 16, 2024
  11. Derrick StoleeDec 18, 2024
  12. Jean-Noël AVILAJan 19, 2025
  13. 4/5 backfill: add --sparse optionDerrick Stolee via GitGitGadget, Dec 6, 2024
  14. Patrick SteinhardtDec 16, 2024
  15. 5/5 backfill: assume --sparse when sparse-checkout is enabledDerrick Stolee via GitGitGadget, Dec 6, 2024
  16. Junio C HamanoDec 8, 2024
  17. Junio C HamanoDec 9, 2024
  18. 0/5 PATH WALK III: Add 'git backfill' commandDerrick Stolee via GitGitGadget, Dec 20, 2024
  19. 1/5 backfill: add builtin boilerplateDerrick Stolee via GitGitGadget, Dec 20, 2024
  20. 2/5 backfill: basic functionality and testsDerrick Stolee via GitGitGadget, Dec 20, 2024
  21. Patrick SteinhardtJan 16, 2025
  22. Derrick StoleeFeb 3, 2025
  23. 3/5 backfill: add --min-batch-size=<n> optionDerrick Stolee via GitGitGadget, Dec 20, 2024
  24. Patrick SteinhardtJan 16, 2025
  25. 4/5 backfill: add --sparse optionDerrick Stolee via GitGitGadget, Dec 20, 2024
  26. Patrick SteinhardtJan 16, 2025
  27. Derrick StoleeFeb 3, 2025
  28. 5/5 backfill: assume --sparse when sparse-checkout is enabledDerrick Stolee via GitGitGadget, Dec 20, 2024
  29. Patrick SteinhardtJan 16, 2025
  30. Junio C HamanoJan 17, 2025
  31. 0/5 PATH WALK III: Add 'git backfill' commandDerrick Stolee via GitGitGadget, Feb 3, 2025
  32. 1/5 backfill: add builtin boilerplateDerrick Stolee via GitGitGadget, Feb 3, 2025
  33. 2/5 backfill: basic functionality and testsDerrick Stolee via GitGitGadget, Feb 3, 2025
  34. 3/5 backfill: add --min-batch-size=<n> optionDerrick Stolee via GitGitGadget, Feb 3, 2025
  35. 4/5 backfill: add --sparse optionDerrick Stolee via GitGitGadget, Feb 3, 2025
  36. 5/5 backfill: assume --sparse when sparse-checkout is enabledDerrick Stolee via GitGitGadget, Feb 3, 2025
  37. Junio C HamanoFeb 4, 2025
  38. Patrick SteinhardtFeb 5, 2025
  39. Junio C HamanoFeb 5, 2025

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.