-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Add new configuration mechanism for CoreCLR. #3896
Add new configuration mechanism for CoreCLR. #3896
Conversation
| int forceGCconcurrent = CLRConfig::GetConfigValue(CLRConfig::UNSUPPORTED_gcConcurrent); | ||
| if ((forceGCconcurrent > 0) || (forceGCconcurrent == -1 && g_IGCconcurrent)) | ||
| bool gcConcurrentWasForced = false; | ||
| #ifdef FEATURE_CORECLR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think we need this change and the related change in clrconfig.h.
What will not work if both these changes are reverted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we revert the change in clrconfigvalues.h, the startup flag for concurrent GC will not be enabled unless "System.GC.Concurrent" is explicitly set in the JSON configuration. We can change the code (in unixinterface.cpp) that sets the flag so that it uses the boolean argument fallback instead of the COMPlus one and always returns true if the value isn't explicitly set, but then you won't be able to use the COMPlus mechanism to configure the concurrent GC startup flag.
If we keep the change in clrconfigvalues.h, the existing code here that checks for -1 doesn't make sense anymore for CoreCLR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are looking up the CLRConfig::UNSUPPORTED_gcConcurrent and System.GC.Concurrent both here as well as in InitializeStartupFlags. It is redundant.
I think we should either:
- Lookup both in
InitializeStartupFlagsand do nothing here (put this piece of code here under#ifndef FEATURE_CORECLRifdef)
or
- Lookup just
System.GC.ConcurrentinInitializeStartupFlags(use the overload that takes default value as constant) andUNSUPPORTED_gcConcurrenthere - the existing code here should work just fine for it, no need to ifdef it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't simply ifdef it out entirely because a bit further down, we need to know whether concurrent GC was forced. If it wasn't, we disable concurrent GC if GCStress is enabled.
However, doing the second option does mean that we won't treat the presence of "System.GC.Concurrent": true as the user forcing concurrent GC (in other words, we may turn it off even if they specify it).
If we're okay with that, I can undo the change in clrconfigvalues.h and here, and change InitializeStartupFlags to fallback to 'true' if "System.GC.Concurrent" isn't set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to keep the existing behavior. I think that we do want to be able run GCStress with Concurrent GC enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We definitely should allow the option to run GCStress with concurrent GC enabled - at the very least, you should be able to turn on/off concurrent GC for GCStress 3.
what is the order of evaluation supposed to be here? complus overwrites startup flag which overwrites config?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the order of evaluation supposed to be here? complus overwrites startup flag which overwrites config?
With my changes, we will first determine whether the startup flag for concurrent GC should be set with this criteria:
- If the COMPlus value is set explicitly, we will respect that (treating 1 as true and anything else as false).
- If not, we will check whether the user has set "System.GC.Concurrent" explicitly to true or false in the config file (in the case of CLI this is the JSON configuration) and respect that.
- If neither of them is set explicitly, we will use the default specified in the ConfigDWORDInfo, which for CoreCLR will be 1 (true).
If we go through all that and decide concurrent GC should be on, we will treat that as 'force' enabling. So with no special configuration set for concurrent GC and GCStress on, we will have both enabled. You can turn off concurrent GC by either setting "System.GC.Concurrent" to false in your JSON config or setting the COMPlus value to 0 (or anything other than 1).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
treating 1 as true and anything else as false
Pretty much all existing COMPlus settings treat 0 as false, and everything else as true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok, I will change that in configuration.cpp in my next commit.
7b1f030 to
922cd56
Compare
|
I've updated the PR based on feedback and also updated the code reading ThreadPool_Force[Min|Max]WorkerThreads to use the new system. Please let me know if there are any further comments. |
src/vm/win32threadpool.cpp
Outdated
| // initialize Worker and CP thread settings | ||
| DWORD forceMin; | ||
| forceMin = CLRConfig::GetConfigValue(CLRConfig::INTERNAL_ThreadPool_ForceMinWorkerThreads); | ||
| forceMin = Configuration::GetKnobDWORDValue(W("System.Threading.ThreadPool.MinThreads"), CLRConfig::INTERNAL_ThreadPool_ForceMinWorkerThreads); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please factor this out into a small helper method, so that the actual Configuration call is done in just single place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, done. I added helper functions for getting min/max. For now, the behavior will be the same though (each check results in a lookup). I think we should add a caching mechanism like we have for the old CLRConfig types, but that can be a separate change (not rushed for RC2).
|
LGTM modulo comments |
4ea37db to
13e03b8
Compare
|
Thanks @jkotas. Comments have been addressed. |
13e03b8 to
1aa1b8b
Compare
|
@dotnet-bot test Windows_NT x86 Release Legacy Backend Build and Test please |
|
LGTM |
…lues4 Add new configuration mechanism for CoreCLR. Commit migrated from dotnet/coreclr@775003a
This change allows hosts using
coreclr_initializeto specify configuration properties via key-value strings. The values of these properties can be retrieved at run time using a new mechanism that allows falling back on CLRConfig settings if desired.Addresses #3884.
cc: @sergiy-k @jkotas @Maoni0