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

Implement new Codec that uses mem.BufferSlice instead of []byte #7356

Merged
merged 100 commits into from
Aug 21, 2024

Conversation

PapaCharlie
Copy link
Contributor

@PapaCharlie PapaCharlie commented Jun 26, 2024

This new codec, as outlined in #6619 will allow the reuse of buffers to their fullest extent. Note that this deliberately does not (yet) implement support for stathandlers, however all the relevant APIs have been updated and both old and new Codec implementations are supported.

RELEASE NOTES:

  • TBD

This new codec, as outlined in grpc#6619 will allow the reuse of buffers to their fullest extent. Note that this deliberately does not (yet) implement support for stathandlers, however all the relevant APIs have been updated and both old and new Codec implementations are supported.
encoding/encoding_v2.go Outdated Show resolved Hide resolved
internal/transport/http2_server.go Show resolved Hide resolved
internal/transport/controlbuf.go Show resolved Hide resolved
internal/leakcheck/leakcheck.go Outdated Show resolved Hide resolved
internal/leakcheck/leakcheck_test.go Outdated Show resolved Hide resolved
internal/transport/controlbuf.go Show resolved Hide resolved
internal/transport/http2_server.go Outdated Show resolved Hide resolved
internal/transport/http2_client.go Outdated Show resolved Hide resolved
internal/transport/http2_client.go Show resolved Hide resolved
func (t *http2Server) Write(s *Stream, hdr []byte, data []byte, opts *Options) error {
func (t *http2Server) Write(s *Stream, hdr []byte, data mem.BufferSlice, opts *Options) error {
reader := data.Reader()
data.Free()
Copy link
Member

Choose a reason for hiding this comment

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

Should Reader just take ownership instead of acquiring its own ref? Unconditionally freeing here and in the other usage seems weird.

We may want to call it ToReader to make it obvious that ownership is transferred in that case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Talked about this offline. It's less error prone to have .Reader take a reference and guarantee that it will be there rather than having to make sure Reader has its own reference. The overall attitude towards buffers is that callers to a function manage the lifecycle of buffers, and if a function wants to guarantee that a buffer lives beyond the function returning, it should always take its own reference. This has been updated in the codec as well

@arjan-bal arjan-bal modified the milestones: 1.66 Release, 1.67 Release Aug 16, 2024
@dfawley dfawley modified the milestones: 1.67 Release, 1.66 Release Aug 16, 2024
encoding/encoding_v2.go Outdated Show resolved Hide resolved
encoding/encoding_v2.go Outdated Show resolved Hide resolved
test/timeouts.go Outdated Show resolved Hide resolved
@easwars easwars assigned PapaCharlie and unassigned easwars Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Performance Performance improvements (CPU, network, memory, etc)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants