Merge branch 'jn/eoie-ieot'
authorJunio C Hamano <gitster@pobox.com>
Wed, 21 Nov 2018 11:39:02 +0000 (20:39 +0900)
committerJunio C Hamano <gitster@pobox.com>
Wed, 21 Nov 2018 11:39:02 +0000 (20:39 +0900)
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

Documentation/config/index.txt
config.c
config.h
read-cache.c
t/t1700-split-index.sh
index 4b94b6bedc03071109998ee7d27cf50c53e4194b..f18150304106891ad388a7620594937b43e7615e 100644 (file)
@@ -1,3 +1,19 @@
+index.recordEndOfIndexEntries::
+       Specifies whether the index file should include an "End Of Index
+       Entry" section. This reduces index load time on multiprocessor
+       machines but produces a message "ignoring EOIE extension" when
+       reading the index using Git versions before 2.20. Defaults to
+       'true' if index.threads has been explicitly enabled, 'false'
+       otherwise.
+
+index.recordOffsetTable::
+       Specifies whether the index file should include an "Index Entry
+       Offset Table" section. This reduces index load time on
+       multiprocessor machines but produces a message "ignoring IEOT
+       extension" when reading the index using Git versions before 2.20.
+       Defaults to 'true' if index.threads has been explicitly enabled,
+       'false' otherwise.
+
 index.threads::
        Specifies the number of threads to spawn when loading the index.
        This is meant to reduce index load time on multiprocessor machines.
index 04286f7717645c6812c7236a282c34f5ad353eb7..ff521eb27ad243b27c7bd95f3ad7a1b777a4ae00 100644 (file)
--- a/config.c
+++ b/config.c
@@ -2294,22 +2294,25 @@ int git_config_get_fsmonitor(void)
        return 0;
 }
 
-int git_config_get_index_threads(void)
+int git_config_get_index_threads(int *dest)
 {
-       int is_bool, val = 0;
+       int is_bool, val;
 
        val = git_env_ulong("GIT_TEST_INDEX_THREADS", 0);
-       if (val)
-               return val;
+       if (val) {
+               *dest = val;
+               return 0;
+       }
 
        if (!git_config_get_bool_or_int("index.threads", &is_bool, &val)) {
                if (is_bool)
-                       return val ? 0 : 1;
+                       *dest = val ? 0 : 1;
                else
-                       return val;
+                       *dest = val;
+               return 0;
        }
 
-       return 0; /* auto */
+       return 1;
 }
 
 NORETURN
index a06027e69b9d453c6e4277968622aa9bd6ae92b1..ee5d3fa7b4264f24e8b36c2e1154546ae626c191 100644 (file)
--- a/config.h
+++ b/config.h
@@ -246,11 +246,11 @@ extern int git_config_get_bool(const char *key, int *dest);
 extern int git_config_get_bool_or_int(const char *key, int *is_bool, int *dest);
 extern int git_config_get_maybe_bool(const char *key, int *dest);
 extern int git_config_get_pathname(const char *key, const char **dest);
+extern int git_config_get_index_threads(int *dest);
 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 4ca81286c00c57484a3567a56fa4d441725708da..42de59a163c1f88580b88281dfc1572ca0dcd5f0 100644 (file)
@@ -2176,7 +2176,8 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
 
        src_offset = sizeof(*hdr);
 
-       nr_threads = git_config_get_index_threads();
+       if (git_config_get_index_threads(&nr_threads))
+               nr_threads = 1;
 
        /* TODO: does creating more threads than cores help? */
        if (!nr_threads) {
@@ -2689,6 +2690,36 @@ void update_index_if_able(struct index_state *istate, struct lock_file *lockfile
                rollback_lock_file(lockfile);
 }
 
+static int record_eoie(void)
+{
+       int val;
+
+       if (!git_config_get_bool("index.recordendofindexentries", &val))
+               return val;
+
+       /*
+        * As a convenience, the end of index entries extension
+        * used for threading is written by default if the user
+        * explicitly requested threaded index reads.
+        */
+       return !git_config_get_index_threads(&val) && val != 1;
+}
+
+static int record_ieot(void)
+{
+       int val;
+
+       if (!git_config_get_bool("index.recordoffsettable", &val))
+               return val;
+
+       /*
+        * As a convenience, the offset table used for threading is
+        * written by default if the user explicitly requested
+        * threaded index reads.
+        */
+       return !git_config_get_index_threads(&val) && val != 1;
+}
+
 /*
  * On success, `tempfile` is closed. If it is the temporary file
  * 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,
        if (ce_write(&c, newfd, &hdr, sizeof(hdr)) < 0)
                return -1;
 
-       if (HAVE_THREADS)
-               nr_threads = git_config_get_index_threads();
-       else
+       if (!HAVE_THREADS || git_config_get_index_threads(&nr_threads))
                nr_threads = 1;
 
-       if (nr_threads != 1) {
+       if (nr_threads != 1 && record_ieot()) {
                int ieot_blocks, cpus;
 
                /*
@@ -2936,7 +2965,7 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
         * read.  Write it out regardless of the strip_extensions parameter as we need it
         * when loading the shared index.
         */
-       if (offset) {
+       if (offset && record_eoie()) {
                struct strbuf sb = STRBUF_INIT;
 
                write_eoie_extension(&sb, &eoie_c, offset);
index 2ac47aa0e4a7164cd06037496832a1744990a774..0cbac64e28b26eebe2805c51748be99d647e039d 100755 (executable)
@@ -25,14 +25,17 @@ test_expect_success 'enable split index' '
        git update-index --split-index &&
        test-tool dump-split-index .git/index >actual &&
        indexversion=$(test-tool index-version <.git/index) &&
+
+       # NEEDSWORK: Stop hard-coding checksums.
        if test "$indexversion" = "4"
        then
-               own=3527df833c6c100d3d1d921a9a782d62a8be4b58
-               base=746f7ab2ed44fb839efdfbffcf399d0b113fb4cb
+               own=432ef4b63f32193984f339431fd50ca796493569
+               base=508851a7f0dfa8691e9f69c7f055865389012491
        else
-               own=5e9b60117ece18da410ddecc8b8d43766a0e4204
-               base=4370042739b31cd17a5c5cd6043a77c9a00df113
+               own=8299b0bcd1ac364e5f1d7768efb62fa2da79a339
+               base=39d890139ee5356c7ef572216cebcd27aa41f9df
        fi &&
+
        cat >expect <<-EOF &&
        own $own
        base $base