Enable the filesystem cache (fscache) in refresh_index().

On file systems that support it, this can dramatically speed up operations
like add, commit, describe, rebase, reset, rm that would otherwise have to
lstat() every file to "re-match" the stat information in the index to that
of the file system.

On a synthetic repo with 1M files, "git reset" dropped from 52.02 seconds to
14.42 seconds for a savings of 72%.

Signed-off-by: Ben Peart <benpeart@microsoft.com>
This commit is contained in:
Ben Peart 2018-09-07 11:39:57 -04:00 коммит произвёл Johannes Schindelin
Родитель 80f4a28a2c
Коммит 1016bf009b
1 изменённых файлов: 2 добавлений и 0 удалений

Просмотреть файл

@ -1505,6 +1505,7 @@ 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";
enable_fscache(1);
/*
* Use the multi-threaded preload_index() to refresh most of the
* cache entries quickly then in the single threaded loop below,
@ -1582,6 +1583,7 @@ int refresh_index(struct index_state *istate, unsigned int flags,
stop_progress(&progress);
}
trace_performance_leave("refresh index");
enable_fscache(0);
return has_errors;
}