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

Reuse zstd context for better perf #248

Open
NobodyXu opened this issue Sep 23, 2023 · 0 comments
Open

Reuse zstd context for better perf #248

NobodyXu opened this issue Sep 23, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@NobodyXu
Copy link
Collaborator

NobodyXu commented Sep 23, 2023

I noticed a new PR on zstd gyscos/zstd-rs#247 that optimizes zstd::stream::Encoder by reusing zstd context:

From profiling, I have found that creating a zstd::stream::Encoder and using it to encode a small amount of bytes (less than 100) takes over 200 microseconds per encode on my machine. The vast majority of this time is related to the creation of new zstd contexts, so this PR adds a simple method on Encoder and Decoder that allows one to supply an external context from zstd_safe instead. With these changes, performance is improved - the previously-mentioned benchmark takes less than 2 microseconds per encode.

from @DouglasDwyer

Seems like a good idea to support this once it is merged.

@NobodyXu NobodyXu changed the title Reuse zstd context for Reuse zstd context for better perf Sep 23, 2023
@robjtede robjtede added the enhancement New feature or request label Jan 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants