For a project which implements its own buffered memory stream I added the int Read(Span<byte> buffer) and void Write(ReadOnlySpan<byte> buffer) signatures and compared the performance of MemoryStream, ArraySegmentStream (custom based on ArrayPool) and RecyclableMemoryStream.
To my surprise, RecyclableMemoryStream is always outperformed by MemoryStream and ArraySegmentStream by a factor of two, as if the Write(ReadOnlyMemory<byte>) is not properly implemented or disabled in RecyclableMemoryStream?
see benchmark results here: OPCFoundation/UA-.NETStandard#2556
see results of BinaryEncoderRecyclableMemoryStream vs BinaryEncoderArraySegmentStream and BinaryEncoderMemoryStream.
Any idea what could be wrong in the benchmark or why RecyclableMemoryStream.Write is always slower?