-
Notifications
You must be signed in to change notification settings - Fork 2.6k
WIP: Getting GC settings from runtimeconfig #25469
Conversation
// TODO: own file | ||
public readonly struct GCConfigInfo | ||
{ | ||
public bool AllowVeryLargeObjects { get; } |
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.
As public API, it would be more interesting to expose maximum size of array of given type instead. It is hard-coded as constant in number of places currently that is less than ideal.
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.
The API is internal now -- just needed it for testing.
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.
It needs comments to say so.
public readonly struct GCConfigInfo | ||
{ | ||
public bool AllowVeryLargeObjects { get; } | ||
public bool CpuGroup { get; } |
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.
Many of these look very specialized and platform specific., e.g. CpuGroup
is a Windows-specific, LargePages
can have multiple values on Unix, ... . They do not feel like good durable APIs.
Is the purpose of this API to return the config for diagnostic purposes? I am wondering whether it would better to have an API to return all overriden runtime config settings as Dictionary or something. It may be useful to have API proposal issue in CoreFX to discuss.
@jkotas I asked Andy to change this to an internal API that returns whatever config you are asking for. please take another look. yes this is for diagnostics purpose. |
|
||
#if !defined(FEATURE_REDHAWK) && (defined(_TARGET_AMD64_) || defined(_TARGET_ARM64_)) | ||
BOOL enableGCCPUGroups = CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_GCCpuGroup) != 0; | ||
BOOL enableGCCPUGroups = Configuration::GetKnobBooleanValue(W("System.GC.CpuGroup"), CLRConfig::EXTERNAL_GCCpuGroup); |
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.
This is adding a new official .runtime.json
switch. Is it intentional?
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.
yes, we want to allow all public facing GC configs to be specifiable via runtimeconfig.json.
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.
- It may be useful to get the list of the new public facing configs and make sure that they are designed well and have good names.
- The new public facing GC configs are a new feature that should be approved for 3.0 by @MeiChin-Tsai at this point.
src/vm/comutilnative.cpp
Outdated
if (value != nullptr) | ||
{ | ||
result.Set(value); | ||
delete value; |
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.
This will leak memory when result.Set
throws. Use Holder - we use holders everywhere else in the runtime.
src/inc/configuration.h
Outdated
// - The value of the ConfigurationKnob (searched by name) if it's set (performs a wcstoul) | ||
// - The default value passed in | ||
static DWORD GetKnobDWORDValue(LPCWSTR name, DWORD defaultValue); | ||
static DWORD GetKnobDWORDValueWithDefault(LPCWSTR name, DWORD defaultValue); |
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 was wrong with the old name?
src/vm/eeconfig.cpp
Outdated
|
||
#ifdef _WIN64 | ||
iGCAllowVeryLargeObjects = (CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_gcAllowVeryLargeObjects) != 0); | ||
iGCAllowVeryLargeObjects = Configuration::GetKnobBooleanValue(W("System.GC.AllowVeryLargeObjects"), CLRConfig::EXTERNAL_gcAllowVeryLargeObjects); |
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 official switch for AllowVeryLargeObjects
. It is left over compat quirk from desktop.
There is a difference between internal testing purposes (internal API is ok) and diagnostic purposes (we tell people out there to call this API via reflection). It is just internal testing purposes, correct? |
Also, the change contains both exposing the internal testing API as well as a bunch of new config surface. Should that be split into multiple PRs? |
iGCCpuGroup = Configuration::GetKnobBooleanValue(W("System.GC.CpuGroup"), CLRConfig::EXTERNAL_GCCpuGroup); | ||
iGCHighMemPercent = Configuration::GetKnobDWORDValueWithDefault(W("System.GC.HighMemPercent"), 0); | ||
iGCHeapHardLimit = Configuration::GetKnobULONGLONGValue(W("System.GC.HeapHardLimit")); | ||
fGCLargePages = Configuration::GetKnobBooleanValue(W("System.GC.LargePages"), CLRConfig::EXTERNAL_GCLargePages); |
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.
The large pages come in multiple sizes. Do we need to design for that?
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 think we just let the users specify whether they want to use large pages or not and if so we will use as many larger large pages as we can instead of users having to worry about what size to specify
In reply to: 299312301 [](ancestors = 299312301)
src/vm/eeconfig.cpp
Outdated
#endif //_WIN64 | ||
|
||
iGCCpuGroup = Configuration::GetKnobBooleanValue(W("System.GC.CpuGroup"), CLRConfig::EXTERNAL_GCCpuGroup); | ||
iGCHighMemPercent = Configuration::GetKnobDWORDValueWithDefault(W("System.GC.HighMemPercent"), 0); |
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.
The idea behind the official .runtime.json
config surface is that we will hold it to the same naming standard as public APIs. HighMemPercent
does not look like a good name of a public API.
per our discussion, please minimize the PR to .NET Core 3.0 necessity and only expose configuration that is completed in design. |
A much smaller version of this is #25574 |
Thank you for your contribution. As announced in dotnet/coreclr#27549 this repository will be moving to dotnet/runtime on November 13. If you would like to continue working on this PR after this date, the easiest way to move the change to dotnet/runtime is:
|
src/vm/eeconfig.cpp
Outdated
iGCHeapHardLimitPercent = Configuration::GetKnobDWORDValue(W("System.GC.HeapHardLimitPercent"), 0); | ||
|
||
iGCCpuGroup = Configuration::GetKnobBooleanValue(W("System.GC.CpuGroup"), CLRConfig::EXTERNAL_GCCpuGroup); | ||
iGCHighMemoryPercent = Configuration::GetKnobDWORDValue(W("System.GC.HighMemoryPercent"), 0); |
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.
0 [](start = 93, length = 2)
why is this not reading from the complus variable "GCHighMemPercent"?
src/gc/gcconfig.h
Outdated
// Each one of these keys produces a method on GCConfig with the name "Get{name}", where {name} | ||
// is the first parameter of the *_CONFIG macros below. | ||
#define GC_CONFIGURATION_KEYS \ | ||
BOOL_CONFIG(AllowVeryLargeObjects, "gcAllowVeryLargeObjects", true, "Allow allocation of 2GB+ objects on GC heap") \ |
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.
AllowVeryLargeObjects [](start = 16, length = 21)
why do we need this? GC does not use 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.
It would be best to delete this (in this or separate change). gcAllowVeryLargeObjects
was a desktop compact quirk that serves no real purpose in .NET Core.
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.
SGTM
internal static extern void GetGCConfigValue(string name, StringHandleOnStack retString); | ||
|
||
// internal for now, for testing that configuration works | ||
internal static string GetConfigValue(string name) |
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.
GetConfigValue [](start = 31, length = 14)
Andy, can you please file an API proposal for this? for the next release we should provide this as a public API
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.
dotnet/corefx#42499
src/vm/comutilnative.cpp
Outdated
} | ||
FCIMPLEND | ||
|
||
void QCALLTYPE GCInterface::GetGCConfigValue(const wchar_t* key, QCall::StringHandleOnStack result) |
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.
@jkotas Is this the best way to return a string from a function? GCHeap::GetGCConfigValue
has to always return a newly allocated string, which is then put in to a string holder here, result.Set
is called, then it's deleted. (If we don't always return a newly allocated one, how would we know whether it should be deleted or not?) Alternately we could try to pass the StringHandleOnStack down to gc.cpp, but I don't think it has the necessary headers to deal with those.
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.
GCHeap::GetGCConfigValue has to always return a newly allocated string, which is then put in to a string holder here, result.Set is called, then it's deleted
Yes, that's the way to do it.
Moved to dotnet/runtime#162. |
No description provided.