-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Improve performance of ProtobufHttpMessageConverter #29496
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
Improve performance of ProtobufHttpMessageConverter #29496
Conversation
@koo-taejin Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@koo-taejin Thank you for signing the Contributor License Agreement! |
0818621
to
a1ab8d4
Compare
a1ab8d4
to
dba2812
Compare
Thanks for this contribution, and sorry for getting back to you so long after. Running with Without this change:
With this change:
In light of that, I'm declining this PR for now. We can always consider other changes if they're backed by benchmark results. |
This commit re-generates the protobuf Java classes with a recent version of the protoc binary and adds JMH benchmarks that exercise the message converter for both the reading and writing cases. See gh-29496
Improved performance for
ProtobufHttpMessageConverter
Currently, when a binary message in the form of ProtoBuf is received, data is created using the Builder via
ProtobufHttpMessageConverter
.When Protobuf creating individual
com.google.protobuf.Message
. it creates aPROTO_MESSAGE parseFrom(java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
methodIf use this method, ProtobufHttpMessageConverter can reduce creating unnecessary Builder and executing merge method process.
(And I have confirmed that
grpc-java
use this method when creating 'com.google.protobuf.Message'.)If change the object creation to the
parseFrom
method, I made a simple test and confirmed that the TPS increased by about 5% in several simple performance tests.(I have confirmed that the slope of increasing heap improved.)
Rather than using a builder, there is a risk for method presence, so I made a map for present method.
Please feel free to let me know if I misjudged anything. :)