]> git.ipfire.org Git - thirdparty/git.git/commit
reftable/block: reuse uncompressed blocks
authorPatrick Steinhardt <ps@pks.im>
Mon, 8 Apr 2024 12:16:54 +0000 (14:16 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 15 Apr 2024 17:36:09 +0000 (10:36 -0700)
commitdd347bbce6053538d3332e6e8e499a3bebdbd251
tree553124cc09502d07e5cb9b2070cceb2840983bd9
parentb00bcb7c49a4f96d39e4a448998b366bcd484de2
reftable/block: reuse uncompressed blocks

The reftable backend stores reflog entries in a compressed format and
thus needs to uncompress blocks before one can read records from it.
For each reflog block we thus have to allocate an array that we can
decompress the block contents into. This block is being discarded
whenever the table iterator moves to the next block. Consequently, we
reallocate a new array on every block, which is quite wasteful.

Refactor the code to reuse the uncompressed block data when moving the
block reader to a new block. This significantly reduces the number of
allocations when iterating through many compressed blocks. The following
measurements are done with `git reflog list` when listing 100k reflogs.
Before:

  HEAP SUMMARY:
      in use at exit: 13,473 bytes in 122 blocks
    total heap usage: 45,755 allocs, 45,633 frees, 254,779,456 bytes allocated

After:

  HEAP SUMMARY:
      in use at exit: 13,473 bytes in 122 blocks
    total heap usage: 23,028 allocs, 22,906 frees, 162,813,547 bytes allocated

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