-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Remove MS.Extensions.Logging.Console's dependency on ConfigurationBinder #81931
Comments
Tagging subscribers to this area: @dotnet/area-extensions-logging Issue DetailsIn measuring the size of a NativeAOT published ASP.NET app, a considerable amount of size is added when using Console logging.
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 For a full picture of all the code that can be trimmed here, diff the following mstat dumps: no-configbinder-console.txt was created using eerhardt@af48374. To eliminate this code from the application, we should remove the ConfigurationBinder usages in Logging.Console. They come from 2 places: runtime/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerExtensions.cs Line 43 in 46cb4ed
runtime/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerExtensions.cs Line 141 in 46cb4ed
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.
|
CC @layomia for awareness |
This allows ConfigurationBinder, and its dependencies like TypeConverter, to be trimmed in an application that uses Console Logging, like an ASP.NET API application. Fix dotnet#81931
* Remove ConfigurationBinder usage from Console Logging This allows ConfigurationBinder, and its dependencies like TypeConverter, to be trimmed in an application that uses Console Logging, like an ASP.NET API application. Fix #81931 * Ensure invalid configuration data throws appropriate exception.
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
anddotnet publish
on win-x64: 13.2 MB. Removing the linebuilder.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 theSystem.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:
no-configbinder-console.txt was created using eerhardt@af48374.
configbinder-console.txt was created from
main
To eliminate this code from the application, we should remove the ConfigurationBinder usages in Logging.Console. They come from 2 places:
runtime/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerExtensions.cs
Line 43 in 46cb4ed
runtime/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerExtensions.cs
Line 141 in 46cb4ed
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.
The text was updated successfully, but these errors were encountered: