Skip to content

stats: include message header in stats.InPayload.WireLength#3886

Merged
menghanl merged 2 commits intogrpc:masterfrom
xstephen95x:master
Sep 25, 2020
Merged

stats: include message header in stats.InPayload.WireLength#3886
menghanl merged 2 commits intogrpc:masterfrom
xstephen95x:master

Conversation

@xstephen95x
Copy link
Copy Markdown
Contributor

@xstephen95x xstephen95x commented Sep 18, 2020

Summary

Currently, the stats.InPayload.WireLength actually under-reports the true WireSize of each received message by 5 bytes (headerLen), as it does not include the size of the header going over the wire.
However, stats.OutPayload.WireLength does include the size of the 5 byte header in WireLength.

This leads to the InPayload.WireLength not being equal to the OutPayload.WireLength for the same underlying payload, which further leads to many weird accounting errors.

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla bot commented Sep 18, 2020

CLA Check
The committers are authorized under a signed CLA.

@xstephen95x
Copy link
Copy Markdown
Contributor Author

This aims to fix: #1647

@menghanl menghanl self-requested a review September 24, 2020 20:11
@menghanl menghanl self-assigned this Sep 24, 2020
Copy link
Copy Markdown
Contributor

@menghanl menghanl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this. Suggested a fix in another place.

rpc_util.go Outdated
}
if payInfo != nil {
payInfo.wireLength = len(d)
payInfo.wireLength = len(d) + headerLen
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field is in sync with payInfo.uncompressedBytes (they both don't include the message header).

Add headerLen when HandleRPC is called?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can do!

@menghanl menghanl added this to the 1.33 Release milestone Sep 24, 2020
Copy link
Copy Markdown
Contributor

@menghanl menghanl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix. LGTM.

@menghanl menghanl changed the title Properly report stats.InPayload.WireLength stats: include message header in stats.InPayload.WireLength Sep 25, 2020
@menghanl menghanl merged commit e6c98a4 into grpc:master Sep 25, 2020
vadimi added a commit to vadimi/grpc-client-cli that referenced this pull request Oct 9, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants