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

Re: [PATCH v2 6/8] rerere: provide function to collect stale entries

From
Patrick Steinhardt <ps@pks.im>
Date
May 2, 2025, 08:07 UTC
Message-ID
<aBR9R3PxSCuLON6G@pks.im>
In-Reply-To
<xmqqy0vh1t96.fsf@gitster.g>
On Wed, Apr 30, 2025 at 09:58:13AM -0700, Junio C Hamano wrote:
Show 41 quoted lines
> Patrick Steinhardt <ps@pks.im> writes:
> 
> > We're about to add another task for git-maintenance(1) that prunes stale
> > rerere entries via `git rerere gc`. The condition of when to run this
> > subcommand will be configurable so that the subcommand is only executed
> > when a certain number of stale rerere entries exists. This requires us
> > to know about the number of stale rerere entries in the first place,
> > which is non-trivial to figure out.
> >
> > Refactor `rerere_gc()` and `prune_one()` so that garbage collection is
> > split into three phases:
> >
> >   1. We collect any stale rerere entries and directories that are about
> >      to become empty.
> >
> >   2. Prune all stale rerere entries.
> >
> >   3. Remove all directories that should have become empty in (2).
> >
> > By splitting out the collection of stale entries we can trivially expose
> > this function to external callers and thus reuse it in later steps.
> >
> > This refactoring is not expected to result in a user-visible change in
> > behaviour.
> 
> I have no objection against the goal of allowing "git maintenance"
> drive "git rerere gc", and as the primary author of this code path I
> do not see anything wrong, in the "correctness" sense, in the
> updated code.
> 
> I however am not sure if "count what we would prune, and remove only
> when there are too many" would work well for this subsystem, because
> I expect that the cost to enumerate existing rerere entries and
> check each of them for staleness would be the dominant part,
> relative to actual "rm -fr <rerere-id>", of the cost you are paying
> when you run "git rerere gc".
> 
> And if my suspicion is correct, all this change does to the plain
> vanilla user of "git rerere gc" is to have them pay the extra cost
> of allocating and deallocating the list of names of paths in string
> lists.

Yeah, I think this concern makes sense indeed. I was a bit sceptical myself whether this is going too far. Maybe a simpler solution would be to just count the number of directories in ".git/rr-cache", without checking whether those actually are prunable?

We could also adapt this to be closer to the original version, where we only verified that ".git/rr-cache" exists and contains at least one subdirectory. This can even be combined with the above approach if we set "maintenance.rerere-gc.auto=1" by default.

> We need to see some performance measurement to show that the we pay
> for collection and counting is a lot smaller compared to the whole
> pruning operation to justify the "auto" thing.

Hm. I guess ultimately the answer is going to be "it depends". The performance implication on Windows is going to be quite different compared to the performance on Linux/macOS.

In any case, let's go with the simpler model for now. We can still iterate as needed if we eventually see that the heuristic is too dumb to be useful.

Patrick
Previous: Junio C HamanoNext: Junio C Hamano
Message 9 of 14 in “builtin/maintenance: implement missing tasks compared to git-gc(1)”
  1. 0/8 builtin/maintenance: implement missing tasks compared to git-gc(1)Patrick Steinhardt, Apr 30, 2025
  2. 1/8 builtin/gc: fix indentation of `cmd_gc()` parametersPatrick Steinhardt, Apr 30, 2025
  3. 2/8 builtin/gc: remove global variables where it trivial to doPatrick Steinhardt, Apr 30, 2025
  4. 3/8 builtin/gc: move pruning of worktrees into a separate functionPatrick Steinhardt, Apr 30, 2025
  5. 4/8 worktree: expose function to retrieve worktree namesPatrick Steinhardt, Apr 30, 2025
  6. 5/8 builtin/maintenance: introduce "worktree-prune" taskPatrick Steinhardt, Apr 30, 2025
  7. 6/8 rerere: provide function to collect stale entriesPatrick Steinhardt, Apr 30, 2025
  8. Junio C HamanoApr 30, 2025
  9. Patrick SteinhardtMay 2, 2025
  10. Junio C HamanoMay 2, 2025
  11. Patrick SteinhardtMay 5, 2025
  12. 7/8 builtin/gc: move rerere garbage collection into separate functionPatrick Steinhardt, Apr 30, 2025
  13. 8/8 builtin/maintenance: introduce "rerere-gc" taskPatrick Steinhardt, Apr 30, 2025
  14. Derrick StoleeApr 30, 2025

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.