Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Conversation

@adityamandaleeka
Copy link
Member

This change allows hosts using coreclr_initialize to 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

int forceGCconcurrent = CLRConfig::GetConfigValue(CLRConfig::UNSUPPORTED_gcConcurrent);
if ((forceGCconcurrent > 0) || (forceGCconcurrent == -1 && g_IGCconcurrent))
bool gcConcurrentWasForced = false;
#ifdef FEATURE_CORECLR
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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 InitializeStartupFlags and do nothing here (put this piece of code here under #ifndef FEATURE_CORECLR ifdef)

or

  • Lookup just System.GC.Concurrent in InitializeStartupFlags (use the overload that takes default value as constant) and UNSUPPORTED_gcConcurrent here - the existing code here should work just fine for it, no need to ifdef it.

Copy link
Member Author

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.

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.

Copy link
Member

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?

Copy link
Member Author

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).

Copy link
Member

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

Copy link
Member Author

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.

@adityamandaleeka
Copy link
Member Author

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.

// 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);
Copy link
Member

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?

Copy link
Member Author

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).

@jkotas
Copy link
Member

jkotas commented Mar 25, 2016

LGTM modulo comments

@adityamandaleeka
Copy link
Member Author

Thanks @jkotas. Comments have been addressed.

@sergiy-k
Copy link

@dotnet-bot test Windows_NT x86 Release Legacy Backend Build and Test please

@sergiy-k
Copy link

LGTM

@adityamandaleeka adityamandaleeka merged commit 775003a into dotnet:master Mar 26, 2016
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…lues4

Add new configuration mechanism for CoreCLR.

Commit migrated from dotnet/coreclr@775003a
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants