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

Re: [PATCH 1/2] rerere: extract logic to determine whether entries are stale

From
Patrick Steinhardt <ps@pks.im>
Date
Sep 4, 2026, 05:21 UTC
Message-ID
<appVS2P6ThaRU9fc@pks.im>
In-Reply-To
<a63c3bbe-28b8-4026-9c07-11c2d445c504@gmail.com>
On Thu, Sep 03, 2026 at 10:11:20AM -0400, Derrick Stolee wrote:
Show 43 quoted lines
> On 9/3/2026 5:04 AM, Patrick Steinhardt wrote:
> > When garbage collecting rerere entries we need to figure out whether any
> > given entry is stale before pruning it. In a subsequent commit we're
> > about to introduce a second caller that wants to determine staleness,
> > but the logic is not currently reusable.
> > 
> > Extract the logic to compute staleness by introducing two new helper
> > functions `rerere_gc_cutoffs()` and `rerere_id_is_stale()`.
> 
> Thanks for doing these extractions. It reduces complexity in the top-
> level logic.
> 
> > -static void prune_one(struct rerere_id *id,
> > -		      timestamp_t cutoff_resolve, timestamp_t cutoff_noresolve)
> ...> +static bool rerere_id_is_stale(struct rerere_id *id,
> > +			       timestamp_t cutoff_resolve,
> > +			       timestamp_t cutoff_noresolve)
> 
> This modification of prune_one() to a staleness check is good to
> have split, but...
> 
> >  		for (id.variant = 0, id.collection = rr_dir;
> >  		     id.variant < id.collection->status_nr;
> >  		     id.variant++) {
> > -			prune_one(&id, cutoff_resolve, cutoff_noresolve);
> > +			if (rerere_id_is_stale(&id, cutoff_resolve, cutoff_noresolve))
> > +				unlink_rr_item(&id);
> >  			if (id.collection->status[id.variant])
> >  				now_empty = 0;
> >  		}
> 
> ...this loop gets slightly more complicated. This is not worth
> a change, but I'm thinking out loud that I would have updated
> prune_one to be this simple:
> 
> static void prune_one(struct rerere_id *id,
> 		      timestamp_t cutoff_resolve, timestamp_t cutoff_noresolve)
> {
> 	if (rerere_id_is_stale(&id, cutoff_resolve, cutoff_noresolve))
> 		unlink_rr_item(&id);
> } 
> and left the loop alone. This is only a preference, as your
> implementation is also quite clean.

That's fair. I originally retained `prune_one()`, but then I wasn't sure whether it's really worth it anymore given that it's essentially a two-line function now. Anyway, will restore it.

Patrick
Previous: Derrick StoleeNext: Patrick Steinhardt
Message 4 of 17 in “builtin/maintenance: improve heuristic for "rerere gc"”
  1. 0/2 builtin/maintenance: improve heuristic for "rerere gc"Patrick Steinhardt, Sep 3, 2026
  2. 1/2 rerere: extract logic to determine whether entries are stalePatrick Steinhardt, Sep 3, 2026
  3. Derrick StoleeSep 3, 2026
  4. Patrick SteinhardtSep 4, 2026
  5. 2/2 builtin/maintenance: improve heuristic for "rerere gc"Patrick Steinhardt, Sep 3, 2026
  6. Derrick StoleeSep 3, 2026
  7. Patrick SteinhardtSep 4, 2026
  8. Thomas BachemSep 3, 2026
  9. 0/2 builtin/maintenance: improve heuristic for "rerere gc"Patrick Steinhardt, Sep 4, 2026
  10. 1/2 rerere: extract logic to determine whether entries are stalePatrick Steinhardt, Sep 4, 2026
  11. 2/2 builtin/maintenance: improve heuristic for "rerere gc"Patrick Steinhardt, Sep 4, 2026
  12. Derrick StoleeSep 4, 2026
  13. Junio C HamanoSep 4, 2026
  14. Junio C HamanoSep 4, 2026
  15. Thomas BachemSep 4, 2026
  16. Patrick SteinhardtSep 7, 2026
  17. Patrick SteinhardtSep 7, 2026

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.