grpc-dotnet
grpc-dotnet copied to clipboard
Improve memory usage when compression is enabled
Compression creates a stream on the server because compression APIs are stream based. e.g. https://github.com/grpc/grpc-dotnet/blob/1625f8942791c82d700802fc7278c543025f0fd3/src/Grpc.AspNetCore.Server/Internal/HttpContextSerializationContext.cs#L239-L248
Right now, a memory stream is created which can allocate a large buffer. We could improve memory usage by reusing buffer with something like https://github.com/microsoft/Microsoft.IO.RecyclableMemoryStream
Using https://github.com/microsoft/Microsoft.IO.RecyclableMemoryStream would add a dependency. It might be possible to build a simpler implementation to avoid the dependency.