Thread (75 messages) 75 messages, 6 authors, 7d ago

Re: [PATCH v2 1/8] odb/source-packed: improve lookup when enumerating objects

From: Taylor Blau <hidden>
Date: 2026-07-10 22:25:14

On Fri, Jul 10, 2026 at 10:48:53AM +0200, Patrick Steinhardt wrote:
Fix the issue by using `packed_object_info()` directly.
What you wrote here makes sense to me insofar as I understand the
pluggable ODB code.

However, I am confused by the way this function is written in general.
We use `bsearch_one_midx()` to locate the first possible MIDX position
in which an object matching the given prefix may exist, which is
sensible. However, we go from that position up to "num", where "num" is
the total number of objects in the MIDX!

Functionally this is not incorrect as we will happily discard objects
that do not match the prefix. But it causes us to waste CPU cycles
repeatedly calling `match_hash()` (at least for the first byte of the
prefix) for objects that we know will match.

How often do we call this function with a prefix longer than a
single byte? I have no idea, but I would suspect that it makes up the
majority of calls. If we read the OID fanout chunk, we could narrow the
range that we enumerate through, and only compare the second byte
onwards of the given prefix, if one exists. In the single-byte prefix
case, this means that we shouldn't have to do any memory comparisons at
all.
While at it, rename the `store` variable to `source`.
Unrelated, but please keep these to a minimum, as they make the patch
more difficult to read than is necessary.

Thanks,
Taylor
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help