Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Due to the usage of
AlignedStorage
and its Wrapper^nBuf
when storing andserializing buffers length information is lost and the total length will simply
be set to the capacity. This is wrong. While serialization libraries seem to
handle this well enough, the decompression structure used from
zstd
did not(This could be a bug though). This patch reworks the de/compression part to do 5
things:
store the length of the original data alongside the compressed to ensure the
minimal amount of reallocation on decompression (1); before for each block a
reallocation happened bc of how the
zstd
decompression writer worksinternally
minimize the amount of copies during compression and decompression; the
zstd
writer holds an internal buffer which, to my understanding, alwaysbuffers the intermediate results and then copies it to the final buffer. We
avoid this structure now entirely to reduce the amount of copies
estimate the size of the compressed results inbefore to reduce realloc's
rework the compression interface to be similar to a one-and-done process,
compressors and decompressors might be reused later on (needs an additional
reinit), but the append-append-compress workflow was never used and comes with
inefficienct reallocs
remove redundant memcpy when using the
None
compression algorithm