]> arthur.barton.de Git - bup.git/commit
vint: implement the typical pack() in C
authorJohannes Berg <johannes@sipsolutions.net>
Sat, 1 Feb 2020 21:47:09 +0000 (22:47 +0100)
committerRob Browning <rlb@defaultvalue.org>
Sat, 15 May 2021 18:56:36 +0000 (13:56 -0500)
commit3b98812aa98a1590e2bebbc83c113c07e4c002bc
tree617012d056dae0757a7d462bb34b3bc8c5c25f70
parent717d27e2f71e957aedbf99abdf95a86364b137c8
vint: implement the typical pack() in C

This estimates the size, and if we run over it falls back to the
slower python, and similarly if anything happens with the vuints/vints
contained in there, but it still speeds up the typical case
significantly, and improves raw index speed (on cached filesystem
data) by about 14% (~19.7k paths/sec to ~22.5k paths/sec).

Since it doesn't handle corner cases (very long strings or very large
numbers) add a few tests that cover the fallback to python.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
[rlb@defaultvalue.org: switch to PyMem_Raw*; rename to
 limited_vint_pack; use Py_ssize_t with PyTuple_GET_SIZE]
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/_helpers.c
lib/bup/vint.py
test/int/test_vint.py