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

Use an object pool for ZopfliHash instances #28

Merged
merged 12 commits into from Mar 18, 2024

Conversation

Pr0methean
Copy link
Contributor

@Pr0methean Pr0methean commented Jul 2, 2023

This avoids a huge allocation (several until #27 is merged) every time the code needs a ZopfliHash instance.

If merging both this and #27, change the declaration of HASH_POOL to

#[cfg(feature = "std")]
pub static HASH_POOL: Lazy<LinearObjectPool<Box<ZopfliHash>>> = Lazy::new(|| LinearObjectPool::new(
    ZopfliHash::new, |hash| hash.reset()));
#[cfg(not(feature = "std"))]
pub static HASH_POOL: Lazy<LinearObjectPool<Box<ZopfliHash>>> = Lazy::new(|| LinearObjectPool::new(
    ZopfliHash::new, ZopfliHash::reset));

@AlexTMjugador
Copy link
Member

Thanks! #27 was recently merged, so would you mind rebasing this PR to the latest mainline commit? Also, could you show some benchmark results for comparison?

@andrews05
Copy link

andrews05 commented Aug 7, 2023

For what it's worth, I couldn't measure any performance improvement from this PR 😅.
(Not suggesting it's pointless, just the difference may be negligible)

@Pr0methean
Copy link
Contributor Author

Rebased.

@kornelski kornelski merged commit 92a40f2 into zopfli-rs:main Mar 18, 2024
3 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.

None yet

4 participants