Skip to content

Commit e27bfaa

Browse files
committed
Merge branch 'bp/read-cache-parallel'
A new extension to the index file has been introduced, which allows the file to be read in parallel. * bp/read-cache-parallel: read-cache: load cache entries on worker threads ieot: add Index Entry Offset Table (IEOT) extension read-cache: load cache extensions on a worker thread config: add new index.threads config setting eoie: add End of Index Entry (EOIE) extension read-cache: clean up casting and byte decoding read-cache.c: optimize reading index format v4
2 parents 340fde6 + 77ff112 commit e27bfaa

File tree

7 files changed

+739
-120
lines changed

7 files changed

+739
-120
lines changed

Documentation/config.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2149,6 +2149,13 @@ imap::
21492149
The configuration variables in the 'imap' section are described
21502150
in linkgit:git-imap-send[1].
21512151

2152+
index.threads::
2153+
Specifies the number of threads to spawn when loading the index.
2154+
This is meant to reduce index load time on multiprocessor machines.
2155+
Specifying 0 or 'true' will cause Git to auto-detect the number of
2156+
CPU's and set the number of threads accordingly. Specifying 1 or
2157+
'false' will disable multithreading. Defaults to 'true'.
2158+
21522159
index.version::
21532160
Specify the version with which new index files should be
21542161
initialized. This does not affect existing repositories.

Documentation/technical/index-format.txt

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,3 +314,44 @@ The remaining data of each directory block is grouped by type:
314314

315315
- An ewah bitmap, the n-th bit indicates whether the n-th index entry
316316
is not CE_FSMONITOR_VALID.
317+
318+
== End of Index Entry
319+
320+
The End of Index Entry (EOIE) is used to locate the end of the variable
321+
length index entries and the begining of the extensions. Code can take
322+
advantage of this to quickly locate the index extensions without having
323+
to parse through all of the index entries.
324+
325+
Because it must be able to be loaded before the variable length cache
326+
entries and other index extensions, this extension must be written last.
327+
The signature for this extension is { 'E', 'O', 'I', 'E' }.
328+
329+
The extension consists of:
330+
331+
- 32-bit offset to the end of the index entries
332+
333+
- 160-bit SHA-1 over the extension types and their sizes (but not
334+
their contents). E.g. if we have "TREE" extension that is N-bytes
335+
long, "REUC" extension that is M-bytes long, followed by "EOIE",
336+
then the hash would be:
337+
338+
SHA-1("TREE" + <binary representation of N> +
339+
"REUC" + <binary representation of M>)
340+
341+
== Index Entry Offset Table
342+
343+
The Index Entry Offset Table (IEOT) is used to help address the CPU
344+
cost of loading the index by enabling multi-threading the process of
345+
converting cache entries from the on-disk format to the in-memory format.
346+
The signature for this extension is { 'I', 'E', 'O', 'T' }.
347+
348+
The extension consists of:
349+
350+
- 32-bit version (currently 1)
351+
352+
- A number of index offset entries each consisting of:
353+
354+
- 32-bit offset from the begining of the file to the first cache entry
355+
in this block of entries.
356+
357+
- 32-bit count of cache entries in this block

config.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2289,6 +2289,24 @@ int git_config_get_fsmonitor(void)
22892289
return 0;
22902290
}
22912291

2292+
int git_config_get_index_threads(void)
2293+
{
2294+
int is_bool, val = 0;
2295+
2296+
val = git_env_ulong("GIT_TEST_INDEX_THREADS", 0);
2297+
if (val)
2298+
return val;
2299+
2300+
if (!git_config_get_bool_or_int("index.threads", &is_bool, &val)) {
2301+
if (is_bool)
2302+
return val ? 0 : 1;
2303+
else
2304+
return val;
2305+
}
2306+
2307+
return 0; /* auto */
2308+
}
2309+
22922310
NORETURN
22932311
void git_die_config_linenr(const char *key, const char *filename, int linenr)
22942312
{

config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ extern int git_config_get_untracked_cache(void);
250250
extern int git_config_get_split_index(void);
251251
extern int git_config_get_max_percent_split_change(void);
252252
extern int git_config_get_fsmonitor(void);
253+
extern int git_config_get_index_threads(void);
253254

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

0 commit comments

Comments
 (0)