]> arthur.barton.de Git - bup.git/commit
metadata: implement write using encode, not vice versa
authorJohannes Berg <johannes@sipsolutions.net>
Fri, 31 Jan 2020 22:29:09 +0000 (23:29 +0100)
committerRob Browning <rlb@defaultvalue.org>
Sat, 15 May 2021 18:57:24 +0000 (13:57 -0500)
commitaa46f06bc3f720306415652f30c65b566acd0363
tree1a55c05d784463aa5d0672c9c8f767b188376a14
parent96642edec5b2a38951a0dbaf8ddab26c6de25159
metadata: implement write using encode, not vice versa

Using write() for encode() is slower due to the use of BytesIO,
and we never really stream the data out anyway since it is part
of an object that we build, so it's all in memory.

Thus, implement write() using encode() rather than the other
way around.

Together with the previous patches, this speeds up encoding the
metadata by about 54%, and indexing by about 15-20% (my system goes
from ~16.3k paths/sec to ~19.7k paths/sec when all the filesystem
data is already buffered in memory).

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/metadata.py