From: Thomas Rast <trast@inf.ethz.ch>
To: <git@vger.kernel.org>
Cc: "Junio C Hamano" <gitster@pobox.com>,
"Ramkumar Ramachandra" <artagnon@gmail.com>,
"Alex Bennée" <kernel-hacker@bennee.com>,
"Antoine Pelisse" <apelisse@gmail.com>,
"John Keeping" <john@keeping.me.uk>,
"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 2/2] lookup_commit_reference_gently: do not read non-{tag,commit}
Date: Thu, 30 May 2013 22:00:23 +0200 [thread overview]
Message-ID: <5cc40825d5b4fb3382e4c054c49adf5e6b6fe110.1369943791.git.trast@inf.ethz.ch> (raw)
In-Reply-To: <2d926e4dbd218b2305f50652c00a5c1d87e81208.1369943791.git.trast@inf.ethz.ch>
lookup_commit_reference_gently unconditionally parses the object given
to it. This slows down git-describe a lot if you have a repository
with large tagged blobs in it: parse_object() will read the entire
blob and verify that its sha1 matches, only to then throw it away.
Speed it up by checking the type with sha1_object_info() prior to
unpacking.
The reason that deref_tag() does not need the same fix is a bit
subtle: parse_tag_buffer() does not fill the 'tagged' member of the
tag struct if the tagged object is a blob.
Reported-by: Alex Bennée <kernel-hacker@bennee.com>
Signed-off-by: Thomas Rast <trast@inf.ethz.ch>
---
commit.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/commit.c b/commit.c
index 888e02a..00e8d4a 100644
--- a/commit.c
+++ b/commit.c
@@ -31,8 +31,12 @@ static struct commit *check_commit(struct object *obj,
struct commit *lookup_commit_reference_gently(const unsigned char *sha1,
int quiet)
{
- struct object *obj = deref_tag(parse_object(sha1), NULL, 0);
-
+ struct object *obj;
+ int type = sha1_object_info(sha1, NULL);
+ /* If it's neither tag nor commit, parsing the object is wasted effort */
+ if (type != OBJ_TAG && type != OBJ_COMMIT)
+ return NULL;
+ obj = deref_tag(parse_object(sha1), NULL, 0);
if (!obj)
return NULL;
return check_commit(obj, sha1, quiet);
--
1.8.3.506.g4fdeee5
next prev parent reply other threads:[~2013-05-30 20:00 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-30 10:38 Poor performance of git describe in big repos Alex Bennée
2013-05-30 11:33 ` Ramkumar Ramachandra
2013-05-30 13:09 ` Alex Bennée
2013-05-30 14:32 ` Ramkumar Ramachandra
2013-05-30 15:01 ` Alex Bennée
2013-05-30 15:17 ` Ramkumar Ramachandra
2013-05-30 15:33 ` Thomas Rast
2013-05-30 16:01 ` Alex Bennée
2013-05-30 16:21 ` Thomas Rast
2013-05-30 16:44 ` Thomas Rast
2013-05-30 19:01 ` Antoine Pelisse
2013-05-30 20:00 ` [PATCH 1/2] sha1_file: silence sha1_loose_object_info Thomas Rast
2013-05-30 20:00 ` Thomas Rast [this message]
2013-05-30 21:22 ` [PATCH 2/2] lookup_commit_reference_gently: do not read non-{tag,commit} Jeff King
2013-05-31 0:52 ` Duy Nguyen
2013-05-31 8:08 ` Thomas Rast
2013-05-31 16:00 ` Jeff King
2013-05-31 6:43 ` Ramkumar Ramachandra
2013-05-31 8:16 ` Thomas Rast
2013-05-30 19:30 ` Poor performance of git describe in big repos John Keeping
2013-05-31 8:14 ` Alex Bennée
2013-05-31 8:24 ` Thomas Rast
2013-05-31 8:40 ` Alex Bennée
2013-05-31 8:46 ` Thomas Rast
2013-05-31 9:57 ` Alex Bennée
2013-06-03 8:02 ` Alex Bennée
2013-06-03 16:32 ` Junio C Hamano
2013-06-03 17:48 ` Junio C Hamano
2013-05-31 10:27 ` Thomas Rast
2013-05-31 16:17 ` Jeff King
2013-06-03 8:39 ` Alex Bennée
2013-06-03 14:49 ` Jeff King
2013-05-31 8:32 ` John Keeping
2013-05-31 8:49 ` Alex Bennée
2013-05-31 8:59 ` John Keeping
2013-05-30 11:48 ` John Keeping
2013-05-30 12:29 ` Alex Bennée
2013-05-30 13:20 ` Duy Nguyen
[not found] ` <CAJ-05NPacjAEC99Ntd9eMnTD9_PMMYFob-_tAx5CeSB79TkRSg@mail.gmail.com>
2013-05-30 13:45 ` Duy Nguyen
2013-05-30 14:02 ` Alex Bennée
2013-05-30 13:16 ` Alex Bennée
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5cc40825d5b4fb3382e4c054c49adf5e6b6fe110.1369943791.git.trast@inf.ethz.ch \
--to=trast@inf.ethz.ch \
--cc=apelisse@gmail.com \
--cc=artagnon@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=john@keeping.me.uk \
--cc=kernel-hacker@bennee.com \
--cc=pclouds@gmail.com \
/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.
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).