performance fix: protobuf client ioutil.ReadAll #282
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue #166:
ioutil.ReadAll
takes 2x memory and is ~20% slower for the protobuf client. CC #166Description of changes:
My team uses
twirp
as an RPC to talk to other service. Both client and server are written in go. As a part of the spec, services exchange[]byte
blobs. Occasionally, those blobs are fairly large in size and exceed 100M. I have detected, thatioutil.ReadAll
has a noticeable performance impact for us and pretty much confirmed #166 findings.I have created a test app and a benchmark test for it - https://github.com/mkorenkov/twirpbench. Based on the benchmark, current PR improves
Total Allocations
2x and is about 20% faster, thanmaster
branch.NOTE: requires
https://github.com/gogo/protobuf/
protoc plugin. No special features are needed though - see https://github.com/mkorenkov/twirpbench/blob/master/cmd/protoc-gen-maxgo/main.go. Please let me know what you want me to do about it. I can move https://github.com/mkorenkov/twirpbench/blob/master/cmd/protoc-gen-maxgo/main.go to twirp as well and updateREADME.md
accordingly.Benchmark results:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.