Skip to content

Make the HTTP.sys accept loop cheaper #28345

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
5 commits merged into from
Dec 4, 2020
Merged

Make the HTTP.sys accept loop cheaper #28345

5 commits merged into from
Dec 4, 2020

Conversation

davidfowl
Copy link
Member

@davidfowl davidfowl commented Dec 3, 2020

  • Allocate a single AsyncAcceptContext per loop instead of one per request.
  • The AsyncAcceptContext now implements IValueTaskSource instead of
    Task and doesn't allocate a Task per request.
  • Use a preallocated overlapped since we don't have overlapping calls to accept for a single AsyncAcceptContext.
  • Remove some dead code from SafeNativeOverlapped
  • Move the NativeOverlapped* to the AsyncAcceptContext

Contributes to #22022

- Allocate a single AsyncAcceptContext per loop instead of one per request.
- The AsyncAcceptContext now implements IValueTaskSource instead of
Task and doesn't allocate a Task per request.
- Use a preallocated overlapped since we don't have overlapping calls to accept for a single AsyncAcceptContext.
- Remove some dead code from SafeNativeOverlapped
if (statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS &&
statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_IO_PENDING)
{
// some other bad error, possible(?) return values are:
Copy link
Member Author

Choose a reason for hiding this comment

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

No disposal is done here since the caller will end up calling AcceptAsync again and that will end up clearing the previously allocated request context (same goes for all other places that used to call dispose).

- Move NativeOverlapped* to the AsyncAcceptContext. This removes the SafeNativeOverlapped allocation as the lifetime is managed by the AsyncAcceptContext
- Rename tcs
@davidfowl
Copy link
Member Author

davidfowl commented Dec 4, 2020

@Tratcher #28347 depends on this PR so is that approval transitive?

@Tratcher
Copy link
Member

Tratcher commented Dec 4, 2020

No, just the diff. I'll take a look at this one soon.

@ghost
Copy link

ghost commented Dec 4, 2020

Hello @davidfowl!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit 5d4dac2 into master Dec 4, 2020
@ghost ghost deleted the davidfowl/accept-loop branch December 4, 2020 21:45
@davidfowl davidfowl added this to the 6.0-preview1 milestone Dec 11, 2020
@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Jun 6, 2023
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants