-
Notifications
You must be signed in to change notification settings - Fork 111
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
Allow reusing the same context across multiple Encoders and Decoders #247
Conversation
would love to see this! |
bump @gyscos for visibility |
Thanks for the PR! A few questions:
I don't seem to see these changes anymore, were they already merged through another PR? |
My instinct was to separate them for readability. However, since it's an internal API, they don't necessarily have to be separate. I will go ahead and change this.
The goal for doing this was to ensure that However! Looking at this again,
Yes, the WASM shim now works properly on Taking another look at this PR, I feel like the cleanest solution might be to create an entirely separate |
Ping @gyscos |
I found a workaround that reuses the dictionary: https://gist.github.com/esemeniuc/ad889c617cc4297043fc344136be563f |
Bump @gyscos |
Thanks for the work! Let's start with that, we'll see later if/how we could allow both referencing a dict and a context. |
CI failures looks weird - maybe you need to rebase? |
Ended up testing and merging the PR locally. Thanks for the work! |
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 onEncoder
andDecoder
that allows one to supply an external context fromzstd_safe
instead. With these changes, performance is improved - the previously-mentioned benchmark takes less than 2 microseconds per encode.This PR also makes some minor changes to the WASM shim, as compilation appears to be broken for it.