Skip to content

Commit

Permalink
Merge branch 'bp/read-cache-parallel'
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gitster committed Oct 19, 2018
2 parents 340fde6 + 77ff112 commit e27bfaa
Show file tree
Hide file tree
Showing 7 changed files with 739 additions and 120 deletions.
7 changes: 7 additions & 0 deletions Documentation/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2149,6 +2149,13 @@ imap::
The configuration variables in the 'imap' section are described
in linkgit:git-imap-send[1].

index.threads::
Specifies the number of threads to spawn when loading the index.
This is meant to reduce index load time on multiprocessor machines.
Specifying 0 or 'true' will cause Git to auto-detect the number of
CPU's and set the number of threads accordingly. Specifying 1 or
'false' will disable multithreading. Defaults to 'true'.

index.version::
Specify the version with which new index files should be
initialized. This does not affect existing repositories.
Expand Down
41 changes: 41 additions & 0 deletions Documentation/technical/index-format.txt
Original file line number Diff line number Diff line change
Expand Up @@ -314,3 +314,44 @@ The remaining data of each directory block is grouped by type:

- An ewah bitmap, the n-th bit indicates whether the n-th index entry
is not CE_FSMONITOR_VALID.

== End of Index Entry

The End of Index Entry (EOIE) is used to locate the end of the variable
length index entries and the begining of the extensions. Code can take
advantage of this to quickly locate the index extensions without having
to parse through all of the index entries.

Because it must be able to be loaded before the variable length cache
entries and other index extensions, this extension must be written last.
The signature for this extension is { 'E', 'O', 'I', 'E' }.

The extension consists of:

- 32-bit offset to the end of the index entries

- 160-bit SHA-1 over the extension types and their sizes (but not
their contents). E.g. if we have "TREE" extension that is N-bytes
long, "REUC" extension that is M-bytes long, followed by "EOIE",
then the hash would be:

SHA-1("TREE" + <binary representation of N> +
"REUC" + <binary representation of M>)

== Index Entry Offset Table

The Index Entry Offset Table (IEOT) is used to help address the CPU
cost of loading the index by enabling multi-threading the process of
converting cache entries from the on-disk format to the in-memory format.
The signature for this extension is { 'I', 'E', 'O', 'T' }.

The extension consists of:

- 32-bit version (currently 1)

- A number of index offset entries each consisting of:

- 32-bit offset from the begining of the file to the first cache entry
in this block of entries.

- 32-bit count of cache entries in this block
18 changes: 18 additions & 0 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -2289,6 +2289,24 @@ int git_config_get_fsmonitor(void)
return 0;
}

int git_config_get_index_threads(void)
{
int is_bool, val = 0;

val = git_env_ulong("GIT_TEST_INDEX_THREADS", 0);
if (val)
return val;

if (!git_config_get_bool_or_int("index.threads", &is_bool, &val)) {
if (is_bool)
return val ? 0 : 1;
else
return val;
}

return 0; /* auto */
}

NORETURN
void git_die_config_linenr(const char *key, const char *filename, int linenr)
{
Expand Down
1 change: 1 addition & 0 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ extern int git_config_get_untracked_cache(void);
extern int git_config_get_split_index(void);
extern int git_config_get_max_percent_split_change(void);
extern int git_config_get_fsmonitor(void);
extern int git_config_get_index_threads(void);

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

0 comments on commit e27bfaa

Please sign in to comment.