Skip to content
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

stats.InPayload has incorrect WireLength set #1647

Closed
spencerkimball opened this issue Nov 3, 2017 · 2 comments
Closed

stats.InPayload has incorrect WireLength set #1647

spencerkimball opened this issue Nov 3, 2017 · 2 comments

Comments

@spencerkimball
Copy link
Contributor

While stats.OutPayload correctly accounts for the 5-byte GRPC header, stats.InPayload skips it when computing InPayload.WireLength. This means that a client's throughput does not match the server's throughput when you have a simple test which sends a single request response pair between client and server.

The patch below fixes the problem in GRPC.

diff --git a/rpc_util.go b/rpc_util.go
index eccf84d..8418649 100644
--- a/rpc_util.go
+++ b/rpc_util.go
@@ -376,7 +376,7 @@ func recv(p *parser, c Codec, s *transport.Stream, dc Decompressor, m interface{
                return err
        }
        if inPayload != nil {
-               inPayload.WireLength = len(d)
+               inPayload.WireLength = len(d) + len(p.header)
        }
        if err := checkRecvPayload(pf, s.RecvCompress(), dc); err != nil {
                return err
diff --git a/server.go b/server.go
index 2c26db8..ba53840 100644
--- a/server.go
+++ b/server.go
@@ -818,7 +818,7 @@ func (s *Server) processUnaryRPC(t transport.ServerTransport, stream *transport.
        }
        df := func(v interface{}) error {
                if inPayload != nil {
-                       inPayload.WireLength = len(req)
+                       inPayload.WireLength = len(req) + len(p.header)
                }
                if pf == compressionMade {
                        var err error
@menghanl menghanl self-assigned this Dec 14, 2017
@canguler canguler added the fixit label Jun 5, 2019
@menghanl menghanl assigned canguler and unassigned menghanl Jun 5, 2019
@stale
Copy link

stale bot commented Sep 6, 2019

This issue is labeled as requiring an update from the reporter, and no update has been received after 7 days. If no update is provided in the next 7 days, this issue will be automatically closed.

@dfawley
Copy link
Member

dfawley commented May 3, 2021

Seems this was fixed with #3886.

@dfawley dfawley closed this as completed May 3, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants