Today Kestrel locks and copies buffers into the connection pipe when multiplexing output from multiple streams. We could improve this by using a channel to queue writes to the pipe instead of locking (See
for an example).
This samples shows the difference between a SemaphoreSlim and a Channel<byte[]> and the performance difference is almost 3x with 0 allocations https://gist.github.com/davidfowl/8af7b6fa21df0fe1f150fb5cfeafa8f7.
There was still lock contention in Channels itself but it was pretty optimized.
We should prototype and measure this change.
cc @JamesNK @halter73 @Tratcher
Today Kestrel locks and copies buffers into the connection pipe when multiplexing output from multiple streams. We could improve this by using a channel to queue writes to the pipe instead of locking (See
aspnetcore/src/Servers/Kestrel/Core/src/Internal/Http2/Http2FrameWriter.cs
Line 265 in 9a87636
This samples shows the difference between a
SemaphoreSlimand aChannel<byte[]>and the performance difference is almost 3x with 0 allocations https://gist.github.com/davidfowl/8af7b6fa21df0fe1f150fb5cfeafa8f7.There was still lock contention in Channels itself but it was pretty optimized.
We should prototype and measure this change.
cc @JamesNK @halter73 @Tratcher