-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Allow trimming out HTTP3 support #117012
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
Allow trimming out HTTP3 support #117012
Conversation
Fixes dotnet#77420. This is a meaningful saving to leave on the table. For following app: ```csharp Console.WriteLine(new HttpClient().GetStringAsync("https://bing.com").Result); ``` PublishAot without this switch: 4.91 MB PublishAot with this switch: 4.14 MB We might even go as far as disabling HTTP3 on native AOT by default since dotnet#73290 reached the dreaded Future milestone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces an AppContext switch to allow trimming out HTTP/3 support and reduces native AOT footprint by disabling all HTTP/3 code paths when the switch is off.
- Adds a new
GlobalHttpSettings.SocketsHttpHandler.AllowHttp3
feature switch - Updates
HttpConnectionPool
to guard HTTP/3 code on the new switch - Introduces a trimming test (
QuicTrimmedTest.cs
) and project entry to verify removal ofSystem.Net.Quic
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
src/libraries/System.Net.Http/tests/TrimmingTests/System.Net.Http.TrimmingTests.proj | Registers QuicTrimmedTest.cs with the Http3Support switch disabled |
src/libraries/System.Net.Http/tests/TrimmingTests/QuicTrimmedTest.cs | Implements a console test that ensures the Quic assembly is removed when HTTP/3 is trimmed |
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectionPool/HttpConnectionPool.cs | Surrounds all HTTP/3 usage with AllowHttp3 checks |
src/libraries/System.Net.Http/src/System/Net/Http/GlobalHttpSettings.cs | Defines the System.Net.SocketsHttpHandler.Http3Support feature switch and AllowHttp3 property |
Comments suppressed due to low confidence (2)
src/libraries/System.Net.Http/src/System/Net/Http/GlobalHttpSettings.cs:43
- Add an XML documentation comment above the
AllowHttp3
property to explain its purpose, default behavior, and how to override it at runtime or via AppContext.
[FeatureSwitchDefinition("System.Net.SocketsHttpHandler.Http3Support")]
src/libraries/System.Net.Http/tests/TrimmingTests/System.Net.Http.TrimmingTests.proj:12
- Consider adding a runtime functional test to verify that setting
AllowHttp3
to false actually prevents HTTP/3 connections inHttpClient
, not just trimming the assembly.
<TestConsoleAppSourceFiles Include="QuicTrimmedTest.cs">
.../System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectionPool/HttpConnectionPool.cs
Outdated
Show resolved
Hide resolved
.../System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectionPool/HttpConnectionPool.cs
Outdated
Show resolved
Hide resolved
/fyi @simonrozsival |
One thing I obviously struggled with is why we have both IsHttp3Supported and AllowHttp3, so now some places need to check both to get actual dead code elimination (IsHttp3Supported is not deadcoded outside the select few platforms I assume). Maybe there should be just one place to control this, but I didn't want to regress mobile platforms and I'm not sure if it is actually allowed to enable HTTP3 on mobile platforms (feature switches can be overriden; what is in IsHttp3Supported is currently hardcoded and cannot be changed at publish/runtime). |
cc: @karelz |
.../System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectionPool/HttpConnectionPool.cs
Outdated
Show resolved
Hide resolved
dotnet/sdk part of this at dotnet/sdk#49564. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Control over this is moving from dotnet/runtime repo build time to publish time so we need to set a default that matches the old build-time setting. Ref #117012 Ref dotnet/sdk#49564
Control over this is moving from dotnet/runtime repo build time to publish time so we need to set a default that matches the old build-time setting. Ref dotnet/runtime#117012 Ref dotnet/sdk#49564
Control over this is moving from dotnet/runtime repo build time to publish time so we need to set a default that matches the old build-time setting. Ref dotnet/runtime#117012 Ref #49564
Control over this is moving from dotnet/runtime repo build time to publish time so we need to set a default that matches the old build-time setting. Ref dotnet/runtime#117012 Ref dotnet/sdk#49564
Pull requests that should ideally merge before this one so that perf infra doesn't unnecessarily pick up a size regression.
Phew. Hope I didn't miss a spot. |
Control over this is moving from dotnet/runtime repo build time to publish time so we need to set a default that matches the old build-time setting. Ref dotnet/runtime#117012 Ref dotnet/sdk#49564
Control over this is moving from dotnet/runtime repo build time to publish time so we need to set a default that matches the old build-time setting. Ref dotnet/runtime#117012 Ref #49564
Context: dotnet/runtime#117012 Context: dotnet/sdk#49564 Control over this is moving from dotnet/runtime repo build time to publish time so we need to set a default that matches the old build-time setting.
Control over this is moving from dotnet/runtime repo build time to publish time so we need to set a default that matches the old build-time setting. Ref dotnet/runtime#117012 Ref dotnet/sdk#49564 This is a re-creation of #23221 using origin, since we can't build PRs from forks. --------- Co-authored-by: Michal Strehovský <MichalStrehovsky@users.noreply.github.com>
Fixes #77420.
This is a meaningful saving to leave on the table. For following app:
PublishAot without this switch: 4.91 MB
PublishAot with this switch: 4.14 MB
We might even go as far as disabling HTTP3 on native AOT by default since #73290 reached the dreaded Future milestone and as far as I understand HTTP3 doesn't actually work without extra gestures anyway.