Skip to content

Use miniz_oxide - a better DEFLATE backend - #169

Merged
martin-g merged 8 commits into
apache:mainfrom
Shnatsel:better-deflate
Apr 1, 2025
Merged

martin-g merged 8 commits into
apache:mainfrom
Shnatsel:better-deflate

Conversation

@Shnatsel

@Shnatsel Shnatsel commented Apr 1, 2025

Copy link
Copy Markdown
Contributor

Switch from libflate to miniz_oxide as the DEFLATE backend.

miniz_oxide is faster and more widely tested. It is the default backend for the de-facto standard flate2 crate, and has 10x the amount of downloads compared to libflate.

I've taken care to preserve the same public API so that this change would be transparent to users.

Comment thread avro/src/error.rs Resolved
Comment thread avro/src/error.rs Resolved
Co-authored-by: Martin Grigorov <[email protected]>
Comment thread avro/src/codec.rs
.finish()
.into_result()
.map_err(Error::DeflateCompressFinish)?;
let compressed = miniz_oxide::deflate::compress_to_vec(stream, 6);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is '6' here?
The compression level ?
Could we introduce settings like the other impls ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is the compression level. Making it configurable is a good idea.

I kept the API the same in this PR to get the performance improvements to users without requiring them to change any code. Adding this configuration would be a good follow-up.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done with #174

Comment thread avro/src/codec.rs Resolved
@martin-g martin-g changed the title Use a better DEFLATE backend Use miniz_oxide - a better DEFLATE backend Apr 1, 2025
@martin-g
martin-g merged commit f13800d into apache:main Apr 1, 2025
@martin-g

martin-g commented Apr 1, 2025

Copy link
Copy Markdown
Member

Thank you for the contribution, @Shnatsel !

martin-g added a commit that referenced this pull request Apr 7, 2025
martin-g added a commit that referenced this pull request Apr 7, 2025
…when it is needed

Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
martin-g added a commit that referenced this pull request Apr 9, 2025
* Issue #169 - Be explicit about the used features of miniz_oxide

Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>

* Issue #169 - Do not allow unused imports. Import only what is needed when it is needed

Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>

* Fixes #173 - Introduce DeflateSettings

At the moment it could be used to specify the compression level for
Codec::Deflate

Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>

* Issue #173 - Use non-default compression level for Codec::Deflate

Add some Rustdoc

Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>

* Issue #173 - Update the README.md with `cargo rdme`

Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>

* Issue #173 - Fix Rustdoc imports

Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>

* Issue #173 - Introduce a helper method for the cast of CompressionLevel to u8

Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>

* Issue #173 - Further rustdoc import fixes

Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>

---------

Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants