Skip to content

Make GCToEEInterface::Get*ConfigValue check the runtimeconfig.json - #34797

Merged
cshung merged 1 commit into
dotnet:masterfrom
cshung:dev/andrewau/config
Apr 18, 2020
Merged

cshung merged 1 commit into
dotnet:masterfrom
cshung:dev/andrewau/config

Conversation

@cshung

@cshung cshung commented Apr 9, 2020 •

Copy link
Copy Markdown
Contributor

Fixes #12948
Fixes #32956

@cshung
cshung requested a review from Maoni0 April 9, 2020 23:53
@ghost

ghost commented Apr 9, 2020

Copy link
Copy Markdown

Tagging @Maoni0 as an area owner

@Maoni0

Maoni0 commented Apr 10, 2020

Copy link
Copy Markdown
Member

since now you are checking both env var and runtimeconfig in gcenv.ee.cpp, it means we can get rid of code like this:

    if (strcmp(privateKey, "GCSegmentSize") == 0)
    {
        *value = g_pConfig->GetSegmentSize();
        return true;
    }

and not get the configs in eeconfig.cpp at all unless they are also used on the VM side (like LOHThresHold).

@cshung

cshung commented Apr 10, 2020 •

Copy link
Copy Markdown
Contributor Author

In an ideal world, all the configuration related logic should go through the table-driven logic I refined in this PR. But as I started to go through the individual public configuration keys to find opportunities to eliminate manually written code. I detected all sort of inconsistencies in the code with respect to these knobs summarized below:

Tables Note
System.GC.Server Unix/Corerun/CorerunCommon
System.GC.Concurrent Unix/Corerun
System.GC.RetainVM Unix
System.GC.HeapAffinitizeMask Arch specific size
System.GC.HeapHardLimit Arch specific size, Json Only
System.GC.HeapHardLimitPercent Json Only (fixed)
System.GC.LOHThreshold Used in profiler
System.GC.NoAffinitize eeconfig not used (fixed)
System.GC.HeapCount eeconfig not used (fixed)

(These items are not in a particular order)

The first three are boolean flags, they might be specified through the STARTUP_FLAGS

void InitializeStartupFlags()
{
CONTRACTL {
NOTHROW;
GC_TRIGGERS;
MODE_ANY;
} CONTRACTL_END;
STARTUP_FLAGS flags = CorHost2::GetStartupFlags();
if (flags & STARTUP_CONCURRENT_GC)
g_IGCconcurrent = 1;
else
g_IGCconcurrent = 0;
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

The interesting inconsistency between these flags have to do with where they occurs. If we search for System.GC.Server. It appears in 3 source files related to host initialization, System.GC.Concurrent has only 2, System.GC.RetainVM has only one. This is just weird. At this point I am not sure what the functional differences are and if that is expected or not.

In any case, the table-driven logic wouldn't be able to replace that code, and I will keep the eeconfig logic for them for now.

System.GC.HeapAffinitizeMask and System.GC.HeapHardLimit have an architecture-specific size, this is obvious.

System.GC.HeapHardLimit and System.GC.HeapHardLimitPercent configuration code seems to only read from the json file.

The fact that System.GC.LOHThreshold is used in the profiler code is fine, but this will stop us from using the table.

The last two are interesting, whoever wrote that code go through the work to create an accessor in eeconfig, but the accessor is never called. I experimented with commenting that out, and CoreCLR build just fine.

EDIT: A few easy problems found above are fixed by simply using the table.

@cshung
cshung force-pushed the dev/andrewau/config branch from 68fcb43 to 418366d Compare April 10, 2020 19:07
@Maoni0

Maoni0 commented Apr 10, 2020 •

Copy link
Copy Markdown
Member

thanks for looking into this! System.GC.Server, System.GC.Concurrent and System.GC.RetainVM are specially handled exactly because they can be specified as startup flags and are interpreted in ceemain.cpp as part of handling the startup flags. strictly speaking, only System.GC.Server needs to be specially handled because it dictates which namespace we will be initializing the GCHeap in. Concurrent/RetainVM can always be enabled and disabled as needed. but no one really took the time to unify things like this when we moved to core so I'm glad that you are doing that now.

it's definitely better to make this logic have as little special handling as possible so if we could have a simply policy as you suggested, as much as possible, it'd be great.

@cshung
cshung force-pushed the dev/andrewau/config branch from 418366d to bde7e4f Compare April 15, 2020 16:29
@cshung
cshung force-pushed the dev/andrewau/config branch from bde7e4f to abd949c Compare April 15, 2020 18:08

@Maoni0 Maoni0 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM; also chatted with Andrew offline and he will make a separate PR to address my last comment.

@cshung
cshung merged commit 44ed52a into dotnet:master Apr 18, 2020
@cshung
cshung deleted the dev/andrewau/config branch April 18, 2020 17:21
@ghost ghost locked as resolved and limited conversation to collaborators Dec 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

System.GC.HeapCount not recognised when set via runtimeconfig.json GCToEEInterface::Get*ConfigValue should also check the runtimeconfig.json

2 participants