.NET Run-time Settings
.NET 6+ applications can use the "runtimeconfig.json" file, MSBuild properties and environment variables to set various run-time settings. The performance related settings described below are particularly relevant to actionETL applications, see .NET run-time configuration settings for the full list and further details.
Optimizing Memory Allocation
By default, .NET memory allocations are tuned for interactive applications where low latency (i.e. milliseconds) is desirable. actionETL programs that don't have a user interface or other low latency requirements are instead batch applications, and will (if they have high volume dataflows) almost always run quicker and consume fewer CPU resources by configuring the .NET garbage collector to work in server mode and in the foreground (non-concurrent). This is the recommended default configuration for all actionETL batch applications.
Note
- One rarely significant but possible drawback is that the application can in some cases consume somewhat more memory, see Workstation and server garbage collection for in-depth information.
- Again rarely significant, but you can further fine tune the memory allocation for multiple simultaneous workloads, see Middle Ground between Server and Workstation GC for details. Although written for .NET Framework, the same applies to .NET and its corresponding settings.
runtimeconfig.template.json File
Configure this by adding the following settings to the "runtimeconfig.template.json" project file:
{
"configProperties": {
"System.GC.Concurrent": false,
"System.GC.Server": true,
}
}
[appname].runtimeconfig.json File
Alternatively, you can add them to the published "[appname].runtimeconfig.json""
file, nested under the runtimeOptions property.:
{
"runtimeOptions": {
"tfm": "net6.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "6.0.1"
},
"configProperties": {
"System.GC.Concurrent": false,
"System.GC.Server": true,
}
}
}
MSBuild Properties
You can also add the settings to your MSBuild project file, which would also override any "[myapp].runtimeconfig.json" file settings:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<ConcurrentGarbageCollection>false</ConcurrentGarbageCollection>
<ServerGarbageCollection>true</ServerGarbageCollection>
</PropertyGroup>
</Project>
Environment Variables
You can also use environment variables for these configurations, which override any corresponding MSBuild or "runtimeconfig.json" setting, and also affect all .NET 6+ applications that see these settings:
SET COMPlus_gcConcurrent=0
SET COMPlus_gcServer=1
See Flavors of garbage collection for details.
Compilation Settings
When performance matters, always compile your application as a "Release" build, and with its default "Optimized" setting enabled. Beyond this, in .NET 6+ there are additional compilation settings that affect startup and run-time performance:
- Tiered compilation and Quick JIT can decrease startup time and increase run-time performance. They are enabled by default in .NET 6+.
- ReadyToRun allows pre-compiling for a particular platform to reduce startup time.
In most cases the defaults are perfectly fine, see Run-time configuration options for compilation for details.