pack-objects: enable multi-pack reuse via `feature.experimental`

Now that multi-pack reuse is supported, enable it via the feature.experimental configuration in addition to the classic `pack.allowPackReuse`. This will allow more users to experiment with the new behavior who might not otherwise be aware of the existing `pack.allowPackReuse` configuration option. The enum with values NO_PACK_REUSE, SINGLE_PACK_REUSE, and MULTI_PACK_REUSE is defined statically in builtin/pack-objects.c's compilation unit. We could hoist that enum into a scope visible from the repository_settings struct, and then use that enum value in pack-objects. Instead, define a single int that indicates what pack-objects's default value should be to avoid additional unnecessary code movement. Though `feature.experimental` implies `pack.allowPackReuse=multi`, this can still be overridden by explicitly setting the latter configuration to either "single" or "false". Tests covering all of these cases are showin t5332. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Taylor Blau committed Feb 5, 2024 at 17:50 UTC 23c1e71369f4a5a5e5b176d77cfc9d8edf68ebec
5 files changed +23
Documentation/config/feature.txt
+3
@@ -17,6 +17,9 @@ skipping more commits at a time, reducing the number of round trips.
17 +
18 * `pack.useBitmapBoundaryTraversal=true` may improve bitmap traversal times by
19 walking fewer objects.
20 ++
21 +* `pack.allowPackReuse=multi` may improve the time it takes to create a pack by
22 +reusing objects from multiple packs instead of just one.
23
24 feature.manyFiles::
25 Enable config options that optimize for repos with many files in the
builtin/pack-objects.c
+2
@@ -4396,6 +4396,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
4396 prepare_repo_settings(the_repository);
4397 if (sparse < 0)
4398 sparse = the_repository->settings.pack_use_sparse;
4399 + if (the_repository->settings.pack_use_multi_pack_reuse)
4400 + allow_pack_reuse = MULTI_PACK_REUSE;
4401 }
4402
4403 reset_pack_idx_option(&pack_idx_opts);
repo-settings.c
+1
@@ -43,6 +43,7 @@ void prepare_repo_settings(struct repository *r)
43 if (experimental) {
44 r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_SKIPPING;
45 r->settings.pack_use_bitmap_boundary_traversal = 1;
46 + r->settings.pack_use_multi_pack_reuse = 1;
47 }
48 if (manyfiles) {
49 r->settings.index_version = 4;
repository.h
+1
@@ -39,6 +39,7 @@ struct repo_settings {
39 int sparse_index;
40 int pack_read_reverse_index;
41 int pack_use_bitmap_boundary_traversal;
42 + int pack_use_multi_pack_reuse;
43
44 /*
45 * Does this repository have core.useReplaceRefs=true (on by
t/t5332-multi-pack-reuse.sh
+16
@@ -58,6 +58,22 @@ test_expect_success 'preferred pack is reused for single-pack reuse' '
58 test_pack_objects_reused_all 3 1
59 '
60
61 +test_expect_success 'multi-pack reuse is disabled by default' '
62 + test_pack_objects_reused_all 3 1
63 +'
64 +
65 +test_expect_success 'feature.experimental implies multi-pack reuse' '
66 + test_config feature.experimental true &&
67 +
68 + test_pack_objects_reused_all 6 2
69 +'
70 +
71 +test_expect_success 'multi-pack reuse can be disabled with feature.experimental' '
72 + test_config feature.experimental true &&
73 + test_config pack.allowPackReuse single &&
74 +
75 + test_pack_objects_reused_all 3 1
76 +'
77
78 test_expect_success 'enable multi-pack reuse' '
79 git config pack.allowPackReuse multi