-
Notifications
You must be signed in to change notification settings - Fork 4.5k
transport: writeStatus: Skip Status.Proto() without details #8282
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
transport: writeStatus: Skip Status.Proto() without details #8282
Conversation
Add Status.HasDetails() to check for details. Change http2server.writeStatus to check to avoid unnecessary clones in the common case when there are no details. This seems to be worth about 0.1% of CPU for a high QPS gRPC service, according to the Go profiler. While looking at profiles for a high QPS gRPC service at Datadog, I noticed that about 0.3% of CPU time is being spent calling Status.Proto(). I believe this is unnecessary: this clones the protobuf status message, only to check if there are details. If there are not (the common case, e.g. for status code OK), it throws the protobuf message away. I tried quickly but was not able to reliably measure the impact of this change from any end-to-end benchmarks, but it does seem to make this function go away according to the profiler. This should be a small win for every gRPC server.
1cfbc0c
to
7e10d74
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #8282 +/- ##
==========================================
- Coverage 82.13% 82.10% -0.03%
==========================================
Files 417 419 +2
Lines 41385 41946 +561
==========================================
+ Hits 33991 34440 +449
- Misses 5961 6030 +69
- Partials 1433 1476 +43
🚀 New features to boost your workflow:
|
This changes our external API since |
Removes status.HasDetails() in favor of a gRPC internal function.
I have updated the PR to add the suggested I'm happy to make any other suggested improvements. Thanks for the suggestion and the code review! One unimportant ignorable thought: Another option would be to make this internal function more restricted: |
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.
Thanks!
@arjan-bal can you take a second pass please? |
I have added a copyright to the new test file by copy/pasting and editing the header from status.go in an attempt to fix |
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.
Minor comments, otherwise LGTM.
I believe I addressed all the code review comments. I resolved all the line comments above, and unassigned myself. Happy to address any other feedback! |
Add Status.HasDetails() to check for details. Change http2server.writeStatus to check to avoid unnecessary clones in the common case when there are no details. This seems to use about 0.3% of CPU for a high QPS gRPC service, according to the Go profiler.
While looking at profiles for a high QPS gRPC service at Datadog, I noticed that about 0.3% of CPU time is being spent calling Status.Proto(). I believe this is unnecessary: this clones the protobuf status message, only to check if there are details. If there are not (the common case, e.g. for status code OK), it throws the protobuf message away.
I tried quickly but was not able to reliably measure the impact of this change from any end-to-end benchmarks, but it does seem to make this function go away according to the profiler. This should be a small win for every gRPC server.
RELEASE NOTES: