summaryrefslogtreecommitdiff
path: root/src/vm/ceemain.cpp
diff options
context:
space:
mode:
authorLudovic Henry <luhenry@microsoft.com>2019-04-24 21:38:57 -0700
committerGitHub <noreply@github.com>2019-04-24 21:38:57 -0700
commita9b6851ad1a9551f3f654b654b094147b50e5999 (patch)
tree561f714a16f0aa94ab927f8505f894ccd413a04d /src/vm/ceemain.cpp
parent57a40b91ce8d340f60717b73ab5d779e9f6a53be (diff)
downloadcoreclr-a9b6851ad1a9551f3f654b654b094147b50e5999.tar.gz
coreclr-a9b6851ad1a9551f3f654b654b094147b50e5999.tar.bz2
coreclr-a9b6851ad1a9551f3f654b654b094147b50e5999.zip
Switch to workstation GC in case of constrained CPU resources (#24194)
* Switch to workstation GC in case of constrained CPU resources Right now, if the user sets the configuration so that the server GC is used, the server GC will be loaded even in conditions where we know the workstation GC would fare better. An example of such conditions is constrained environment where there is only 1 or less CPU or with very low memory. This can be harmful if users deploy the same projects on different kind of platforms: deploying to a 20+ cores server and to Azure Functions will require largely different configurations for the runtime. There are already multiple ways for the user to specify to use the server GC or not: - setting `COMPlus_gcServer` as an environment variable - setting `gcServer` in the configuration file - setting `System.GC.Server` passed to `coreclr_initialize` Fix https://github.com/dotnet/coreclr/issues/23949 * Address review * Address review Remove GCToOSInterface::GetCurrentProcessCpuLimit in favor of GCToOSInterface::GetCurrentProcessCpuCount because the CpuLimit is taken into account in the CpuCount again. * Address review Do the work in src/vm/ceemain.cpp otherwise there will be a disparity between what the VM and the GC are running. Before, only the GC would be aware of the switch from server to workstation GC, but not the VM.
Diffstat (limited to 'src/vm/ceemain.cpp')
-rw-r--r--src/vm/ceemain.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/vm/ceemain.cpp b/src/vm/ceemain.cpp
index 3ca3356717..10216f58ec 100644
--- a/src/vm/ceemain.cpp
+++ b/src/vm/ceemain.cpp
@@ -458,7 +458,7 @@ void InitializeStartupFlags()
g_IGCconcurrent = 0;
- g_heap_type = (flags & STARTUP_SERVER_GC) == 0 ? GC_HEAP_WKS : GC_HEAP_SVR;
+ g_heap_type = ((flags & STARTUP_SERVER_GC) && GetCurrentProcessCpuCount() > 1) ? GC_HEAP_SVR : GC_HEAP_WKS;
g_IGCHoardVM = (flags & STARTUP_HOARD_GC_VM) == 0 ? 0 : 1;
}
#endif // CROSSGEN_COMPILE