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

Re: "git reflog expire --all" very slow

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 2, 2009, 06:46 UTC
Message-ID
<7vmyazimds.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<alpine.LFD.2.00.0903302250500.4093@localhost.localdomain>
Linus Torvalds <torvalds@linux-foundation.org> writes:
Show 11 quoted lines
> That made no sense. It should have been:
>
> On Mon, 30 Mar 2009, Linus Torvalds wrote:
>> 
>> 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).
>                                                   ^^^^
>                                                  reachability
>
> but other than that the commentary stands.

Correct. But after thinking about this a bit more, I am starting to suspect the "of course" in your earlier

    If I do
            mark_reachable(cb.ref_commit, 0);
    instead (to traverse the _whole_ tree, with no regards to date), the time 
    shrinks to 1.7s. But of course, that's also wrong.
may not be such a clearly obvious thing.

Suppose you do not do "mark_reachable(cb.ref_commit, 0)" but use the expire_total as the cut-off value (which is what I've queued). If you have one unreachable entry that you end up running in_merge_bases() for, you will traverse all the history down _anyway_, and at that point, you would be better off if you actually marked everything upfront, and discarded anything unmarked as unreachable without falling back to in_merge_bases() at all.

The above reasoning of course assumes that "keep reflog entries if they are reachable from the tip, otherwise drop them if they are more than 30 days old" is a good medium level semantics to cull what the other rule "drop any reflog entry older than 90 days" may not.

A hacky alternative would be to use total_expire as the cut-off and do not fall back on in_merge_bases(). We might incorrectly prune away an entry that records that you pulled a commit that is still reachable from the tip last week, if that commit happens to be 4 months old if we did so, so I am not convinced myself it is a reasonable hack, though.

Previous: Linus TorvaldsNext: Linus Torvalds
Message 11 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.