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

Reduction performance tweaks #676

Merged
merged 2 commits into from
Feb 8, 2025
Merged

Conversation

andrews05
Copy link
Collaborator

@andrews05 andrews05 commented Feb 3, 2025

Two key changes here:

  • Removed some defunct reduction benches and added some more alpha reduction benches.
  • Changed use of chunks() to chunks_exact() where appropriate to improve performance. (As a byproduct, this also fixes a potential crash if a malformed file has a PLTE chunk that isn't a multiple of 3.)

src/reduction/alpha.rs Outdated Show resolved Hide resolved
@andrews05 andrews05 marked this pull request as ready for review February 3, 2025 18:50
@andrews05
Copy link
Collaborator Author

The chunks_exact makes a big difference to the 16-to-8 benchmarks. (Still not appreciable in actual use though.)
Before:

test reductions_16_to_8_bits                        ... bench:     352,770.85 ns/iter (+/- 11,464.83)
test reductions_16_to_8_bits_scaled                 ... bench:     748,591.70 ns/iter (+/- 7,528.53)

After

test reductions_16_to_8_bits                        ... bench:     200,931.25 ns/iter (+/- 4,184.77)
test reductions_16_to_8_bits_scaled                 ... bench:     116,423.44 ns/iter (+/- 652.00)

Copy link
Collaborator

@AlexTMjugador AlexTMjugador left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

@AlexTMjugador AlexTMjugador merged commit 1188b9a into shssoichiro:master Feb 8, 2025
12 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