-
-
Notifications
You must be signed in to change notification settings - Fork 68
Description
Discussed in #503
Originally posted by plonkaadam July 1, 2022
I'm trying to send a large binary file using MultiplexingStream over TcpSocket. I tried to send it directly using sockets (for now on loopback interface) and I'm able to transfer over 10GB/s.
When I try to do the same using MultiplexingStream and return Stream, PipeReader or create separate channel I could get up to only 80MB/s.
I tried to increase the buffer sizes but with no luck. Does the MultiplexingStream add so much overhead that it's not possible to get it any faster?
// after lot of tries I found out that there is a significant difference in speed between versions and I tried to use the newest one
Average speeds I got on my laptop are:
V1 - 118.11 MBps
V2 - 41.5 MBps
V3 - 48.0 MBps
Anyway - this application will run on a much slower device which during my initial tests got only up to 8MBps on V3; there's still a huge gap between multiplexed stream and raw stream speeds. Is there any way to make it faster?
Great library btw
In testing this, I measured 2-4Gbps using FullDuplexStream (basically raw pass through with no I/O overhead). That represents the ceiling of perf we might achieve (on my machine). MultiplexingStream V1 achieves 1.3Gbps, V2 931Mbps, and V3 599Mbps. So we indeed have a perf hit, and it gets worse with each protocol version. MessagePack slows down v2, and I'm not sure about V3 (window size handling, perhaps?).
What's particularly interesting is that when the transport is a named pipe instead of FullDuplexStream, mxstream slows to below 100Mbps. We should compare raw binary transfers across named pipes, for a fair comparison. But it may be that the frequency of flushes or some other Stream call has particularly high overhead when doing real I/O that involves the Windows kernel. We should look into both.