Use Inheritance instead of Composition to Reduce allocation in Request Decompression Middleware #42324
Labels
area-middleware
Includes: URL rewrite, redirect, response cache/compression, session, and other general middlesware
area-networking
Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
investigate
Perf
Milestone
I've opened this issue to discuss the idea that I've mentioned in here and here now that Request Decompression Middleware is merged.
At the moment
IDecompressionProvider
is creating a decompression stream and the middleware creates aSizeLimitedStream
which wraps the other one. We could reduce this two streams into one if theIDecompressionProvider
returns a stream that also handle size limit check, and the middleware only createSizeLimitedStream
if the returned stream from theIDecompressionProvider
is not marked withIDontNeedWrapper
interface.The new types for this change are all private, so there's no new public types. By doing this we would reduce one allocation per requests when request body is compressed by
GZip
,Deflate
orBrotli
.The text was updated successfully, but these errors were encountered: