git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH v1] read_index_from(): Skip verification of the cache entry order to speed index loading
@ 2017-10-18 14:27 Ben Peart
  2017-10-19  5:22 ` Junio C Hamano
  2017-10-24 14:45 ` [PATCH v2] " Ben Peart
  0 siblings, 2 replies; 18+ messages in thread
From: Ben Peart @ 2017-10-18 14:27 UTC (permalink / raw)
  To: git; +Cc: jeffhost, gitster, t.gummerer, mhagger, Ben Peart

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>
---

Notes:
    Base Ref:
    Web-Diff: https://github.com/benpeart/git/commit/54fa9cf954
    Checkout: git fetch https://github.com/benpeart/git verify_ce_order-v1 && git checkout 54fa9cf954

 builtin/fsck.c | 1 +
 cache.h        | 1 +
 read-cache.c   | 6 ++++++
 3 files changed, 8 insertions(+)

diff --git a/builtin/fsck.c b/builtin/fsck.c
index d18244ab54..81cc5ad78d 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -763,6 +763,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
 
 	if (keep_cache_objects) {
 		verify_index_checksum = 1;
+		verify_ce_order = 1;
 		read_cache();
 		for (i = 0; i < active_nr; i++) {
 			unsigned int mode;
diff --git a/cache.h b/cache.h
index 5e2c9512ff..4a4f879061 100644
--- a/cache.h
+++ b/cache.h
@@ -721,6 +721,7 @@ extern int hold_locked_index(struct lock_file *, int);
 extern void set_alternate_index_output(const char *);
 
 extern int verify_index_checksum;
+extern int verify_ce_order;
 
 /* Environment bits from configuration mechanism */
 extern int trust_executable_bit;
diff --git a/read-cache.c b/read-cache.c
index b64610c400..32743da157 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1513,6 +1513,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;
@@ -1698,6 +1701,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];

base-commit: 46309c695b080648f8c0ea5e2d1fd7387ee7f044
-- 
2.14.1.windows.1.1034.g0776750557


^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2017-11-01  6:09 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-18 14:27 [PATCH v1] read_index_from(): Skip verification of the cache entry order to speed index loading Ben Peart
2017-10-19  5:22 ` Junio C Hamano
2017-10-19 15:12   ` Ben Peart
2017-10-19 16:05     ` Jeff King
2017-10-20  1:14       ` Junio C Hamano
2017-10-19 22:14     ` Stefan Beller
2017-10-20 12:47       ` Johannes Schindelin
2017-10-20 18:53         ` Stefan Beller
2017-10-21  1:55           ` Junio C Hamano
2017-10-24 14:45 ` [PATCH v2] " Ben Peart
2017-10-30 12:48   ` Ben Peart
2017-10-30 18:03     ` Jeff King
2017-10-31  0:33       ` Alex Vandiver
2017-10-31 13:01         ` Ben Peart
2017-10-31 17:10           ` Jeff King
2017-11-01  6:09             ` Junio C Hamano
2017-10-31  1:49     ` Junio C Hamano
2017-10-31 12:51       ` Ben Peart

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).