Subject: Re: [PATCH v2 3/3] refs/files: use heuristic to decide whether to repack with `--auto`

From: Junio C Hamano <[email-masked]>
Date: Wed, 04 Sep 2024 08:24:44 -0700

Patrick Steinhardt <[email-masked]> writes:

> Introduce a heuristic that decides whether or not it is worth to pack
> loose references. The important factors to decide here are the number of
> loose references in comparison to the overall size of the "packed-refs"
> file. The bigger the "packed-refs" file, the longer it takes to rewrite
> it and thus we scale up the limit of allowed loose references before we
> repack.
>
> As is the nature of heuristics, this mechansim isn't obviously
> "correct", but should rather be seen as a tradeoff between how much
> resources we spend packing refs and how inefficient the ref store
> becomes. For all I can say, we have successfully been using the exact
> same heuristic in Gitaly for several years by now.

This seems to hit the balance between the thoroughness of repack
(leaving fewer loose refs is good) and the frequencey (doing repack
less often is good) in a quite sensible way.

I also have to wonder if it adds a good component to the heuristics
to leave younger loose refs (wrt mtime) out of packed-refs, with the
expectation that they are more likely to be updated again soon than
refs that were written long time ago and stayed the same value.

Thanks.