summaryrefslogtreecommitdiff
path: root/refs/debug.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2025-10-30 11:38:45 +0100
committerJunio C Hamano <gitster@pobox.com>2025-10-30 07:09:53 -0700
commitc31bad4f7dcf3e04ae22e7d4a1059fd628acf1a2 (patch)
treee834be384525f7b9546a71453d7b6a862e652a8f /refs/debug.c
parent6aff1f25a046f3dcd8a78b0c61414fa2d1c9a93c (diff)
packfile: track packs via the MRU list exclusively
We track packfiles via two different lists: - `struct packfile_store::packs` is a list that sorts local packs first. In addition, these packs are sorted so that younger packs are sorted towards the front. - `struct packfile_store::mru` is a list that sorts packs so that most-recently used packs are at the front. The reasoning behind the ordering in the `packs` list is that younger objects stored in the local object store tend to be accessed more frequently, and that is certainly true for some cases. But there are going to be lots of cases where that isn't true. Especially when traversing history it is likely that one needs to access many older objects, and due to our housekeeping it is very likely that almost all of those older objects will be contained in one large pack that is oldest. So whether or not the ordering makes sense really depends on the use case at hand. A flexible approach like our MRU list addresses that need, as it will sort packs towards the front that are accessed all the time. Intuitively, this approach is thus able to satisfy more use cases more efficiently. This reasoning casts some doubt on whether or not it really makes sense to track packs via two different lists. It causes confusion, and it is not clear whether there are use cases where the `packs` list really is such an obvious choice. Merge these two lists into one most-recently-used list. Note that there is one important edge case: `for_each_packed_object()` uses the MRU list to iterate through packs, and then it lists each object in those packs. This would have the effect that we now sort the current pack towards the front, thus modifying the list of packfiles we are iterating over, with the consequence that we'll see an infinite loop. This edge case is worked around by introducing a new field that allows us to skip updating the MRU. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs/debug.c')
0 files changed, 0 insertions, 0 deletions