-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Remove call to proto.Clone() in http2Server.WriteStatus. #2842
Conversation
Update fork with changes from master
Move MinConnectionTimeout() out of backoff.Strategy interface. Store it directly in dialOptions instead, and have ClientConn use it from there.
I need to roll these back because I had sent out changes from my master branch, and this is causing a lot of pain right now for my work on other branches. I will create a branch for this issue and will send out these changes in a fresh PR.
Sync fork with upstream master.
|
* Expose a method from the internal package to get to the raw StatusProto wrapped by the status error, and use it from http2Server.WriteStatus(). * Add a helper method in internal/testutils to compare two status errors and update test code to use that instead of reflect.DeepEqual()
Thanks for the git tips. Definitely going to be useful moving forward. |
vet is failing because the reverted go.sum and go.mod changes? How do we usually handle this?
Thanks for the git tips. Definitely going to be useful moving forward. |
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.
LGTM modulo the one small change requested.
internal/transport/http2_server.go
Outdated
@@ -817,7 +819,8 @@ func (t *http2Server) WriteStatus(s *Stream, st *status.Status) error { | |||
headerFields = append(headerFields, hpack.HeaderField{Name: "grpc-status", Value: strconv.Itoa(int(st.Code()))}) | |||
headerFields = append(headerFields, hpack.HeaderField{Name: "grpc-message", Value: encodeGrpcMessage(st.Message())}) | |||
|
|||
if p := st.Proto(); p != nil && len(p.Details) > 0 { | |||
srp := internal.StatusRawProto.(func(*status.Status) *spb.Status) |
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.
It should be (a tiny bit) better to declare this globally and avoid the type assertion every time status is written:
var statusRawProto = internal.StatusRawProto.(func(*status.Status) *spb.Status)
(Also it would fail at init time if the types are wrong, instead of runtime, which is also a win.)
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.
Done. Thanks.
I also meant to request some performance metrics for this change - can you run a QPS-style workload (many concurrent, small RPCs) before/after and see if this makes much difference in performance / allocations? Benchmark results should be posted in the first PR comment. Thanks. |
I ran a benchmark with 100 concurrent calls and req and resp sizes of 32 bytes. There doesn't seem to any significant change in performance. Stream-traceMode_false-latency_0s-kbps_0-MTU_0-maxConcurrentCalls_100-reqSize_32B-respSize_32B-Compressor_off-Preloader_false |
Interesting. Do we trust the allocation numbers? I would expect them to be lower (both count and size) since we are removing |
I made a change to the server to return a status with details message. When I used a details message of len 128, this was the result: And when I used a details message of len 512, this was the result: The allocation numbers seem to be reasonably trustworthy in the sense that the number of allocs/op has not changed based on the length of the details message while the bytes/op has (and is proportional in some sense to the length of the details message). |
@dfawley : Is there a way to get the vet test to be happy without the go.mod and go.sum changes? |
internal/testutils/status_equal.go
Outdated
package testutils | ||
|
||
import ( | ||
"github.com/gogo/protobuf/proto" |
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.
This should not use gogo/proto
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.
Done. Thanks.
Some of the tests are unusually flaky today. Unable to make travis happy as of now.
Fixes #2182
StatusProto wrapped by the status error, and use it from
http2Server.WriteStatus().
and update test code to use that instead of reflect.DeepEqual()