[Performance improvement] Minimize number of properties placed in the runtimeconfig.json file
@steveisok is already working on this.
Since Feb 26, 2025.
Assessment
This issue has not been assessed yet.
Description
When building the default dotnet new android runtime application, we can see that the following runtimeconfig.json file is generated:
{
"runtimeOptions": {
"tfm": "net10.0",
"frameworks": [
{
"name": "Microsoft.NETCore.App",
"version": "10.0.0-preview.2.25119.7"
},
{
"name": "Microsoft.Android",
"version": "**FromWorkload**"
}
],
"configProperties": {
"System.Diagnostics.Metrics.Meter.IsSupported": false,
"Microsoft.Extensions.DependencyInjection.VerifyOpenGenericServiceTrimmability": false,
"System.ComponentModel.DefaultValueAttribute.IsSupported": true,
"System.ComponentModel.Design.IDesignerHost.IsSupported": false,
"System.ComponentModel.TypeConverter.EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization": false,
"System.ComponentModel.TypeDescriptor.IsComObjectDescriptorSupported": false,
"System.Data.DataSet.XmlSerializationIsSupported": false,
"System.Diagnostics.Debugger.IsSupported": false,
"System.Diagnostics.Tracing.EventSource.IsSupported": false,
"System.Globalization.Invariant": false,
"System.Linq.Enumerable.IsSizeOptimized": true,
"System.Net.Http.EnableActivityPropagation": false,
"System.Net.Http.UseNativeHttpHandler": true,
"System.Reflection.Metadata.MetadataUpdater.IsSupported": false,
"System.Resources.ResourceManager.AllowCustomResourceTypes": false,
"System.Resources.UseSystemResourceKeys": true,
"System.Runtime.CompilerServices.RuntimeFeature.IsDynamicCodeSupported": true,
"System.Runtime.InteropServices.BuiltInComInterop.IsSupported": false,
"System.Runtime.InteropServices.EnableConsumingManagedCodeFromNativeHosting": false,
"System.Runtime.InteropServices.EnableCppCLIHostActivation": false,
"System.Runtime.InteropServices.Marshalling.EnableGeneratedComInterfaceComImportInterop": false,
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false,
"System.StartupHookProvider.IsSupported": false,
"System.Text.Encoding.EnableUnsafeUTF7Encoding": false,
"System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault": true,
"System.Threading.Thread.EnableAutoreleasePool": false,
"Xamarin.Android.Net.UseNegotiateAuthentication": false,
"Switch.System.Reflection.ForceInterpretedInvoke": true,
"Microsoft.Extensions.DependencyInjection.DisableDynamicEngine": true
}
}
}
After a discussion on Discord, it appears that most of those options aren't needed and might not be checked at run time, because the relevant code could have been trimmed away by the trimmer.
Each of those options is passed to CoreCLR runtime at initialization and each of them (both the name and the value) needs to be converted from UTF-8 to Unicode, which means memory allocation and the actual conversion. If a property isn't used, it means the time processing the property and memory allocated for it are both wasted.
It would be very good if we were able to omit unnecessary properties/switches from the JSON file. This could be done in two ways, it appears:
- By adding support to the trimmer to annotate in msbuild those properties it trimmed out, so we can skip them when building the application.
- By adding a way to learn what is the default value of each switch/property, so that we can go over the list and decide which options are set to their defaults, to skip them when building the application.
- Dominant language
- C#
- Stars
- 18.3k
- Forks
- 5.6k
- PR merge metrics
- PR metrics pending
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dotnet/runtime
-
agentic-workflows untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
area-System.Reflection blocking-clean-ci-optional Known Build Error os-mac-os-x untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
area-CodeGen-coreclr untriaged
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
agentic-workflows untriaged
Difficulty 1/5 Under an hour Newbie friendliness 78/100
-
area-VM-meta-mono untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SubtitleEdit/subtitleedit#15108 · 1 comment ·
-
area/docs-content Bug pulumi/docs
Difficulty 1/5 1-3 hours Newbie friendliness 94/100
-
Create parent directories only after the containment check in InstallHelper.TryExtractToDirectory Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
PowerShell/PSResourceGet#2056 ·