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

pkg/proto: adopt CodecV2 and gRPC buffer pooling #2070

Merged
merged 1 commit into from
Oct 31, 2024

Conversation

jzelinskie
Copy link
Member

@jzelinskie jzelinskie commented Sep 18, 2024

This replaces our existing gRPC codec (which enabled us to use vtprotobuf) with the new v2 codec interface that can support buffer pooling.

Huge thanks to engineers from Google and LinkedIn for fleshing out this work and upstreaming the necessary changes. There was a great talk from gRPConf I can share once it's uploaded to YouTube.

I did regenerate our go.mod which combined all of the indirect dependencies into one block. If there were purposely split out, I can fix it.

See the sister PR to this introducing the Codec for Vitess: vitessio/vitess#16790

@jzelinskie jzelinskie requested a review from a team as a code owner September 18, 2024 20:25
@github-actions github-actions bot added the area/dependencies Affects dependencies label Sep 18, 2024
Copy link
Contributor

@tstirrat15 tstirrat15 left a comment

Choose a reason for hiding this comment

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

See comment; I'll let someone more familiar with the internals give an approval.

pkg/proto/dispatch/v1/01_codec.go Show resolved Hide resolved
@vmg
Copy link

vmg commented Sep 20, 2024

@jzelinskie We have quite a bit of work left before the Vitess PR is green... I would really like to see how these changes affect spicedb benchmarks. Do you have a plan to benchmark this branch? Cheers!

@jzelinskie jzelinskie force-pushed the grpc-codecv2 branch 3 times, most recently from ec25c3f to 1a0d8be Compare September 24, 2024 14:40
size := m.SizeVT()
if mem.IsBelowBufferPoolingThreshold(size) {
buf := make([]byte, size)
n, err := m.MarshalToSizedBufferVT(buf[:size])
Copy link
Member

Choose a reason for hiding this comment

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

if we're allocating the buffer as size of size, why do we need to slice here and below?

Copy link
Member Author

Choose a reason for hiding this comment

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

I cleaned this up a bit to try and make it more clear (and after checking guarantees from the pool implementations).
I'm being defensive for the scenario where the number of bytes written are not actually the exact size of the buffer, which looks possible based on the generated code.

@jzelinskie
Copy link
Member Author

@jzelinskie We have quite a bit of work left before the Vitess PR is green... I would really like to see how these changes affect spicedb benchmarks. Do you have a plan to benchmark this branch? Cheers!

We're getting out 2 stable releases of SpiceDB and then looking to begin testing this in some different staging environments to see how it goes.

Copy link
Member

@josephschorr josephschorr left a comment

Choose a reason for hiding this comment

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

LGTM

@josephschorr josephschorr added this pull request to the merge queue Oct 31, 2024
Merged via the queue into authzed:main with commit eef3c2f Oct 31, 2024
22 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Oct 31, 2024
@jzelinskie jzelinskie deleted the grpc-codecv2 branch October 31, 2024 19:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/dependencies Affects dependencies
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants