-
Notifications
You must be signed in to change notification settings - Fork 322
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
zstd decoder not re-using memory effectively between Reset() and Read() #666
Comments
It's not doing exactly the same as my case, but I think
It's calling |
klauspost
added a commit
that referenced
this issue
Sep 24, 2022
Adds `WithDecodeBuffersBelow` to tweak buffer switch-over. Fixes #666 and generally reduces Reader allocations.
Merged
klauspost
added a commit
that referenced
this issue
Sep 25, 2022
Adds `WithDecodeBuffersBelow` to tweak buffer switch-over. Fixes #666 and generally reduces Reader allocations.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've been stepping through some decompression code to try to figure out why zstd memory use is much higher than other compression types.
I see that
Reset()
uses the bufferd.current.b
:compress/zstd/decoder.go
Line 198 in 697e507
Then in my case
DecodeAll
runs and the buffer grows to ~300KB.Each time
Read()
is called, it advances the start of the buffer:compress/zstd/decoder.go
Line 135 in 697e507
After we read the whole thing,
b
is still pointing into a 300KB buffer, but towards the end.When we re-use the Decoder, this buffer has len zero and cap ~35KB. Because 300KB is needed, a new block is allocated.
Could we have the Decoder hold a reference to the beginning of the buffer, so the whole size can be re-used?
Apologies if I'm mis-reading this.
The text was updated successfully, but these errors were encountered: