git/reftable
Patrick Steinhardt a418a7abef reftable/record: don't try to reallocate ref record name
When decoding reftable ref records we first release the pointer to the
record passed to us and then use realloc(3P) to allocate the refname
array. This is a bit misleading though as we know at that point that the
refname will always be `NULL`, so we would always end up allocating a
new char array anyway.

Refactor the code to use `REFTABLE_ALLOC_ARRAY()` instead. As the
following benchmark demonstrates this is a tiny bit more efficient. But
the bigger selling point really is the gained clarity.

  Benchmark 1: show-ref: single matching ref (revision = HEAD~)
    Time (mean ± σ):     150.1 ms ±   4.1 ms    [User: 146.6 ms, System: 3.3 ms]
    Range (min … max):   144.5 ms … 180.5 ms    1000 runs

  Benchmark 2: show-ref: single matching ref (revision = HEAD)
    Time (mean ± σ):     148.9 ms ±   4.5 ms    [User: 145.2 ms, System: 3.4 ms]
    Range (min … max):   143.0 ms … 185.4 ms    1000 runs

  Summary
    show-ref: single matching ref (revision = HEAD) ran
      1.01 ± 0.04 times faster than show-ref: single matching ref (revision = HEAD~)

Ideally, we should try and reuse the memory of the old record instead of
first freeing and then immediately reallocating it. This requires some
more surgery though and is thus left for a future iteration.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-12 09:18:05 -08:00
..
LICENSE
basics.c
basics.h
basics_test.c
block.c reftable/block: swap buffers instead of copying 2024-02-12 09:18:04 -08:00
block.h
block_test.c reftable/record: store "val1" hashes as static arrays 2024-01-03 09:54:20 -08:00
blocksource.c reftable/blocksource: use mmap to read tables 2024-01-11 12:10:59 -08:00
blocksource.h
constants.h
dump.c
error.c
generic.c
generic.h
iter.c
iter.h
merged.c reftable/merged: skip comparison for records of the same subiter 2024-02-12 09:18:04 -08:00
merged.h reftable/merged: allocation-less dropping of shadowed records 2024-02-12 09:18:04 -08:00
merged_test.c Merge branch 'ps/reftable-fixes-and-optims' 2024-01-16 10:11:57 -08:00
pq.c reftable/pq: allocation-less comparison of entry keys 2024-02-12 09:18:04 -08:00
pq.h
pq_test.c
publicbasics.c
reader.c Merge branch 'en/header-cleanup' 2024-01-08 14:05:15 -08:00
reader.h
readwrite_test.c Merge branch 'ps/reftable-fixes-and-optims' 2024-01-16 10:11:57 -08:00
record.c reftable/record: don't try to reallocate ref record name 2024-02-12 09:18:05 -08:00
record.h reftable/record: introduce function to compare records by key 2024-02-12 09:18:04 -08:00
record_test.c reftable/record: store "val2" hashes as static arrays 2024-01-03 09:54:21 -08:00
refname.c
refname.h
refname_test.c
reftable-blocksource.h
reftable-error.h
reftable-generic.h
reftable-iterator.h
reftable-malloc.h
reftable-merged.h
reftable-reader.h
reftable-record.h reftable/record: store "val2" hashes as static arrays 2024-01-03 09:54:21 -08:00
reftable-stack.h
reftable-tests.h
reftable-writer.h
stack.c Merge branch 'ps/reftable-optimize-io' 2024-01-29 16:02:59 -08:00
stack.h reftable/stack: fix race in up-to-date check 2024-01-18 12:02:09 -08:00
stack_test.c Merge branch 'ps/reftable-fixes-and-optims' 2024-01-16 10:11:57 -08:00
system.h reftable/stack: fix race in up-to-date check 2024-01-18 12:02:09 -08:00
test_framework.c
test_framework.h
tree.c
tree.h
tree_test.c
writer.c reftable/writer: fix index corruption when writing multiple indices 2024-01-03 09:54:20 -08:00
writer.h