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

Conversation

ghost
Copy link

@ghost ghost commented Jun 28, 2019

No description provided.

// TODO: own file
public readonly struct GCConfigInfo
{
public bool AllowVeryLargeObjects { get; }
Copy link
Member

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.

Copy link
Author

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.

Copy link
Member

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

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.

Andy Hanson added 2 commits July 1, 2019 19:24
@Maoni0
Copy link
Member

Maoni0 commented Jul 2, 2019

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

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?

Copy link
Member

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.

Copy link
Member

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.

if (value != nullptr)
{
result.Set(value);
delete value;
Copy link
Member

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.

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

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?


#ifdef _WIN64
iGCAllowVeryLargeObjects = (CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_gcAllowVeryLargeObjects) != 0);
iGCAllowVeryLargeObjects = Configuration::GetKnobBooleanValue(W("System.GC.AllowVeryLargeObjects"), CLRConfig::EXTERNAL_gcAllowVeryLargeObjects);
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 official switch for AllowVeryLargeObjects. It is left over compat quirk from desktop.

@jkotas
Copy link
Member

jkotas commented Jul 2, 2019

yes this is for diagnostics purpose.

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?

@jkotas
Copy link
Member

jkotas commented Jul 2, 2019

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

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?

Copy link
Member

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)

#endif //_WIN64

iGCCpuGroup = Configuration::GetKnobBooleanValue(W("System.GC.CpuGroup"), CLRConfig::EXTERNAL_GCCpuGroup);
iGCHighMemPercent = Configuration::GetKnobDWORDValueWithDefault(W("System.GC.HighMemPercent"), 0);
Copy link
Member

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.

@MeiChin-Tsai
Copy link

per our discussion, please minimize the PR to .NET Core 3.0 necessity and only expose configuration that is completed in design.

@ghost
Copy link
Author

ghost commented Jul 5, 2019

A much smaller version of this is #25574

@maryamariyan
Copy link

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:

  1. In your coreclr repository clone, create patch by running git format-patch origin
  2. In your runtime repository clone, apply the patch by running git apply --directory src/coreclr <path to the patch created in step 1>

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

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"?

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

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.

Copy link
Member

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.

Copy link
Member

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

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dotnet/corefx#42499

}
FCIMPLEND

void QCALLTYPE GCInterface::GetGCConfigValue(const wchar_t* key, QCall::StringHandleOnStack result)
Copy link
Author

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.

Copy link
Member

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.

@sergiy-k sergiy-k added the post-consolidation PRs which will be hand ported to dotnet/runtime label Nov 12, 2019
@ghost
Copy link
Author

ghost commented Nov 20, 2019

Moved to dotnet/runtime#162.

This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-GC post-consolidation PRs which will be hand ported to dotnet/runtime
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants