Re: "git reflog expire --all" very slow
- From
Linus Torvalds <torvalds@linux-foundation.org>
- Date
- Mar 31, 2009, 05:50 UTC
- Message-ID
- <alpine.LFD.2.00.0903302244580.4093@localhost.localdomain>
- In-Reply-To
- <alpine.LFD.2.00.0903302231370.4093@localhost.localdomain>
On Mon, 30 Mar 2009, Linus Torvalds wrote:
> > If I do > > mark_reachable(cb.ref_commit, 0);
Ok, I think I got it.
You had
mark_reachable(cb.ref_commit, cmd->expire_unreachable);
but we care about the commits that are younger than 'expire_total' (older than that, and they are pruned unconditionally), but older than 'expire_unreachable' (younger than that and the date doesn't matter).
So making it do
mark_reachable(cb.ref_commit, cmd->expire_total);
marks the right parts reachable. Not the whole tree, but also not just the commits we're not going to expire regardless.
With that change, it's all basically instantaneous. We don't need to traverse the whole kernel history, and with that change to your patch, I get
[torvalds@nehalem linux]$ time ~/git/git reflog expire --all
real 0m1.715s user 0m1.676s sys 0m0.040s
which is still slower than I'd wish for, but is a whole lot faster than over half a minute.
Linus