diff options
| author | Taylor Blau <me@ttaylorr.com> | 2024-08-27 17:13:36 -0400 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-08-27 14:50:27 -0700 |
| commit | db40e3c92b9ccd03d2263b12cf1824ffab8a1cce (patch) | |
| tree | c003067817ac2de32d2875c022baf3aa0cbe346e /t/unit-tests/t-reftable-pq.c | |
| parent | 125c32605ab93a7778c064315a5d8d78d554b8b4 (diff) | |
pack-bitmap.c: avoid repeated `pack_pos_to_offset()` during reuse
When calling `try_partial_reuse()`, the (sole) caller from the function
`reuse_partial_packfile_from_bitmap_1()` has to translate its bit
position to a pack position.
In the MIDX bitmap case, the caller translates from the bit position, to
a position in the MIDX's pseudo-pack order (with `pack_pos_to_midx()`),
then get a pack offset (with `nth_midxed_offset()`) before finally
working backwards to get the pack position in the source pack by calling
`offset_to_pack_pos()`.
In the non-MIDX bitmap case, we can use the bit position as the pack
position directly (see the comment at the beginning of the
`reuse_partial_packfile_from_bitmap_1()` function for why).
In either case, the first thing that `try_partial_reuse()` does after
being called is determine the offset of the object at the given pack
position by calling `pack_pos_to_offset()`. But we already have that
information in the MIDX case!
Avoid re-computing that information by instead passing it in. In the
MIDX case, we already have that information stored. In the non-MIDX
case, the call to `pack_pos_to_offset()` moves from the function
`try_partial_reuse()` to its caller. In total, we'll save one call to
`pack_pos_to_offset()` when processing MIDX bitmaps.
(On my machine, there is a slight speed-up on the order of ~2ms, but it
is within the margin of error over 10 runs, so I think you'd have to
have a truly gigantic repository to confidently measure any significant
improvement here).
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/unit-tests/t-reftable-pq.c')
0 files changed, 0 insertions, 0 deletions
