-
Notifications
You must be signed in to change notification settings - Fork 317
Description
Since .NET Core 2.1, System.IO.Stream has had Read and Write overloads that accept a Span to read to / write from. However, the base Stream implementation isn't optimized. To get the best performance when a caller is using the Span-based APIs, derived implementations of Stream are expected to override the Span-based APIs and perform the operation on the Spans. See the System.IO.Stream section of dotnet/runtime#22387 for more information.
We should consider overriding the Span Read/Write methods on these classes:
| sealed internal class SqlStream : Stream |
SqlClient/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlStream.cs
Line 270 in f2635ca
| sealed internal class SqlCachedStream : Stream |
That way callers using the Span-based APIs get better performance - an ArrayPool buffer doesn't need to be rented, and the data copied twice.
See more conversation here: dotnet/runtime#69879 (comment)