On Sat, Nov 6, 2021 at 1:23 AM Nir Soffer <nsoffer@redhat.com> wrote:
The generic vector reallocs on every append. Add benchmarks to measure the cost with uint32 vector (used for copying extents) and the effect of reserving space upfront.
The tests show that realloc is pretty efficient, but calling reserve before the appends speeds the appends up significantly.
NBDKIT_BENCH=1 ./test-vector bench_reserve: 1000000 appends in 0.004503 s bench_append: 1000000 appends in 0.014986 s
The new benchmarks do not run by default to avoid trouble in CI on overloaded machines or under qemu emulation.
A new target added to run all benchmaks:
make bench
Ported from libnbd: - https://listman.redhat.com/archives/libguestfs/2021-October/msg00304.html - https://listman.redhat.com/archives/libguestfs/2021-October/msg00305.html --- Makefile.am | 5 +++ README | 7 ++++ common/utils/Makefile.am | 3 ++ common/utils/bench.h | 72 ++++++++++++++++++++++++++++++++++++++
I forgot to add this file to the sources, so it is not included in the tarball. Wil fix this before pusing. I think including maintainer-check-extra-dist in the check target wil avoid such errors for very little cost: $ time make dist maintainer-check-extra-dist >/dev/null make: *** [Makefile:1173: maintainer-check-extra-dist] Error 1 real 0m3.767s user 0m2.655s sys 0m1.644s