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

Save two allocations by making MapRPCWriter and SerializingRPCWriter generic over wrapped writer #1983

Merged
merged 3 commits into from
Jul 17, 2024

Conversation

gjcairo
Copy link
Collaborator

@gjcairo gjcairo commented Jul 16, 2024

Motivation

We currently wrap a base writer into an RPCWriter inside the MapRPCWriter and SerializingRPCWriter.
This results in an unnecessary allocation in both cases. In the case of unary requests, this means two extra allocations per requests on the client side.

Modifications

Make the MapRPCWriter and SerializingRPCWriter generic over the base writer, to avoid the extra allocations caused by wrapping them in an RPCWriter.

Result

Two fewer allocations per unary request on the client side.

@gjcairo gjcairo requested a review from glbrntt July 16, 2024 15:54
Copy link
Collaborator

@glbrntt glbrntt left a comment

Choose a reason for hiding this comment

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

Nice one

@glbrntt glbrntt merged commit 9ae6550 into grpc:main Jul 17, 2024
15 of 17 checks passed
@gjcairo gjcairo deleted the rpcwriters-allocs branch July 17, 2024 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants