Skip to content
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

Use ArrayBuffer for write buffer management in HttpConnection #79525

Merged
merged 1 commit into from Jan 2, 2023

Conversation

MihaZupan
Copy link
Member

Contributes to #61223

Similar idea as #79524 - makes the code easier to work with, allowing us to make future improvements such as pooling easier.

This PR replaces the WriteHeadersAsync logic to synchronously buffer the headers, as we do in HTTP/2 and HTTP/3. This also gives us a slight perf advantage.

Sample in-memory numbers copying around 1000-byte requests and 1000-byte responses:

Method Toolchain RequestHeaders ChunkedResponse Mean Error Ratio
SendAsync main 4 False 1.613 us 0.0181 us 1.00
SendAsync pr 4 False 1.345 us 0.0262 us 0.83
SendAsync main 4 True 1.608 us 0.0125 us 1.00
SendAsync pr 4 True 1.364 us 0.0052 us 0.85
SendAsync main 8 False 1.717 us 0.0043 us 1.00
SendAsync pr 8 False 1.506 us 0.0066 us 0.88
SendAsync main 8 True 1.747 us 0.0068 us 1.00
SendAsync pr 8 True 1.544 us 0.0080 us 0.88
SendAsync main 16 False 2.142 us 0.0075 us 1.00
SendAsync pr 16 False 1.874 us 0.0071 us 0.88
SendAsync main 16 True 2.085 us 0.0045 us 1.00
SendAsync pr 16 True 1.872 us 0.0126 us 0.90

@MihaZupan MihaZupan added this to the 8.0.0 milestone Dec 12, 2022
@MihaZupan MihaZupan requested a review from a team December 12, 2022 07:34
@MihaZupan MihaZupan self-assigned this Dec 12, 2022
@ghost
Copy link

ghost commented Dec 12, 2022

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

Issue Details

Contributes to #61223

Similar idea as #79524 - makes the code easier to work with, allowing us to make future improvements such as pooling easier.

This PR replaces the WriteHeadersAsync logic to synchronously buffer the headers, as we do in HTTP/2 and HTTP/3. This also gives us a slight perf advantage.

Sample in-memory numbers copying around 1000-byte requests and 1000-byte responses:

Method Toolchain RequestHeaders ChunkedResponse Mean Error Ratio
SendAsync main 4 False 1.613 us 0.0181 us 1.00
SendAsync pr 4 False 1.345 us 0.0262 us 0.83
SendAsync main 4 True 1.608 us 0.0125 us 1.00
SendAsync pr 4 True 1.364 us 0.0052 us 0.85
SendAsync main 8 False 1.717 us 0.0043 us 1.00
SendAsync pr 8 False 1.506 us 0.0066 us 0.88
SendAsync main 8 True 1.747 us 0.0068 us 1.00
SendAsync pr 8 True 1.544 us 0.0080 us 0.88
SendAsync main 16 False 2.142 us 0.0075 us 1.00
SendAsync pr 16 False 1.874 us 0.0071 us 0.88
SendAsync main 16 True 2.085 us 0.0045 us 1.00
SendAsync pr 16 True 1.872 us 0.0126 us 0.90
Author: MihaZupan
Assignees: MihaZupan
Labels:

area-System.Net.Http

Milestone: 8.0.0

Copy link
Member

@rzikm rzikm left a comment

Choose a reason for hiding this comment

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

LGTM!

@MihaZupan MihaZupan merged commit 88dd8c7 into dotnet:main Jan 2, 2023
@dotnet dotnet locked as resolved and limited conversation to collaborators Feb 1, 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.

None yet

2 participants