-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
compression: fix decomp buffer mgt (#51)
* compression: fix decomp buffer mgt Due to the usage of `AlignedStorage` and its Wrapper^n `Buf` when storing and serializing 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 4 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 works internally - minimize the amount of copies during compression and decompression; the `zstd` writer holds an internal buffer which, to my understanding, always buffers 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 * compression: fix incorrect length stored * compression: avoid copy on none algo This commit fixes the redundant copy that was done when calling `decompress` with the `None` compression. We should see less memcpys now.
- Loading branch information
jwuensche
authored
Jan 26, 2024
1 parent
df1ed2f
commit f559bda
Showing
5 changed files
with
144 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters