git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Frans Pop <elendil@planet.nl>,
	"Shawn O. Pearce" <spearce@spearce.org>,
	git@vger.kernel.org
Subject: Re: Extremely slow progress during 'git reflog expire --all'
Date: Sun, 04 Apr 2010 11:22:18 -0700	[thread overview]
Message-ID: <7vy6h36pt1.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <20100403203507.GA12262@coredump.intra.peff.net> (Jeff King's message of "Sat\, 3 Apr 2010 16\:35\:07 -0400")

Jeff King <peff@peff.net> writes:

> Thanks, I was able to get it and reproduce your problem. The slowness is
> in the expire-unreachable code. You can work around it with:
>
>   git config gc.reflogExpireUnreachable never
>
> Obviously that's not really a fix, but it should let your "git gc" work.
>
> It looks like we do two merge-base calculations for each reflog entry,
> which is what takes so long. Perhaps if we know we are going to do a
> large number of reachability checks, we can pre-mark all reachable
> commits, and then each reflog entry would just need to check the commit
> mark.

Thanks for the analysis, but expire_reflog() that is run for each ref
already does that, I think.  It first runs mark_reachable(), then walks
each reflog entry for the ref to call expire_reflog_ent(), which in turn
calls unreachable() that first checks if mark_reachable() has marked the
commit, and if so we don't run in_merge_bases().

But if the commit in question is not reachable, then we end up running
in_merge_bases() to double-check anyway, which is probably the symptom
that was observed.

So perhaps this is a workable compromise?

 builtin/reflog.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/builtin/reflog.c b/builtin/reflog.c
index 64e45bd..7e278b8 100644
--- a/builtin/reflog.c
+++ b/builtin/reflog.c
@@ -230,6 +230,13 @@ static int unreachable(struct expire_reflog_cb *cb, struct commit *commit, unsig
 	/* Reachable from the current ref?  Don't prune. */
 	if (commit->object.flags & REACHABLE)
 		return 0;
+	/*
+	 * Unless there was a clock skew, younger ones that are
+	 * reachable should have been marked by mark_reachable().
+	 */
+	if (cb->cmd->expire_total < commit->date)
+		return 1;
+
 	if (in_merge_bases(commit, &cb->ref_commit, 1))
 		return 0;
 

  reply	other threads:[~2010-04-04 18:22 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-02 19:54 Extremely slow progress during 'git reflog expire --all' Frans Pop
2010-04-02 21:28 ` Jeff King
2010-04-02 21:50   ` Frans Pop
2010-04-02 22:41     ` Jeff King
2010-04-03 14:29       ` Frans Pop
2010-04-03 20:33         ` Jeff King
2010-04-03 20:35         ` Jeff King
2010-04-04 18:22           ` Junio C Hamano [this message]
2010-04-05  6:26             ` Jeff King
2010-04-05 18:54               ` Junio C Hamano
2010-04-06  6:02                 ` Jeff King
2010-04-07 18:39                   ` Re*: " Junio C Hamano
2010-04-07 18:43                     ` Junio C Hamano
2010-04-08  7:00                       ` Jeff King
2010-04-08  6:52                     ` Jeff King

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=7vy6h36pt1.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=elendil@planet.nl \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    --cc=spearce@spearce.org \
    /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).