-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Trim some HttpHeader parsing logic on browser-wasm #52572
Conversation
Introduce a new feature switch: System.Net.Http.MinimalHeaderValidation. When set to `true`, this switch will allow for trimming header parsing logic that may not be needed in the app. Contributes to dotnet#44534
Tagging subscribers to this area: @dotnet/ncl Issue DetailsIntroduce a new feature switch: Contributes to #44534 Before: 2,644,974 bytes So roughly 4.5KB .br compressed savings in a Blazor WASM app. Opening this PR as "draft" to get feedback on the approach. I'm not convinced this savings is worth the tradeoff. Can anyone think of more header parsers that could be removed with the proposed feature switch?
|
Are parsers like DateHeaderParser excluded already? |
No. From what I can tell from the code, we won't be able to exclude parsers like that without a re-design of how the KnownHeaders work. The reason being that there is public API that rely on the parsers being there, and exceptions occur if they aren't. For example, take the runtime/src/libraries/System.Net.Http/src/System/Net/Http/Headers/KnownHeaders.cs Line 45 in 7dc986e
There is a public runtime/src/libraries/System.Net.Http/src/System/Net/Http/Headers/HttpGeneralHeaders.cs Lines 83 to 87 in 7dc986e
If I try to exclude the DateHeaderParser from the
|
How much of the win here is MailAddressParser vs AltSvcHeaderParser? The AltSvcHeaderParser is strictly internal, so there's no issue really with just disabling it for Blazor. @scalablecory any concerns here? As I mentioned in the linked issue, we should strongly consider just removing MailAddressParser entirely. |
Agree AltSvc is only for SocketsHttpHandler and can be removed from browser build. |
And to be clear, we don't need to introduce a feature switch to do this. |
It's pretty much 50/50 from my measurements. MailAddressParser ~2KB compressed. AltSvcHeaderParser ~2KB compressed. |
Introduce a new feature switch:
System.Net.Http.MinimalHeaderValidation
. When set totrue
, this switch will allow for trimming header parsing logic that may not be needed in the app.Contributes to #44534
Before: 2,644,974 bytes
After: 2,640,488 bytes (with new feature switch set)
So roughly 4.5KB .br compressed savings in a Blazor WASM app. Opening this PR as "draft" to get feedback on the approach. I'm not convinced this savings is worth the tradeoff. Can anyone think of more header parsers that could be removed with the proposed feature switch?
cc @CoffeeFlux @marek-safar