From: Linus Torvalds <torvalds@linux-foundation.org>
To: "Carlos R. Mafra" <crmafra2@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>,
Junio C Hamano <gitster@pobox.com>
Subject: Re: Performance issue of 'git branch'
Date: Wed, 22 Jul 2009 19:23:39 -0700 (PDT) [thread overview]
Message-ID: <alpine.LFD.2.01.0907221921570.3352@localhost.localdomain> (raw)
In-Reply-To: <alpine.LFD.2.01.0907221850000.3352@localhost.localdomain>
On Wed, 22 Jul 2009, Linus Torvalds wrote:
>
> Ooh yes. That would do it. It's going to peel and look up every single ref
> it finds, so it's going to look up _hundreds_ of objects (all the tags,
> all the commits they point to, etc etc). Even if it then only shows a
> couple of branches.
>
> Junio, any ideas?
I had one of my own.
Does this fix it?
It uses the "raw" version of 'for_each_ref()' (which doesn't verify that
the ref is valid), and then does the "type verification" before it starts
doing any gentle commit lookup.
That should hopefully mean that it no longer does tons of object lookups
on refs that it's not actually interested in.
Linus
---
builtin-branch.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/builtin-branch.c b/builtin-branch.c
index 5687d60..54a89ff 100644
--- a/builtin-branch.c
+++ b/builtin-branch.c
@@ -240,6 +240,10 @@ static int append_ref(const char *refname, const unsigned char *sha1, int flags,
if (ARRAY_SIZE(ref_kind) <= i)
return 0;
+ /* Don't add types the caller doesn't want */
+ if ((kind & ref_list->kinds) == 0)
+ return 0;
+
commit = lookup_commit_reference_gently(sha1, 1);
if (!commit)
return error("branch '%s' does not point at a commit", refname);
@@ -248,10 +252,6 @@ static int append_ref(const char *refname, const unsigned char *sha1, int flags,
if (!is_descendant_of(commit, ref_list->with_commit))
return 0;
- /* Don't add types the caller doesn't want */
- if ((kind & ref_list->kinds) == 0)
- return 0;
-
if (merge_filter != NO_FILTER)
add_pending_object(&ref_list->revs,
(struct object *)commit, refname);
@@ -426,7 +426,7 @@ static void print_ref_list(int kinds, int detached, int verbose, int abbrev, str
ref_list.with_commit = with_commit;
if (merge_filter != NO_FILTER)
init_revisions(&ref_list.revs, NULL);
- for_each_ref(append_ref, &ref_list);
+ for_each_rawref(append_ref, &ref_list);
if (merge_filter != NO_FILTER) {
struct commit *filter;
filter = lookup_commit_reference_gently(merge_filter_ref, 0);
next prev parent reply other threads:[~2009-07-23 2:24 UTC|newest]
Thread overview: 74+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-22 23:59 Performance issue of 'git branch' Carlos R. Mafra
2009-07-23 0:21 ` Linus Torvalds
2009-07-23 0:51 ` Linus Torvalds
2009-07-23 0:55 ` Linus Torvalds
2009-07-23 2:02 ` Carlos R. Mafra
2009-07-23 2:28 ` Linus Torvalds
2009-07-23 12:42 ` Jakub Narebski
2009-07-23 14:45 ` Carlos R. Mafra
2009-07-23 16:25 ` Linus Torvalds
2009-07-23 1:22 ` Carlos R. Mafra
2009-07-23 2:20 ` Linus Torvalds
2009-07-23 2:23 ` Linus Torvalds [this message]
2009-07-23 3:08 ` Linus Torvalds
2009-07-23 3:21 ` Linus Torvalds
2009-07-23 17:47 ` Tony Finch
2009-07-23 18:57 ` Linus Torvalds
2009-07-23 22:48 ` Newton-Raphson, was " Tony Finch
2009-07-23 23:24 ` Johannes Schindelin
2009-07-23 23:50 ` Tony Finch
2009-07-24 0:43 ` Johannes Schindelin
2009-07-23 3:18 ` Carlos R. Mafra
2009-07-23 3:27 ` Carlos R. Mafra
2009-07-23 3:40 ` Carlos R. Mafra
2009-07-23 3:47 ` Linus Torvalds
2009-07-23 4:10 ` Linus Torvalds
2009-07-23 5:13 ` Junio C Hamano
2009-07-23 5:17 ` Carlos R. Mafra
2009-07-23 4:40 ` Junio C Hamano
2009-07-23 5:36 ` Linus Torvalds
2009-07-23 5:52 ` Junio C Hamano
2009-07-23 6:04 ` Junio C Hamano
2009-07-23 17:19 ` Linus Torvalds
2009-07-23 16:07 ` Carlos R. Mafra
2009-07-23 16:19 ` Linus Torvalds
2009-07-23 16:53 ` Carlos R. Mafra
2009-07-23 19:05 ` Linus Torvalds
2009-07-23 19:13 ` Linus Torvalds
2009-07-23 19:55 ` Carlos R. Mafra
2009-07-24 20:36 ` Linus Torvalds
2009-07-24 20:47 ` Linus Torvalds
2009-07-24 21:21 ` Linus Torvalds
2009-07-24 22:13 ` Linus Torvalds
2009-07-24 22:18 ` david
2009-07-24 22:42 ` Linus Torvalds
2009-07-24 22:46 ` david
2009-07-25 2:39 ` Linus Torvalds
2009-07-25 2:53 ` Daniel Barkalow
2009-08-07 4:21 ` Jeff King
2009-07-24 22:54 ` Theodore Tso
2009-07-24 22:59 ` Shawn O. Pearce
2009-07-24 23:28 ` Junio C Hamano
2009-07-26 17:07 ` Avi Kivity
2009-07-26 17:16 ` Johannes Schindelin
2009-07-24 23:46 ` Carlos R. Mafra
2009-07-25 0:41 ` Carlos R. Mafra
2009-07-25 18:04 ` Linus Torvalds
2009-07-25 18:57 ` Timo Hirvonen
2009-07-25 19:06 ` Reece Dunn
2009-07-25 20:31 ` Mike Hommey
2009-07-25 21:02 ` Linus Torvalds
2009-07-25 21:13 ` Linus Torvalds
2009-07-25 23:23 ` Johannes Schindelin
2009-07-26 4:49 ` Linus Torvalds
2009-07-26 16:29 ` Theodore Tso
2009-07-26 7:54 ` Mike Hommey
2009-07-26 10:16 ` Johannes Schindelin
2009-07-26 10:23 ` demerphq
2009-07-26 10:27 ` demerphq
2009-07-25 21:04 ` Carlos R. Mafra
2009-07-23 16:48 ` Anders Kaseorg
2009-07-23 19:03 ` Carlos R. Mafra
2009-07-23 0:23 ` SZEDER Gábor
2009-07-23 2:25 ` Carlos R. Mafra
-- strict thread matches above, loose matches on Subject: below --
2009-07-26 23:21 George Spelvin
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=alpine.LFD.2.01.0907221921570.3352@localhost.localdomain \
--to=torvalds@linux-foundation.org \
--cc=crmafra2@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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.
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).