Skip to content

StreamPipeReader does not amortize ValueTask ReadAsync calls #30169

@benaadams

Description

@benaadams

In usage a StreamPipeReader type normally has very many ReadAsync calls made on it. (Use case WebSockets/SignalR over TLS)

Using the ValueTask overloads for StreamPipeReader read allocates a AsyncStateMachineBox per read (when data is not immediately available)

image

However it could use TryRead for the sync-path and allocating a IValueTaskSource object the first time that fails to back the async read, and then reuse it each time the read needs to go async again.

Related: dotnet/aspnetcore#11940

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions