I was performance tuning our server, and tried specifying the following config, as well as setting GCLatencyMode
to LowLatency
.
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
<runtime>
<gcServer enabled="true"/>
<gcConcurrent enabled="false"/>
</runtime>
This gave me a performance increase, and I was pretty pleased until a colleague pointed out that the two settings are mutually exclusive in .Net 4.
So what configuration will this resolve to? Certainly, GCSettings.IsServerGC
returns true, and there's a very measurable performance gain from setting gcConcurrent
to false.
(I compiled the code I was profiling into a test harness, so although it's usually a server hosted by IIS, all my timings were on a console application)
I have found your answer here: Latency Modes
Default Garbage Collection Modes
If the LatencyMode property is not specified, the default mode is concurrent workstation garbage collection. The mode is dependent on the value of two runtime configuration settings:
<gcConcurrent>
If enabled, this setting specifies that the common language runtime runs workstation garbage collection on a separate thread to support concurrent operations. This setting is enabled by default.
<gcServer>
If enabled, this setting specifies that the common language runtime runs server garbage collection; otherwise, it runs workstation garbage collection. You can enable server garbage collection only on computers with two or more processors. It is not enabled by default. If this setting is enabled, gcConcurrent is automatically disabled.
The default values for GCLatencyMode are as follows:
Interactive when gcConcurrent is enabled and gcServer is disabled.
Batch when gcConcurrent is disabled, or gcServer is enabled.
Thus, when gcServer is enabled, gcConcurrent is automatically disabled. No need to set gcConcurrent to disabled. GCLatencymode runs in batch mode which exaplains the performance increase.
If this is any help now, gcConcurrent setting is used interchangably with background GC in .NET 4.5. The following MSDN blog explains the settings available in .NET 4.5. You can use all settings together, and they are available for both workstation as well as server GC.
While the SustainedLowLatency setting is in effect, generation 0, generation 1, and background generation 2 collections still occur and do not typically cause noticeable pause times. A blocking generation 2 collection happens only if the machine is low in memory or if the app induces a GC by calling GC.Collect().
Also,
In the .NET Framework 4.5, SustainedLowLatency mode is available for both workstation and server GC. To turn it on, set the GCSettings.LatencyMode property to GCLatencyMode.SustainedLowLatency. The .NET Framework 4 includes a LowLatency mode for workstation GC; however, this setting is only intended to be used for short periods of time, whereas SustainedLowLatency mode is intended to be used for much longer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With