-
Notifications
You must be signed in to change notification settings - Fork 49
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
Add shared zstd decoder pools. #285
Conversation
go/pkg/client/cas.go
Outdated
decoderInit.Do(func() { | ||
decoders = syncpool.NewDecoderPool(zstd.WithDecoderConcurrency(1)) | ||
}) | ||
|
||
// TODO(rubensf): Reuse decoders when possible to save the effort of starting/closing goroutines. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you can remove this TODO?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup - thanks for catching!
go/pkg/client/cas.go
Outdated
@@ -881,13 +894,14 @@ func NewCompressedWriteBuffer(w io.Writer) (io.WriteCloser, chan error, error) { | |||
// separate thread. As such, we also need a way to signal the main | |||
// thread that the decoding has finished - which will have some delay | |||
// from the last Write call. | |||
_, err := decoder.WriteTo(w) | |||
_, err := decoderW.Decoder.WriteTo(w) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could just be decoderW.WriteTo(w)
since the Decoder is embedded. And similarly for the decoderW.Decoder.Reset
call further up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, thanks!
Like #267, but for decoders.
Testing on internal builds yielded improvements :)