You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Remove MS.Extensions.Logging.Console's dependency on ConfigurationBinder #81931
In measuring the size of a NativeAOT published ASP.NET app, a considerable amount of size is added when using Console logging.
dotnet new api -aot and dotnet publish on win-x64: 13.2 MB. Removing the line builder.Logging.AddConsole(): 12.1 MB.
From my investigation, I've determined that ~860KB of size comes from using the ConfigurationBinder, which also pulls in Sytem.ComponentModel.TypeConverter. One reason this is so big is because a bunch of methods on ICollection/IList can be trimmed if we don't include ConfigurationBinder/TypeConverter. There are a lot of generic instantiations of collections (Dictionary, List, etc), and all these interface methods across scores of collection types add up. The methods in the System.Collections.Generic namespace drop by 343 KB alone.
For a full picture of all the code that can be trimmed here, diff the following mstat dumps:
And instead we can hand-write the "configuration => options" deserialization code. This can also improve startup performance, since we won't be using Reflection here.
Another option would be to use #44493, but that isn't available yet. We can always hand-write the code for now, and use the source generator later once available.
Activity
tarekgh commentedon Feb 11, 2023
CC @layomia for awareness
Remove ConfigurationBinder usage from Console Logging
Remove ConfigurationBinder usage from Console Logging (#82098)