@matheusbsbs / matheus-bagliano / commits / 3ab3185f99
Fork 0

pack-objects: support filters with bitmaps

Just as rev-list recently learned to combine filters and bitmaps, let's do the same for pack-objects. The infrastructure is all there; we just need to pass along our filter options, and the pack-bitmap code will decide to use bitmaps or not. This unsurprisingly makes things faster for partial clones of large repositories (here we're cloning linux.git): Test HEAD^ HEAD ------------------------------------------------------------------------------ 5310.11: simulated partial clone 38.94(37.28+5.87) 11.06(11.27+4.07) -71.6% Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Feb 14, 2020 at 13:22 UTC 3ab3185f999f5d0d0079ac8246edb8fca5d9d3fd
3 files changed +19 -2
builtin/pack-objects.c
+1 -2
@@ -3040,7 +3040,7 @@ static int pack_options_allow_reuse(void)
3040
3041 static int get_object_list_from_bitmap(struct rev_info *revs)
3042 {
3043 - if (!(bitmap_git = prepare_bitmap_walk(revs, NULL)))
3043 + if (!(bitmap_git = prepare_bitmap_walk(revs, &filter_options)))
3044 return -1;
3045
3046 if (pack_options_allow_reuse() &&
@@ -3419,7 +3419,6 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
3419 if (filter_options.choice) {
3420 if (!pack_to_stdout)
3421 die(_("cannot use --filter without --stdout"));
3422 - use_bitmap_index = 0;
3422 }
3423
3424 /*
t/perf/p5310-pack-bitmaps.sh
+4
@@ -57,6 +57,10 @@ test_perf 'rev-list count with blob:limit=1k' '
57 --filter=blob:limit=1k >/dev/null
58 '
59
60 +test_perf 'simulated partial clone' '
61 + git pack-objects --stdout --all --filter=blob:none </dev/null >/dev/null
62 +'
63 +
64 test_expect_success 'create partial bitmap state' '
65 # pick a commit to represent the repo tip in the past
66 cutoff=$(git rev-list HEAD~100 -1) &&
t/t5310-pack-bitmaps.sh
+14
@@ -107,6 +107,20 @@ test_expect_success 'clone from bitmapped repository' '
107 test_cmp expect actual
108 '
109
110 +test_expect_success 'partial clone from bitmapped repository' '
111 + test_config uploadpack.allowfilter true &&
112 + git clone --no-local --bare --filter=blob:none . partial-clone.git &&
113 + (
114 + cd partial-clone.git &&
115 + pack=$(echo objects/pack/*.pack) &&
116 + git verify-pack -v "$pack" >have &&
117 + awk "/blob/ { print \$1 }" <have >blobs &&
118 + # we expect this single blob because of the direct ref
119 + git rev-parse refs/tags/tagged-blob >expect &&
120 + test_cmp expect blobs
121 + )
122 +'
123 +
124 test_expect_success 'setup further non-bitmapped commits' '
125 test_commit_bulk --id=further 10
126 '