Skip to content

WebSocket doesn't amortize its ValueTask ReadAsync calls #30167

Closed
@benaadams

Description

@benaadams

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

Using the ValueTask overloads for WebSocket read allocates 2x AsyncStateMachineBox per read (when data is not immediately available)

image

However it could allocate once; backing with an IValueTaskSource objects that get allocated for the first async and reused when the read goes async again.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.NetenhancementProduct code improvement that does NOT require public API changes/additionstenet-performancePerformance related issue

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions