Skip to content

SqlStream and SqlCachedStream should consider overriding Span Read/Write methods #1628

@eerhardt

Description

@eerhardt

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 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions