Skip to content

Commit cdda0cc

Browse files
committed
Merge branch 'jn/eoie-ieot'
As the warning message shown by existing versions of Git for unknown index extensions is a bit too alarming, two new extensions are held back and not written by default for the upcoming release. * jn/eoie-ieot: index: make index.threads=true enable ieot and eoie ieot: default to not writing IEOT section eoie: default to not writing EOIE section
2 parents 7fab474 + 2a9dede commit cdda0cc

File tree

5 files changed

+69
-18
lines changed

5 files changed

+69
-18
lines changed

Documentation/config/index.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
index.recordEndOfIndexEntries::
2+
Specifies whether the index file should include an "End Of Index
3+
Entry" section. This reduces index load time on multiprocessor
4+
machines but produces a message "ignoring EOIE extension" when
5+
reading the index using Git versions before 2.20. Defaults to
6+
'true' if index.threads has been explicitly enabled, 'false'
7+
otherwise.
8+
9+
index.recordOffsetTable::
10+
Specifies whether the index file should include an "Index Entry
11+
Offset Table" section. This reduces index load time on
12+
multiprocessor machines but produces a message "ignoring IEOT
13+
extension" when reading the index using Git versions before 2.20.
14+
Defaults to 'true' if index.threads has been explicitly enabled,
15+
'false' otherwise.
16+
117
index.threads::
218
Specifies the number of threads to spawn when loading the index.
319
This is meant to reduce index load time on multiprocessor machines.

config.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2294,22 +2294,25 @@ int git_config_get_fsmonitor(void)
22942294
return 0;
22952295
}
22962296

2297-
int git_config_get_index_threads(void)
2297+
int git_config_get_index_threads(int *dest)
22982298
{
2299-
int is_bool, val = 0;
2299+
int is_bool, val;
23002300

23012301
val = git_env_ulong("GIT_TEST_INDEX_THREADS", 0);
2302-
if (val)
2303-
return val;
2302+
if (val) {
2303+
*dest = val;
2304+
return 0;
2305+
}
23042306

23052307
if (!git_config_get_bool_or_int("index.threads", &is_bool, &val)) {
23062308
if (is_bool)
2307-
return val ? 0 : 1;
2309+
*dest = val ? 0 : 1;
23082310
else
2309-
return val;
2311+
*dest = val;
2312+
return 0;
23102313
}
23112314

2312-
return 0; /* auto */
2315+
return 1;
23132316
}
23142317

23152318
NORETURN

config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,11 @@ extern int git_config_get_bool(const char *key, int *dest);
246246
extern int git_config_get_bool_or_int(const char *key, int *is_bool, int *dest);
247247
extern int git_config_get_maybe_bool(const char *key, int *dest);
248248
extern int git_config_get_pathname(const char *key, const char **dest);
249+
extern int git_config_get_index_threads(int *dest);
249250
extern int git_config_get_untracked_cache(void);
250251
extern int git_config_get_split_index(void);
251252
extern int git_config_get_max_percent_split_change(void);
252253
extern int git_config_get_fsmonitor(void);
253-
extern int git_config_get_index_threads(void);
254254

255255
/* This dies if the configured or default date is in the future */
256256
extern int git_config_get_expiry(const char *key, const char **output);

read-cache.c

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2176,7 +2176,8 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
21762176

21772177
src_offset = sizeof(*hdr);
21782178

2179-
nr_threads = git_config_get_index_threads();
2179+
if (git_config_get_index_threads(&nr_threads))
2180+
nr_threads = 1;
21802181

21812182
/* TODO: does creating more threads than cores help? */
21822183
if (!nr_threads) {
@@ -2689,6 +2690,36 @@ void update_index_if_able(struct index_state *istate, struct lock_file *lockfile
26892690
rollback_lock_file(lockfile);
26902691
}
26912692

2693+
static int record_eoie(void)
2694+
{
2695+
int val;
2696+
2697+
if (!git_config_get_bool("index.recordendofindexentries", &val))
2698+
return val;
2699+
2700+
/*
2701+
* As a convenience, the end of index entries extension
2702+
* used for threading is written by default if the user
2703+
* explicitly requested threaded index reads.
2704+
*/
2705+
return !git_config_get_index_threads(&val) && val != 1;
2706+
}
2707+
2708+
static int record_ieot(void)
2709+
{
2710+
int val;
2711+
2712+
if (!git_config_get_bool("index.recordoffsettable", &val))
2713+
return val;
2714+
2715+
/*
2716+
* As a convenience, the offset table used for threading is
2717+
* written by default if the user explicitly requested
2718+
* threaded index reads.
2719+
*/
2720+
return !git_config_get_index_threads(&val) && val != 1;
2721+
}
2722+
26922723
/*
26932724
* On success, `tempfile` is closed. If it is the temporary file
26942725
* of a `struct lock_file`, we will therefore effectively perform
@@ -2747,12 +2778,10 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
27472778
if (ce_write(&c, newfd, &hdr, sizeof(hdr)) < 0)
27482779
return -1;
27492780

2750-
if (HAVE_THREADS)
2751-
nr_threads = git_config_get_index_threads();
2752-
else
2781+
if (!HAVE_THREADS || git_config_get_index_threads(&nr_threads))
27532782
nr_threads = 1;
27542783

2755-
if (nr_threads != 1) {
2784+
if (nr_threads != 1 && record_ieot()) {
27562785
int ieot_blocks, cpus;
27572786

27582787
/*
@@ -2936,7 +2965,7 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
29362965
* read. Write it out regardless of the strip_extensions parameter as we need it
29372966
* when loading the shared index.
29382967
*/
2939-
if (offset) {
2968+
if (offset && record_eoie()) {
29402969
struct strbuf sb = STRBUF_INIT;
29412970

29422971
write_eoie_extension(&sb, &eoie_c, offset);

t/t1700-split-index.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,17 @@ test_expect_success 'enable split index' '
2525
git update-index --split-index &&
2626
test-tool dump-split-index .git/index >actual &&
2727
indexversion=$(test-tool index-version <.git/index) &&
28+
29+
# NEEDSWORK: Stop hard-coding checksums.
2830
if test "$indexversion" = "4"
2931
then
30-
own=3527df833c6c100d3d1d921a9a782d62a8be4b58
31-
base=746f7ab2ed44fb839efdfbffcf399d0b113fb4cb
32+
own=432ef4b63f32193984f339431fd50ca796493569
33+
base=508851a7f0dfa8691e9f69c7f055865389012491
3234
else
33-
own=5e9b60117ece18da410ddecc8b8d43766a0e4204
34-
base=4370042739b31cd17a5c5cd6043a77c9a00df113
35+
own=8299b0bcd1ac364e5f1d7768efb62fa2da79a339
36+
base=39d890139ee5356c7ef572216cebcd27aa41f9df
3537
fi &&
38+
3639
cat >expect <<-EOF &&
3740
own $own
3841
base $base

0 commit comments

Comments
 (0)