From b00bcb7c49a4f96d39e4a448998b366bcd484de2 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Mon, 8 Apr 2024 14:16:50 +0200 Subject: 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 Signed-off-by: Junio C Hamano --- reftable/block.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'reftable/block.c') diff --git a/reftable/block.c b/reftable/block.c index 2d8d0668b3..0c4e71eae3 100644 --- a/reftable/block.c +++ b/reftable/block.c @@ -188,6 +188,8 @@ int block_reader_init(struct block_reader *br, struct reftable_block *block, uint8_t *restart_bytes = NULL; uint8_t *uncompressed = NULL; + reftable_block_done(&br->block); + if (!reftable_is_block_type(typ)) { err = REFTABLE_FORMAT_ERROR; goto done; -- cgit v1.3-5-g9baa