From: git@jeffhostetler.com
To: git@vger.kernel.org
Cc: gitster@pobox.com, peff@peff.net,
Jeff Hostetler <jeffhost@microsoft.com>
Subject: [PATCH v3 1/2] read-cache: core.checksumindex
Date: Tue, 28 Mar 2017 19:07:31 +0000 [thread overview]
Message-ID: <20170328190732.59486-2-git@jeffhostetler.com> (raw)
In-Reply-To: <20170328190732.59486-1-git@jeffhostetler.com>
From: Jeff Hostetler <jeffhost@microsoft.com>
Teach git to skip verification of the index SHA in verify_hdr()
in read_index().
This is a performance optimization. The index file SHA verification
can be considered an ancient relic from the early days of git and only
useful for detecting disk corruption. For small repositories, this
SHA calculation is not that significant, but for gigantic repositories
this calculation adds significant time to every command.
Added "core.checksumindex" to enable/disable the SHA verification.
Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
---
read-cache.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/read-cache.c b/read-cache.c
index 9054369..2ab4b74 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1376,12 +1376,24 @@ static int verify_hdr(struct cache_header *hdr, unsigned long size)
git_SHA_CTX c;
unsigned char sha1[20];
int hdr_version;
+ int do_checksum = 0;
if (hdr->hdr_signature != htonl(CACHE_SIGNATURE))
return error("bad signature");
hdr_version = ntohl(hdr->hdr_version);
if (hdr_version < INDEX_FORMAT_LB || INDEX_FORMAT_UB < hdr_version)
return error("bad index version %d", hdr_version);
+
+ /*
+ * Since we run very early in command startup, git_config()
+ * may not have been called yet and the various "core_*"
+ * global variables haven't been set. So look it up
+ * explicitly.
+ */
+ git_config_get_bool("core.checksumindex", &do_checksum);
+ if (!do_checksum)
+ return 0;
+
git_SHA1_Init(&c);
git_SHA1_Update(&c, hdr, size - 20);
git_SHA1_Final(sha1, &c);
--
2.9.3
next prev parent reply other threads:[~2017-03-28 19:08 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-28 19:07 [PATCH v3 0/2] read-cache: call verify_hdr() in a background thread git
2017-03-28 19:07 ` git [this message]
2017-03-28 19:07 ` [PATCH v3 2/2] test-core-checksum-index: core.checksumindex test helper git
2017-03-28 19:16 ` [PATCH v3 0/2] read-cache: call verify_hdr() in a background thread Jeff King
2017-03-28 19:50 ` Jeff Hostetler
2017-03-28 19:56 ` Jeff King
2017-03-30 19:49 ` Junio C Hamano
2017-03-30 19:58 ` Jeff King
2017-03-30 20:44 ` Junio C Hamano
2017-03-31 13:20 ` Jeff Hostetler
2017-03-30 20:06 ` Thomas Gummerer
2017-03-30 20:39 ` Jeff King
2017-03-31 13:23 ` Jeff Hostetler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170328190732.59486-2-git@jeffhostetler.com \
--to=git@jeffhostetler.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jeffhost@microsoft.com \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 NNTP newsgroup(s).