]> git.ipfire.org Git - thirdparty/git.git/commitdiff
pack-objects: enable multi-pack reuse via `feature.experimental`
authorTaylor Blau <me@ttaylorr.com>
Mon, 5 Feb 2024 22:50:23 +0000 (17:50 -0500)
committerJunio C Hamano <gitster@pobox.com>
Mon, 5 Feb 2024 23:27:01 +0000 (15:27 -0800)
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>
Documentation/config/feature.txt
builtin/pack-objects.c
repo-settings.c
repository.h
t/t5332-multi-pack-reuse.sh

index bf9546fca4f693f01b39252d12def7df9b51a52f..f061b64b7484497a43fba7aaac67c7f84b012582 100644 (file)
@@ -17,6 +17,9 @@ skipping more commits at a time, reducing the number of round trips.
 +
 * `pack.useBitmapBoundaryTraversal=true` may improve bitmap traversal times by
 walking fewer objects.
++
+* `pack.allowPackReuse=multi` may improve the time it takes to create a pack by
+reusing objects from multiple packs instead of just one.
 
 feature.manyFiles::
        Enable config options that optimize for repos with many files in the
index d8c2128a97928229e93212461027b700d219ec6a..329aeac80437502a49b48fe5383aa40e90cd16c3 100644 (file)
@@ -4396,6 +4396,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
                prepare_repo_settings(the_repository);
                if (sparse < 0)
                        sparse = the_repository->settings.pack_use_sparse;
+               if (the_repository->settings.pack_use_multi_pack_reuse)
+                       allow_pack_reuse = MULTI_PACK_REUSE;
        }
 
        reset_pack_idx_option(&pack_idx_opts);
index 30cd4787627b7cacbc2dbceddc0babee1b72cb3e..a0b590bc6c0bb927fb0846055f4c4826e9558c80 100644 (file)
@@ -43,6 +43,7 @@ void prepare_repo_settings(struct repository *r)
        if (experimental) {
                r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_SKIPPING;
                r->settings.pack_use_bitmap_boundary_traversal = 1;
+               r->settings.pack_use_multi_pack_reuse = 1;
        }
        if (manyfiles) {
                r->settings.index_version = 4;
index 7a250a6605cc8e5a3ae661584122bf1f90f16747..21949c5a17f68c8cff53abd3abe815d8c5e2c643 100644 (file)
@@ -39,6 +39,7 @@ struct repo_settings {
        int sparse_index;
        int pack_read_reverse_index;
        int pack_use_bitmap_boundary_traversal;
+       int pack_use_multi_pack_reuse;
 
        /*
         * Does this repository have core.useReplaceRefs=true (on by
index d516062f84fb7b124ff2f2787d63e66c5ada39fe..b925a81d3725d86f68875d6cb17bca589fe99707 100755 (executable)
@@ -58,6 +58,22 @@ test_expect_success 'preferred pack is reused for single-pack reuse' '
        test_pack_objects_reused_all 3 1
 '
 
+test_expect_success 'multi-pack reuse is disabled by default' '
+       test_pack_objects_reused_all 3 1
+'
+
+test_expect_success 'feature.experimental implies multi-pack reuse' '
+       test_config feature.experimental true &&
+
+       test_pack_objects_reused_all 6 2
+'
+
+test_expect_success 'multi-pack reuse can be disabled with feature.experimental' '
+       test_config feature.experimental true &&
+       test_config pack.allowPackReuse single &&
+
+       test_pack_objects_reused_all 3 1
+'
 
 test_expect_success 'enable multi-pack reuse' '
        git config pack.allowPackReuse multi