Skip to content

Switch from adler2 to simd-adler32 crate when using miniz_oxide backend #492

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 3, 2025

Conversation

Shnatsel
Copy link
Member

@Shnatsel Shnatsel commented Jul 2, 2025

Switch over to https://crates.io/crates/simd-adler32 for a performance boost.

Introduces some unsafe code into the dependency tree due to the use of raw CPU intrinsics. However, this unsafe code is low risk due to the way it's structured, and the crate has also undergone extensive fuzzing.

This has been enabled in the famously risk-averse image-png for a good while now, and is even enabled in the Chromium field trials on stable channel.

It's worth noting that Rust v1.87 has dramatically regressed performance of lots of SIMD code relying on runtime feature etection; this negatively affected the AVX2 codepath of simd-adler32, see rust-lang/rust#142603
Which is why I didn't open this earlier.

On all other compiler versions dating back all the way to MSRV this crate is dramatically faster than adler2.

@Shnatsel
Copy link
Member Author

Shnatsel commented Jul 2, 2025

CI fails because Clippy complains about code I didn't touch.

Copy link
Member

@Byron Byron left a comment

Choose a reason for hiding this comment

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

Thanks so much! Particularly the motivation and explanation was helpful as otherwise I would have worried that adding SIMD instructions will reduce compatibility and break downstream.

Also, I have fixed the clippy warnings, including additional ones that come up with cargo clippy --all-targets.

@Byron Byron merged commit 7145603 into rust-lang:main Jul 3, 2025
15 checks passed
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