Skip to content

Conversation

@bboreham
Copy link
Contributor

Fixes #2635

For large messages this generates far less garbage than ioutil.ReadAll().

Implement for gzip - RFC1952 requires it, and the Go implementation checks it already (modulo 2^32).

For large messages this generates far less garbage than ioutil.ReadAll().

Implement for gzip - RFC1952 requires it, and the Go implementation
checks it already (modulo 2^32).

Signed-off-by: Bryan Boreham <[email protected]>
@bboreham bboreham force-pushed the exact-decompress-size branch from e36a434 to 4d7f286 Compare September 27, 2019 14:03
@dfawley dfawley added the Type: Performance Performance improvements (CPU, network, memory, etc) label Sep 27, 2019
@dfawley dfawley added this to the 1.25 Release milestone Sep 27, 2019
Copy link
Member

@dfawley dfawley left a comment

Choose a reason for hiding this comment

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

Thanks for the new version, this is even better!

Return -1 instead of an error in the case that we can't determine a size.

Use a LimitReader set to size+1 so we can detect cases like corrupt
messages and overflow of the 32-bit size field.

Signed-off-by: Bryan Boreham <[email protected]>
Based on review feedback

Signed-off-by: Bryan Boreham <[email protected]>
@bboreham
Copy link
Contributor Author

I pushed a couple more commits which I think cover all the review comments.

@dfawley dfawley self-assigned this Oct 3, 2019
Copy link
Member

@dfawley dfawley left a comment

Choose a reason for hiding this comment

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

LGTM. One last minor change to request for initializing buf first, though. Thanks!

It's simpler.

Signed-off-by: Bryan Boreham <[email protected]>
@dfawley
Copy link
Member

dfawley commented Oct 4, 2019

Thanks for the contribution!

@dfawley dfawley merged commit dcd1c97 into grpc:master Oct 4, 2019
bboreham added a commit to cortexproject/cortex that referenced this pull request Nov 8, 2019
This brings in some performance improvements, including
grpc/grpc-go#3048 which should make a big
difference when using gRPC gzip compression.

Plus some updated dependencies.

Signed-off-by: Bryan Boreham <[email protected]>
@lock lock bot locked as resolved and limited conversation to collaborators Apr 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Type: Performance Performance improvements (CPU, network, memory, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use of ioutil.ReadAll in decompression generates lots of garbage

2 participants