summaryrefslogtreecommitdiff
path: root/read-cache.c
diff options
context:
space:
mode:
authorBen Peart <benpeart@microsoft.com>2018-10-29 20:41:59 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-10-30 02:28:39 (GMT)
commit99ce720c338ebeb37331bd98f724569837c74d0d (patch)
treece7d8197078f0ab98d9e599d2ef46a167e35dd17 /read-cache.c
parentc670b1f876521c9f7cd40184bf7ed05aad843433 (diff)
downloadgit-99ce720c338ebeb37331bd98f724569837c74d0d.zip
git-99ce720c338ebeb37331bd98f724569837c74d0d.tar.gz
git-99ce720c338ebeb37331bd98f724569837c74d0d.tar.bz2
speed up refresh_index() by utilizing preload_index()
Speed up refresh_index() by utilizing preload_index() to do most of the work spread across multiple threads. This works because most cache entries will get marked CE_UPTODATE so that refresh_cache_ent() can bail out early when called from within refresh_index(). On a Windows repo with ~200K files, this drops refresh times from 6.64 seconds to 2.87 seconds for a savings of 57%. Signed-off-by: Ben Peart <benpeart@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'read-cache.c')
-rw-r--r--read-cache.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/read-cache.c b/read-cache.c
index d579582..53733d6 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1496,6 +1496,12 @@ int refresh_index(struct index_state *istate, unsigned int flags,
typechange_fmt = (in_porcelain ? "T\t%s\n" : "%s needs update\n");
added_fmt = (in_porcelain ? "A\t%s\n" : "%s needs update\n");
unmerged_fmt = (in_porcelain ? "U\t%s\n" : "%s: needs merge\n");
+ /*
+ * Use the multi-threaded preload_index() to refresh most of the
+ * cache entries quickly then in the single threaded loop below,
+ * we only have to do the special cases that are left.
+ */
+ preload_index(istate, pathspec, 0);
for (i = 0; i < istate->cache_nr; i++) {
struct cache_entry *ce, *new_entry;
int cache_errno = 0;