]> git.ipfire.org Git - thirdparty/git.git/commitdiff
config: add new index.threads config setting
authorBen Peart <benpeart@microsoft.com>
Wed, 10 Oct 2018 15:59:35 +0000 (11:59 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 11 Oct 2018 06:32:48 +0000 (15:32 +0900)
Add support for a new index.threads config setting which will be used to
control the threading code in do_read_index().  A value of 0 will tell the
index code to automatically determine the correct number of threads to use.
A value of 1 will make the code single threaded.  A value greater than 1
will set the maximum number of threads to use.

For testing purposes, this setting can be overwritten by setting the
GIT_TEST_INDEX_THREADS=<n> environment variable to a value greater than 0.

Signed-off-by: Ben Peart <benpeart@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/config.txt
config.c
config.h
t/README
t/t1700-split-index.sh

index ad0f4510c39c977bc95b41776eda4088d7a89885..8fd973b76b44a0d3b1bd66236894cd4e9bdd88cb 100644 (file)
@@ -2413,6 +2413,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.
index 3461993f0af665d64b48d16915fc2cd017634377..2ee29f6f86057edd5459ee34667f959dc3df0db6 100644 (file)
--- a/config.c
+++ b/config.c
@@ -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)
 {
index ab46e0165d8ffa782a796d0e2b23337aa9004b51..a06027e69b9d453c6e4277968622aa9bd6ae92b1 100644 (file)
--- a/config.h
+++ b/config.h
@@ -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);
index 3ea6c854606056e1a7d9431dd59518d817768527..8f5c0620eae414eaf55da6ab299f3fc00fc8dd14 100644 (file)
--- a/t/README
+++ b/t/README
@@ -327,6 +327,11 @@ GIT_TEST_COMMIT_GRAPH=<boolean>, when true, forces the commit-graph to
 be written after every 'git commit' command, and overrides the
 'core.commitGraph' setting to true.
 
+GIT_TEST_INDEX_THREADS=<n> enables exercising the multi-threaded loading
+of the index for the whole test suite by bypassing the default number of
+cache entries and thread minimums. Setting this to 1 will make the
+index loading single threaded.
+
 Naming Tests
 ------------
 
index 8e17f8e7a043fa38c14f94193df2f79fc2139cd1..ef9349bd70baf40059a1559e9c856584c39bf53f 100755 (executable)
@@ -6,7 +6,12 @@ test_description='split index mode tests'
 
 # We need total control of index splitting here
 sane_unset GIT_TEST_SPLIT_INDEX
+
+# Testing a hard coded SHA against an index with an extension
+# that can vary from run to run is problematic so we disable
+# those extensions.
 sane_unset GIT_FSMONITOR_TEST
+sane_unset GIT_TEST_INDEX_THREADS
 
 test_expect_success 'enable split index' '
        git config splitIndex.maxPercentChange 100 &&