Skip to content
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

Add optional simd feature to optimize adler32 and miniz_oxide #16

Closed
wants to merge 2 commits into from

Conversation

cjgriscom
Copy link
Contributor

In a benchmark that generates many small PNGs, half of the runtime is split between miniz deflate, and the other half in png_pong::zlib::adler32. Replacing the built-in adler32 function with the optimized simd-adler32 crate makes the runtime of the adler32 function almost negligible. This PR adds the 'simd' feature to select between the built-in function and the external crate. It also enables simd optimizations for the miniz_oxide crate.

@AldaronLau
Copy link
Owner

@cjgriscom Nice, thanks for the PR!

I'm thinking since it looks like that crate has a fallback non-simd implementation for unsupported architectures, it would be preferable to depend on it unconditionally, rather than gated behind a feature. Then png_pong could get rid of the slow implementation it has.

@cjgriscom
Copy link
Contributor Author

@AldaronLau I can't think of a reason that wouldn't work. I believe miniz_oxide leaves it behind a flag because of their no-unsafe policy, but if you don't care about that I will rewrite the PR to enable it unconditionally.

@AldaronLau
Copy link
Owner

@cjgriscom Since there are already a few instances of unsafe in the pix dependency for optimizations, I wouldn't be opposed to having unsafe in another dependency for a specialized optimization.

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