diff options
author | Patrick Steinhardt <ps@pks.im> | 2024-11-20 08:51:39 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-11-21 07:59:17 +0900 |
commit | d94ac23d3b9e223c6cacfdab7047d3d4efae3218 (patch) | |
tree | bd83198005a1b65c50d08d8ec94857b05eb0583c /replace-object.c | |
parent | aa248b8ab2ec0dd6e22373b504cfd4ec4b9b970a (diff) |
reftable/block: optimize allocations by using scratch buffer
The block writer needs to compute the key for every record that one adds
to the writer. The buffer for this key is stored on the stack and thus
reallocated on every call to `block_writer_add()`, which is inefficient.
Refactor the code so that we store the buffer in the `block_writer`
struct itself so that we can reuse it. This reduces the number of
allocations when writing many refs, e.g. when migrating one million refs
from the "files" backend to the "reftable backend. Before this change:
HEAP SUMMARY:
in use at exit: 80,048 bytes in 49 blocks
total heap usage: 3,025,864 allocs, 3,025,815 frees, 372,746,291 bytes allocated
After this change:
HEAP SUMMARY:
in use at exit: 80,048 bytes in 49 blocks
total heap usage: 2,013,250 allocs, 2,013,201 frees, 347,543,583 bytes allocated
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'replace-object.c')
0 files changed, 0 insertions, 0 deletions