@matheusbsbs / matheus-bagliano / commits / de3a864114
Fork 0

config: set pack.useSparse=true by default

The pack.useSparse config option was introduced by 3d036eb0 (pack-objects: create pack.useSparse setting, 2019-01-19) and was first available in v2.21.0. When enabled, the pack-objects process during 'git push' will use a sparse tree walk when deciding which trees and blobs to send to the remote. The algorithm was introduced by d5d2e93 (revision: implement sparse algorithm, 2019-01-16) and has been in production use by VFS for Git since around that time. The features.experimental config option also enabled pack.useSparse, so hopefully that has also increased exposure. It is worth noting that pack.useSparse has a possibility of sending more objects across a push, but requires a special arrangement of exact _copies_ across directories. There is a test in t5322-pack-objects-sparse.sh that demonstrates this possibility. This test uses the --sparse option to "git pack-objects" but we can make it implied by the config value to demonstrate that the default value has changed. While updating that test, I noticed that the documentation did not include an option for --no-sparse, which is now more important than it was before. Since the downside is unlikely but the upside is significant, set the default value of pack.useSparse to true. Remove it from the set of options implied by features.experimental. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Derrick Stolee committed Mar 20, 2020 at 12:38 UTC de3a864114291632c05e67bec4a316257c7ff97d
5 files changed +12 -11
Documentation/config/feature.txt
-3
@@ -12,9 +12,6 @@ feature.experimental::
12 setting if you are interested in providing feedback on experimental
13 features. The new default values are:
14 +
15 -* `pack.useSparse=true` uses a new algorithm when constructing a pack-file
16 -which can improve `git push` performance in repos with many files.
17 -+
15 * `fetch.negotiationAlgorithm=skipping` may improve fetch negotiation times by
16 skipping more commits at a time, reducing the number of round trips.
17 +
Documentation/config/pack.txt
+2 -2
@@ -119,8 +119,8 @@ pack.useSparse::
119 objects. This can have significant performance benefits when
120 computing a pack to send a small change. However, it is possible
121 that extra objects are added to the pack-file if the included
122 - commits contain certain types of direct renames. Default is `false`
123 - unless `feature.experimental` is enabled.
122 + commits contain certain types of direct renames. Default is
123 + `true`.
124
125 pack.writeBitmaps (deprecated)::
126 This is a deprecated synonym for `repack.writeBitmaps`.
Documentation/git-pack-objects.txt
+6 -4
@@ -14,7 +14,7 @@ SYNOPSIS
14 [--local] [--incremental] [--window=<n>] [--depth=<n>]
15 [--revs [--unpacked | --all]] [--keep-pack=<pack-name>]
16 [--stdout [--filter=<filter-spec>] | base-name]
17 - [--shallow] [--keep-true-parents] [--sparse] < object-list
17 + [--shallow] [--keep-true-parents] [--[no-]sparse] < object-list
18
19
20 DESCRIPTION
@@ -196,14 +196,16 @@ depth is 4095.
196 Add --no-reuse-object if you want to force a uniform compression
197 level on all data no matter the source.
198
199 ---sparse::
200 - Use the "sparse" algorithm to determine which objects to include in
199 +--[no-]sparse::
200 + Toggle the "sparse" algorithm to determine which objects to include in
201 the pack, when combined with the "--revs" option. This algorithm
202 only walks trees that appear in paths that introduce new objects.
203 This can have significant performance benefits when computing
204 a pack to send a small change. However, it is possible that extra
205 objects are added to the pack-file if the included commits contain
206 - certain types of direct renames.
206 + certain types of direct renames. If this option is not included,
207 + it defaults to the value of `pack.useSparse`, which is true unless
208 + otherwise specified.
209
210 --thin::
211 Create a "thin" pack by omitting the common objects between a
repo-settings.c
+2 -1
@@ -45,6 +45,8 @@ void prepare_repo_settings(struct repository *r)
45
46 if (!repo_config_get_bool(r, "pack.usesparse", &value))
47 r->settings.pack_use_sparse = value;
48 + UPDATE_DEFAULT_BOOL(r->settings.pack_use_sparse, 1);
49 +
50 if (!repo_config_get_bool(r, "feature.manyfiles", &value) && value) {
51 UPDATE_DEFAULT_BOOL(r->settings.index_version, 4);
52 UPDATE_DEFAULT_BOOL(r->settings.core_untracked_cache, UNTRACKED_CACHE_WRITE);
@@ -52,7 +54,6 @@ void prepare_repo_settings(struct repository *r)
54 if (!repo_config_get_bool(r, "fetch.writecommitgraph", &value))
55 r->settings.fetch_write_commit_graph = value;
56 if (!repo_config_get_bool(r, "feature.experimental", &value) && value) {
55 - UPDATE_DEFAULT_BOOL(r->settings.pack_use_sparse, 1);
57 UPDATE_DEFAULT_BOOL(r->settings.fetch_negotiation_algorithm, FETCH_NEGOTIATION_SKIPPING);
58 UPDATE_DEFAULT_BOOL(r->settings.fetch_write_commit_graph, 1);
59 }
t/t5322-pack-objects-sparse.sh
+2 -1
@@ -105,6 +105,7 @@ test_expect_success 'non-sparse pack-objects' '
105 test_cmp required_objects.txt nonsparse_required_objects.txt
106 '
107
108 +# --sparse is enabled by default by pack.useSparse
109 test_expect_success 'sparse pack-objects' '
110 git rev-parse \
111 topic1 \
@@ -112,7 +113,7 @@ test_expect_success 'sparse pack-objects' '
113 topic1:f3 \
114 topic1:f3/f4 \
115 topic1:f3/f4/data.txt | sort >expect_sparse_objects.txt &&
115 - git pack-objects --stdout --revs --sparse <packinput.txt >sparse.pack &&
116 + git pack-objects --stdout --revs <packinput.txt >sparse.pack &&
117 git index-pack -o sparse.idx sparse.pack &&
118 git show-index <sparse.idx | awk "{print \$2}" >sparse_objects.txt &&
119 test_cmp expect_sparse_objects.txt sparse_objects.txt