Re: [PATCH v2 3/4] builtin/maintenance: only consider `gc.reflogExpire` for "--auto"
- From
Toon Claes <toon@iotcl.com>
- Date
- Dec 3, 2026, 14:22 UTC
- Message-ID
- <87ik1aqwa2.fsf@dev.null.iotcl.com.invalid>
- In-Reply-To
- <20261202-pks-reflog-expire-performance-v2-3-17b2d6dd4867@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 24 quoted lines
> The "reflog-expire" maintenance task is responsible for expiring reflog > entries that are older than either "gc.reflogExpire" for entries that > are still reachable, or "gc.reflogExpireUnreachable" for those that are > not reachable. > > When executed with "--auto", the condition that we use to trigger this > task verifies whether the number of reflog entries that we would prune > is larger than "maintenance.reflog-expire.auto". This is evaluated by > walking the "HEAD" reflog, where we then check every entry by calling > `should_expire_reflog_ent()`. That function will then check whether the > reflog entry refers to a commit that is reachable or not, and depending > on the outcome compares against either "gc.reflogExpire", or against > both "gc.reflogExpire" and "gc.reflogExpireUnreachable". > > To decide reachability the caller has to call `reflog_expiry_prepare()`, > which amongst other things also performs a reachability walk for a given > refname. But we don't do that in the "reflog-expire" maintenance task, > and hence every single reflog entry will be considered unreachable and > thus we'd consider many reachable entries prunable even though they > won't be pruned. So we overcount the number of prunable entries quite a > bit and will thus trigger `git reflog expire` even though it won't do > anything. > > Now we could easiliy fix that by calling `reflog_expiry_prepare()`. But
s/easiliy/easily/
Show 12 quoted lines
> in the case of auto-maintenance it has the big downside that we now have > to perform a reachability walk in the foreground, and that may be quite > expensive. The whole point of those auto-conditions is to use heuristics > that are fast to evaluate though so that the time we have to block is > reduced as much as possible. > > Instead, adapt the heuristic to only evaluate reflog entries against > "gc.reflogExpire". This of course means that we're now undercounting the > number of prunable entries. But as part of background maintenance that > feels like a reasonable tradeoff, and a user that really wants to prune > unreachable reflog entries can either execute git-maintenance(1) without > "--auto", or they can run `git reflog expire` directly.
So this commit doesn't include any test changes. Simply put that's because `test_commit` writes really old commits, so they are older than both "gc.reflogExpire" and "gc.reflogExpireUnreachable".
Now we could add a test that sets "gc.reflogExpire=never" and "gc.reflogExpireUnreachable=now" and test the overcounting, but I don't insist on that because that's not really the point of this change.
I'm happy to accept this series as-is.
-- Laters, Toon