mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
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>
This commit is contained in:
committed by
Junio C Hamano
parent
b00bcb7c49
commit
dd347bbce6
@@ -66,6 +66,10 @@ struct block_reader {
|
||||
struct reftable_block block;
|
||||
int hash_size;
|
||||
|
||||
/* Uncompressed data for log entries. */
|
||||
unsigned char *uncompressed_data;
|
||||
size_t uncompressed_cap;
|
||||
|
||||
/* size of the data, excluding restart data. */
|
||||
uint32_t block_len;
|
||||
uint8_t *restart_bytes;
|
||||
|
||||
Reference in New Issue
Block a user