[release/6.0] Remove two async state machines for typical HTTP/1.1 request path #58252
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport of #58092 to release/6.0
Rather than having a dedicated async method for SendAndProcessAltSvcAsync, we can just have the sole call site call DetermineVersionAndSendAsync and ProcessAltSvc. And in DetermineVersionAndSendAsync, special-case the default configuration for SocketsHttpHandler that will result in HTTP/1.1 messages being sent, such that we avoid all the tests for HTTP/2 and HTTP/3 and the async state machine for DetermineVersionAndSendAsync when HTTP/1.1 is being requested and used.
This doesn't entirely get us back to the allocation profile of .NET 5, but it's much closer.
I also noticed an unused parameter to the HTTP/2 and HTTP/3 try send async methods, so I removed those as well, removing those parameters from the corresponding state machines.
Best reviewed without whitespace diffing: https://github.com/dotnet/runtime/pull/58092/files?w=1
Fixes #57977
/cc @stephentoub
Customer Impact
A simple HTTP/1.1 request made with SocketsHttpHandler allocated 1,416 bytes in .NET 5. In release/6.0 currently, that same request allocates 33% more. This changes drops that to almost noise, at just 3% more.
Testing
CI
Risk
Low. Logic didn't change; code was just moved between between async methods, getting rid of several.