summaryrefslogtreecommitdiff
path: root/read-cache.c
diff options
context:
space:
mode:
authorBen Peart <benpeart@microsoft.com>2017-10-18 14:27:25 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-11-08 01:39:41 (GMT)
commit00ec50e56d136de41f43c33f39cdbee83f3e4458 (patch)
tree31f42fd87d978a2d4d3515d7bfa916e4427eb8c7 /read-cache.c
parentfc849d8d6b90e5c1e0c37bc0d60dd92b2fe7347f (diff)
downloadgit-00ec50e56d136de41f43c33f39cdbee83f3e4458.zip
git-00ec50e56d136de41f43c33f39cdbee83f3e4458.tar.gz
git-00ec50e56d136de41f43c33f39cdbee83f3e4458.tar.bz2
read_index_from(): speed index loading by skipping verification of the entry order
There is code in post_read_index_from() to catch out of order entries when reading an index file. This order verification is ~13% of the cost of every call to read_index_from(). Update check_ce_order() so that it skips this verification unless the "verify_ce_order" global variable is set. Teach fsck to force this verification. The effect can be seen using t/perf/p0002-read-cache.sh: Test HEAD HEAD~1 -------------------------------------------------------------------------------------- 0002.1: read_cache/discard_cache 1000 times 0.41(0.04+0.04) 0.50(0.00+0.10) +22.0% 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 5e6d24d..945a377 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1509,6 +1509,9 @@ struct ondisk_cache_entry_extended {
/* Allow fsck to force verification of the index checksum. */
int verify_index_checksum;
+/* Allow fsck to force verification of the cache entry order. */
+int verify_ce_order;
+
static int verify_hdr(struct cache_header *hdr, unsigned long size)
{
git_SHA_CTX c;
@@ -1666,6 +1669,9 @@ static void check_ce_order(struct index_state *istate)
{
unsigned int i;
+ if (!verify_ce_order)
+ return;
+
for (i = 1; i < istate->cache_nr; i++) {
struct cache_entry *ce = istate->cache[i - 1];
struct cache_entry *next_ce = istate->cache[i];