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

proto: Generate faster code using vtprotobuf #8173

Merged
merged 4 commits into from
May 27, 2021
Merged

Conversation

vmg
Copy link
Collaborator

@vmg vmg commented May 24, 2021

Description

Following up on last weeks upgrade to the ProtoBuf APIv2 and the newest version of GRPC, observing minds will have probably noticed a significant regression on CPU usage and performance during RPC since the upgrade.

This performance regression has multiple sources, but the most notable of them is the removal of the gogo/protobuf generated code that we were using with the ProtoBuf APIv1. In #7519, I replaced the serialization and de-serialization code in Vitess with code autogenerated by the Gogo compiler; this was a significant performance improvement with very little cost, although the change itself was contentious: the Gogo compiler has been abandoned and it's looking for new ownership, so adding it as a dependency to Vitess was a questionable choice, particularly since as soon as we upgraded to ProtoBuf API v2, the generated Gogo compiler was no longer usable.

Lo and behold, a couple months later, and we've upgraded to ProtoBuf APIv2, with the consequent performance regression because the autogenerated code from gogo/protobuf is no longer usable. So what do we do about this?

Introducing protoc-gen-go-vtproto

We're replacing the now-deprecated gogo/protobuf compiler with a proper implementation that has been written from scratch for ProtoBuf APIv2. The new compiler, available at https://github.com/planetscale/vtprotobuf, has been designed as a helper generator that is run alongside the upstream protoc-gen-go, instead of a replacement, and it focuses on generating high-performance (un)marshalling code -- which is the core feature that Vitess used from the old compiler.

There are still more improvements on the pipeline for the new compiler, including, huh, a README, but for now the generated code fully passes both the required and optional conformance suites for ProtoBuf and brings back most of the performance we've missed since the upgrade.

Let's see how it behaves in practice!

Related Issue(s)

Checklist

  • Tests were added or are not required
  • Documentation was added or is not required

Deployment Notes

vmg added 2 commits May 24, 2021 16:58
Signed-off-by: Vicent Marti <vmg@strn.cat>
Signed-off-by: Vicent Marti <vmg@strn.cat>
Signed-off-by: Vicent Marti <vmg@strn.cat>
@vmg
Copy link
Collaborator Author

vmg commented May 25, 2021

I've updated the repo for the new protobuf compiler with a README and examples: https://github.com/planetscale/vtprotobuf

@systay systay added the Benchmark me Add label to PR to run benchmarks label May 26, 2021
Signed-off-by: Vicent Marti <vmg@strn.cat>
Copy link
Collaborator

@systay systay left a comment

Choose a reason for hiding this comment

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

muy rico!

@systay systay merged commit 3f1544c into vitessio:master May 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants