Skip to content

Commit 23c1e71

Browse files
ttaylorrgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7c01878 commit 23c1e71

File tree

5 files changed

+23
-0
lines changed

5 files changed

+23
-0
lines changed

Documentation/config/feature.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ skipping more commits at a time, reducing the number of round trips.
1717
+
1818
* `pack.useBitmapBoundaryTraversal=true` may improve bitmap traversal times by
1919
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.
2023

2124
feature.manyFiles::
2225
Enable config options that optimize for repos with many files in the

builtin/pack-objects.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4396,6 +4396,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
43964396
prepare_repo_settings(the_repository);
43974397
if (sparse < 0)
43984398
sparse = the_repository->settings.pack_use_sparse;
4399+
if (the_repository->settings.pack_use_multi_pack_reuse)
4400+
allow_pack_reuse = MULTI_PACK_REUSE;
43994401
}
44004402

44014403
reset_pack_idx_option(&pack_idx_opts);

repo-settings.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ void prepare_repo_settings(struct repository *r)
4343
if (experimental) {
4444
r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_SKIPPING;
4545
r->settings.pack_use_bitmap_boundary_traversal = 1;
46+
r->settings.pack_use_multi_pack_reuse = 1;
4647
}
4748
if (manyfiles) {
4849
r->settings.index_version = 4;

repository.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ struct repo_settings {
3939
int sparse_index;
4040
int pack_read_reverse_index;
4141
int pack_use_bitmap_boundary_traversal;
42+
int pack_use_multi_pack_reuse;
4243

4344
/*
4445
* Does this repository have core.useReplaceRefs=true (on by

t/t5332-multi-pack-reuse.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,22 @@ test_expect_success 'preferred pack is reused for single-pack reuse' '
5858
test_pack_objects_reused_all 3 1
5959
'
6060

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+
'
6177

6278
test_expect_success 'enable multi-pack reuse' '
6379
git config pack.allowPackReuse multi

0 commit comments

Comments
 (0)