Description
Libraries code reduction:
In order to produce a minimally-sized Blazor wasm sample, we will have to also shrink the size of the managed libraries. Current Brotli-compressed sizes indicate that the bulk of our size budget is taken up by four assemblies:
- System.Private.CoreLib (403KB)
- System.Text.Json (78KB)
- System.Net.Http (53KB)
- Microsoft.AspNetCore.Components (45KB)
Every other assembly is around 25KB or lower.
Additionally, all the non-Corelib libraries combined are only barely larger than Corelib itself, and there is no way to get around loading Corelib early in startup. Any work to shrink Corelib will help with native size reduction as well, once we are able to fully link out unused P/Invokes. Given that we have a 0.5MB budget for the entire initial wire transfer and the linked Corelib is around 0.4MB, this effort has no chance of succeeding without a dramatically smaller Corelib. Additional efforts may be necessary, so feel free to add issues to the list, but this should be a good start.
It's worth noting that flags to disable features entirely in the interest of size reduction are very welcome here. The goal is to get the initial wire size as small as possible, and that can mean sacrifices in functionality.
Some of the source generator work is more speculative on the overall size, but it should enable us to trim more code out from Corelib. If we can delay loading of the generated assemblies, it could be a large win.
.NET 6.0.0 :
- SRE types not linked out linker#1588 - SRE types not linked out
- Intrinsics code not linked out in Blazor sample linker#1615 - Intrinsics code not linked out in Blazor sample
- Trimming Http in Blazor wasm Trimming Http in Blazor wasm #44534
- Add feature switch to disable custom .resources reader support (UserResourceSet) Add feature switch to disable custom .resources reader support (UserResourceSet) #45272
- Large memory dependency in OrdinalCasing::ToUpper Large memory dependency in OrdinalCasing::ToUpper #43732
- Add the ability to remove COM support using ILLinker Add the ability to remove COM support using ILLinker #36659
- Trim
Vector128<T>
Vector128<T> is unnecessarily being left in a Blazor WASM default app #47860 - Use size optimized LINQ Consider using .SizeOpt.cs in System.Linq built for Browser/Xamarin/AOT #45399
- JSON serialization source generator Compile-time source generation for System.Text.Json #45448 -- Need @layomia to verify if this is still targetting .NET6 ?
Future release :
- Add feature-switch for invariant TimeZone support Add feature-switch for invariant TimeZone support #37973
- IcuLocaleData.NameIndexToNumericData is not linker friendly IcuLocaleData.NameIndexToNumericData is not linker friendly #47967
- Default Uri constructors brings a lot of dependencies Default Uri constructors brings a lot of dependencies #50359
- Linking out formatting code linker#923 - Linking out formatting code
- Consider stripping names of fields that don't matter linker#1282 - Consider stripping names of fields that don't matter
- Trim out more System.Threading classes in Blazor sample #44528 - [wasm] Trim out more System.Threading classes in Blazor sample
- Trimming System.SR Trimming System.SR #46940
- Trim STAThreadAttribute STAThreadAttribute is unnecessarily being left in a Blazor WASM default app #47861