Reuse compression buffer
Use case(s) - what problem will this feature solve?
gRPC's compression code allocates a bytes.Buffer for each sent message. This code is responsible for 25% of RAM allocations in my program.
https://github.com/grpc/grpc-go/blob/d41b01db97ca2e3627b2c9949fffe8f152a4255d/rpc_util.go#L658
Proposed Solution
Reuse bytes.Buffer using a sync.Pool.
Alternatives Considered
Additional Context
To the folks interested in this behavior that are open to using third-party dependencies, I suggest https://github.com/mostynb/go-grpc-compression
It's got a lot of more efficient algorithms, too.
We've made some recent changes to introduce a new encoding API which addresses this issue. See: https://github.com/grpc/grpc-go/pull/7356
Would appreciate your feedback on how the new changes work for you.
Also, I'm closing this, and if you still have issues, please use https://github.com/grpc/grpc-go/issues/6619 or file a new issue. Thanks.