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));

Unverified

This user has not yet uploaded their public signing key.

Unverified

This user has not yet uploaded their public signing key.

Unverified

This user has not yet uploaded their public signing key.

Unverified

This user has not yet uploaded their public signing key.

Unverified

This user has not yet uploaded their public signing key.

Unverified

This user has not yet uploaded their public signing key.

Unverified

This user has not yet uploaded their public signing key.
@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 and others added 3 commits March 16, 2024 20:05

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
@Pr0methean
Copy link
Contributor Author

Rebased.

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
@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