git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: Linus TorvaldsNext: Linus Torvalds
Message 9 of 13 in “"git reflog expire --all" very slow”
  1. Linus TorvaldsMar 31, 2009
  2. Junio C HamanoMar 31, 2009
  3. Linus TorvaldsMar 31, 2009
  4. Junio C HamanoMar 31, 2009
  5. Linus TorvaldsMar 31, 2009
  6. Junio C HamanoMar 31, 2009
  7. Junio C HamanoMar 31, 2009
  8. Linus TorvaldsMar 31, 2009
  9. Linus TorvaldsMar 31, 2009
  10. Linus TorvaldsMar 31, 2009
  11. Junio C HamanoApr 2, 2009
  12. Linus TorvaldsApr 2, 2009
  13. Junio C HamanoMar 31, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.