grpc-dotnet icon indicating copy to clipboard operation
grpc-dotnet copied to clipboard

Improve memory usage when compression is enabled

Open JamesNK opened this issue 8 months ago • 0 comments

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.

JamesNK avatar Nov 28 '23 00:11 JamesNK