]> git.ipfire.org Git - thirdparty/git.git/commit
reftable/reader: iterate to next block in place
authorPatrick Steinhardt <ps@pks.im>
Mon, 8 Apr 2024 12:16:50 +0000 (14:16 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 15 Apr 2024 17:36:09 +0000 (10:36 -0700)
commitb00bcb7c49a4f96d39e4a448998b366bcd484de2
tree0bfd68ad7a0786667e1503f5ecfa112563f4ce64
parentbcdc586db0b3310d05256cbe38724551e4f70475
reftable/reader: iterate to next block in place

The table iterator has to iterate towards the next block once it has
yielded all records of the current block. This is done by creating a new
table iterator, initializing it to the next block, releasing the old
iterator and then copying over the data.

Refactor the code to instead advance the table iterator in place. This
is simpler and unlocks some optimizations in subsequent patches. Also,
it allows us to avoid some allocations.

The following measurements show a single matching ref out of 1 million
refs. Before this change:

  HEAP SUMMARY:
      in use at exit: 13,603 bytes in 125 blocks
    total heap usage: 7,235 allocs, 7,110 frees, 301,481 bytes allocated

After:

  HEAP SUMMARY:
      in use at exit: 13,603 bytes in 125 blocks
    total heap usage: 315 allocs, 190 frees, 107,027 bytes allocated

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
reftable/block.c
reftable/reader.c