Skip to content

Commit 17194b1

Browse files
derrickstoleegitster
authored andcommitted
features: feature.manyFiles implies fast index writes
The recent addition of the index.skipHash config option allows index writes to speed up by skipping the hash computation for the trailing checksum. This is particularly critical for repositories with many files at HEAD, so add this config option to two cases where users in that scenario may opt-in to such behavior: 1. The feature.manyFiles config option enables some options that are helpful for repositories with many files at HEAD. 2. 'scalar register' and 'scalar reconfigure' set config options that optimize for large repositories. In both of these cases, set index.skipHash=true to gain this speedup. Add tests that demonstrate the proper way that index.skipHash=true can override feature.manyFiles=true. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent da9acde commit 17194b1

File tree

6 files changed

+22
-1
lines changed

6 files changed

+22
-1
lines changed

Documentation/config/feature.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ feature.manyFiles::
2323
working directory. With many files, commands such as `git status` and
2424
`git checkout` may be slow and these new defaults improve performance:
2525
+
26+
* `index.skipHash=true` speeds up index writes by not computing a trailing
27+
checksum. Note that this will cause Git versions earlier than 2.13.0 to
28+
refuse to parse the index and Git versions earlier than 2.40.0 will report
29+
a corrupted index during `git fsck`.
30+
+
2631
* `index.version=4` enables path-prefix compression in the index.
2732
+
2833
* `core.untrackedCache=true` enables the untracked cache. This setting assumes

read-cache.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2927,7 +2927,8 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
29272927

29282928
f = hashfd(tempfile->fd, tempfile->filename.buf);
29292929

2930-
repo_config_get_bool(r, "index.skiphash", &f->skip_hash);
2930+
prepare_repo_settings(r);
2931+
f->skip_hash = r->settings.index_skip_hash;
29312932

29322933
for (i = removed = extended = 0; i < entries; i++) {
29332934
if (cache[i]->ce_flags & CE_REMOVE)

repo-settings.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ void prepare_repo_settings(struct repository *r)
4747
}
4848
if (manyfiles) {
4949
r->settings.index_version = 4;
50+
r->settings.index_skip_hash = 1;
5051
r->settings.core_untracked_cache = UNTRACKED_CACHE_WRITE;
5152
}
5253

@@ -61,6 +62,7 @@ void prepare_repo_settings(struct repository *r)
6162
repo_cfg_bool(r, "pack.usesparse", &r->settings.pack_use_sparse, 1);
6263
repo_cfg_bool(r, "core.multipackindex", &r->settings.core_multi_pack_index, 1);
6364
repo_cfg_bool(r, "index.sparse", &r->settings.sparse_index, 0);
65+
repo_cfg_bool(r, "index.skiphash", &r->settings.index_skip_hash, r->settings.index_skip_hash);
6466

6567
/*
6668
* The GIT_TEST_MULTI_PACK_INDEX variable is special in that

repository.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ struct repo_settings {
4242
struct fsmonitor_settings *fsmonitor; /* lazily loaded */
4343

4444
int index_version;
45+
int index_skip_hash;
4546
enum untracked_cache_setting core_untracked_cache;
4647

4748
int pack_use_sparse;

scalar.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ static int set_recommended_config(int reconfigure)
143143
{ "credential.validate", "false", 1 }, /* GCM4W-only */
144144
{ "gc.auto", "0", 1 },
145145
{ "gui.GCWarning", "false", 1 },
146+
{ "index.skipHash", "false", 1 },
146147
{ "index.threads", "true", 1 },
147148
{ "index.version", "4", 1 },
148149
{ "merge.stat", "false", 1 },

t/t1600-index.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,17 @@ test_expect_success 'index.skipHash config option' '
7373
test_cmp expect hash &&
7474
git fsck &&
7575
76+
rm -f .git/index &&
77+
git -c feature.manyFiles=true add a &&
78+
test_trailing_hash .git/index >hash &&
79+
cmp expect hash &&
80+
81+
rm -f .git/index &&
82+
git -c feature.manyFiles=true \
83+
-c index.skipHash=false add a &&
84+
test_trailing_hash .git/index >hash &&
85+
! cmp expect hash &&
86+
7687
test_commit start &&
7788
git -c protocol.file.allow=always submodule add ./ sub &&
7889
git config index.skipHash false &&

0 commit comments

Comments
 (0)