Repository navigation
Switch to flate2 with zlib-rs backend for deflate compression - #474
Merged
Merged
Conversation
oscarlorentzon
approved these changes
Oct 6, 2026
oscarlorentzon
left a comment
Collaborator
There was a problem hiding this comment.
Looks good.
Could we use zlib-rs for spz as well, so that one library handles compression and decompression throughout and miniz_oxide can be dropped from spark-lib's dependencies?
Collaborator
Author
Yes, wanted to do that as a follow-up to this PR. Would also allow us to get rid of the manual gzip header parsing, as that's built-in to |
Contributor
|
Thanks! |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The RAD format uses deflate compression through
miniz_oxide. Seeing #433 achieve a large decompression performance uplift by usingzstd, made me wonder whether this is due to the different algorithm or implementation. It seems thatminiz_oxideis one of the slower implementations in the Rust ecosystem.This PR switches to using
flate2which supports various backends, includingzlib-rs. Performing some basic tests show a huge improvement in compression speed (~50% shorter), slightly smaller outputs (~2-5%) and an improvement in overall decoding time (~20%). While the result isn't byte identical, bothzlib-rsandminiz_oxideare compatible with each others output.One annoying downside of Cargo is the way features are additive throughout the dependency tree. Even without specifying the
zlib-rsfeature,flate2would already switch to it as thezipdependency forsogsdepends onflate2and sets thezlib-rsfeature as well. As such, I've made the exact feature forzipexplicit asdeflatewas a shorthand for["deflate-flate2-zlib-rs", "deflate-zopfli"]. The latter is only for compression with compression levels > 10, whichspark-rs/-libdoesn't actually need.