Content-Length: 280476 | pFad | https://github.com/dotnet/runtime/pull/87329

B7 Optimize zero-byte receives on ManagedWebSocket by stephentoub · Pull Request #87329 · dotnet/runtime · GitHub
Skip to content

Optimize zero-byte receives on ManagedWebSocket #87329

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 11, 2023

Conversation

stephentoub
Copy link
Member

Today you can perform a zero-byte receive on ManagedWebSocket, but doing so still issues a request to the underlying stream with the receive header buffer. That in turn can cause the underlying stream to rent and/or pin a buffer. By special-casing zero-byte reads, we can take advantage of any special-casing in the base stream, and hopefully make it so that when the actual read is performed, the data necessary to satisfy it synchronously is already available.

Today you can perform a zero-byte receive on ManagedWebSocket, but doing so still issues a request to the underlying stream with the receive header buffer.  That in turn can cause the underlying stream to rent and/or pin a buffer.  By special-casing zero-byte reads, we can take advantage of any special-casing in the base stream, and hopefully make it so that when the actual read is performed, the data necessary to satisfy it synchronously is already available.
@stephentoub stephentoub requested a review from wfurt June 9, 2023 17:33
@ghost ghost added the area-System.Net label Jun 9, 2023
@ghost ghost assigned stephentoub Jun 9, 2023
@ghost
Copy link

ghost commented Jun 9, 2023

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

Today you can perform a zero-byte receive on ManagedWebSocket, but doing so still issues a request to the underlying stream with the receive header buffer. That in turn can cause the underlying stream to rent and/or pin a buffer. By special-casing zero-byte reads, we can take advantage of any special-casing in the base stream, and hopefully make it so that when the actual read is performed, the data necessary to satisfy it synchronously is already available.

Author: stephentoub
Assignees: -
Labels:

area-System.Net

Milestone: -

Copy link
Member

@wfurt wfurt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@stephentoub stephentoub merged commit 63a9458 into dotnet:main Jun 11, 2023
@stephentoub stephentoub deleted the mwszerobyteread branch June 11, 2023 15:10
@karelz karelz added this to the 8.0.0 milestone Jul 3, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Aug 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/dotnet/runtime/pull/87329

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy