1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-12 10:04:14 +02:00
pgbackrest/test
David Steele 61ce58692f
Pack manifest file structs to save memory.
Manifests with a very large number of files can use a considerable amount of memory. There are a lot of zeroes in the data so it can be stored more efficiently by using base-128 varint encoding for the integers and storing the strings in the same allocation.

The downside is that the data needs to be unpacked in order to be used, but in most cases this seems fast enough (about 10% slower than before) except for saving the manifest, which is 10% slower up to 10 million files and then gets about 5x slower by 100 million (two minutes on my M1 Mac). Profiling does not show this slowdown so I wonder if this is related to the change in memory layout. Curiously, the function that increased most was jsonFromStrInternal(), which was not modified. That gives more weight to the idea that there is some kind of memory issue going on here and one hopes that servers would be less affected. Either way, they largest use cases we have seen are for about 6 million files so if we can improve that case I believe we will be better off.

Further analysis showed that most of the time was taken up writing the size and timestamp fields, which makes almost no sense. The same amount of time was used if they were hard-coded to 0, which points to some odd memory issue on the M1 architecture.

This change has been planned for a while, but the particular impetus at this time is that small file support requires additional fields that would increase manifest memory usage by about 20%, even if the feature is not used.

Note that the Pack code has been updated to use the new varint encoder, but the decoder remains separate because it needs to fetch one byte at a time.
2022-01-21 17:05:07 -05:00
..
certificate Add TLS Server. 2021-10-18 14:32:41 -04:00
code-count Simplify manifest defaults. 2022-01-21 15:22:48 -05:00
data
expect Simplify manifest defaults. 2022-01-21 15:22:48 -05:00
lib/pgBackRestTest Simplify manifest defaults. 2022-01-21 15:22:48 -05:00
src Pack manifest file structs to save memory. 2022-01-21 17:05:07 -05:00
.gitignore
ci.pl Use Rocky Linux for documentation builds instead of CentOS. 2021-10-28 15:15:49 -04:00
container.yaml Use Rocky Linux for documentation builds instead of CentOS. 2021-10-28 15:15:49 -04:00
define.yaml Pack manifest file structs to save memory. 2022-01-21 17:05:07 -05:00
Dockerfile Add libc6-dbg required by updated valgrind to Vagrantfile/Dockerfile. 2021-10-13 09:37:03 -04:00
test.pl Use Rocky Linux for documentation builds instead of CentOS. 2021-10-28 15:15:49 -04:00
Vagrantfile Update Vagrantfile to Ubuntu 20.04. 2021-10-13 13:21:04 -04:00