From: git@jeffhostetler.com
To: git@vger.kernel.org
Cc: gitster@pobox.com, peff@peff.net,
Jeff Hostetler <jeffhost@microsoft.com>
Subject: [PATCH v2 1/2] read-cache: skip index SHA verification
Date: Mon, 27 Mar 2017 21:09:38 +0000 [thread overview]
Message-ID: <1490648979-49580-2-git-send-email-git@jeffhostetler.com> (raw)
In-Reply-To: <1490648979-49580-1-git-send-email-git@jeffhostetler.com>
From: Jeff Hostetler <jeffhost@microsoft.com>
Teach git to skip verification of the index SHA 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.
I added a global "skip_verify_index" variable to control this and
allow it to be tested.
I did not create a config setting for this because of chicken-n-egg
problems with the loading the config and the index.
Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
---
cache.h | 5 +++++
read-cache.c | 6 ++++++
2 files changed, 11 insertions(+)
diff --git a/cache.h b/cache.h
index 80b6372..4e9182f 100644
--- a/cache.h
+++ b/cache.h
@@ -740,6 +740,11 @@ extern int protect_ntfs;
extern int git_db_env, git_index_env, git_graft_env, git_common_dir_env;
/*
+ * When set, skip verification of the index SHA in read_index().
+ */
+extern int skip_verify_index;
+
+/*
* Include broken refs in all ref iterations, which will
* generally choke dangerous operations rather than letting
* them silently proceed without taking the broken ref into
diff --git a/read-cache.c b/read-cache.c
index 9054369..1ca69c3 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -46,6 +46,8 @@
struct index_state the_index;
static const char *alternate_index_output;
+int skip_verify_index = 1;
+
static void set_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)
{
istate->cache[nr] = ce;
@@ -1382,6 +1384,10 @@ static int verify_hdr(struct cache_header *hdr, unsigned long size)
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);
+
+ if (skip_verify_index)
+ return 0;
+
git_SHA1_Init(&c);
git_SHA1_Update(&c, hdr, size - 20);
git_SHA1_Final(sha1, &c);
--
2.7.4
next prev parent reply other threads:[~2017-03-27 21:09 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-27 21:09 [PATCH v2 0/2] read-cache: call verify_hdr() in a background thread git
2017-03-27 21:09 ` git [this message]
2017-03-27 22:44 ` [PATCH v2 1/2] read-cache: skip index SHA verification Jeff King
2017-03-27 23:32 ` Jonathan Nieder
2017-03-27 23:39 ` Jeff King
2017-03-28 15:27 ` Jeff Hostetler
2017-03-28 15:37 ` Jeff King
2017-03-27 21:09 ` [PATCH v2 2/2] skip_verify_index: helper test git
2017-03-27 22:45 ` [PATCH v2 0/2] read-cache: call verify_hdr() in a background thread Jeff King
2017-03-28 15:30 ` 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=1490648979-49580-2-git-send-email-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).