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

Add shared zstd decoder pools. #285

Merged
merged 1 commit into from
Feb 19, 2021
Merged

Add shared zstd decoder pools. #285

merged 1 commit into from
Feb 19, 2021

Conversation

rubensf
Copy link
Contributor

@rubensf rubensf commented Feb 19, 2021

Testing on internal builds yielded improvements :)

@google-cla google-cla bot added the cla: yes The author signed a CLA label Feb 19, 2021
decoderInit.Do(func() {
decoders = syncpool.NewDecoderPool(zstd.WithDecoderConcurrency(1))
})

// TODO(rubensf): Reuse decoders when possible to save the effort of starting/closing goroutines.
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup - thanks for catching!

@@ -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)
Copy link
Contributor

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.

Copy link
Contributor Author

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.
@rubensf rubensf merged commit 41f1b9e into master Feb 19, 2021
@rubensf rubensf deleted the onedec branch February 19, 2021 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes The author signed a CLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants