-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Read public GC options if available #86068
Read public GC options if available #86068
Conversation
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas Issue DetailsAlso pass RuntimeHostConfigurationOption into --runtimeopt ILC parameter Fixes : #85961
|
0edad47
to
b4a4f08
Compare
These configuration names come from different "namespaces". Like I wrote in #85961 (comment) "We need to either add another blob with the new values, or come up with some sort of mangling so that we can store both key/value pairs in the same blob. I don't have an opinion. Whichever looks better." The approach in this PR will run into issues as soon as there's a conflict between a "Config" name and "Knob" name. Here's how CoreCLR implements this: runtime/src/coreclr/vm/gcenv.ee.cpp Lines 1158 to 1176 in 0b5f137
|
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.
Thanks for taking up the challenge!
@@ -82,6 +82,55 @@ bool RhConfig::ReadConfigValue(_In_z_ const TCHAR *wszName, uint64_t* pValue, bo | |||
} | |||
|
|||
#ifdef FEATURE_EMBEDDED_CONFIG | |||
|
|||
bool RhConfig::ReadKnobValue(_In_z_ const TCHAR *wszName, uint64_t* pValue, bool decimal) |
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 just switched ReadConfigValue
from TCHAR to char*
. Could you rebase against latest main and apply similar changes as in #86393? Cc @elinor-fung
#endif // FEATURE_EMBEDDED_CONFIG | ||
|
||
public: | ||
|
||
bool ReadConfigValue(_In_z_ const TCHAR* wszName, uint64_t* pValue, bool decimal = false); | ||
#ifdef FEATURE_EMBEDDED_CONFIG | ||
bool ReadKnobValue(_In_z_ const TCHAR* wszName, uint64_t* pValue, bool decimal = false); |
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.
decimal = false
doesn't look right - we don't pass this as true for GC settings but the GC settings in runtimeconfig.json are documented to be decimal (as opposed to the GC settings set through environment variables that are hex).
In fact, do we need the hex support in knobs?
|
||
foreach (string option in _runtimeKnobs) | ||
{ | ||
byte[] optionBytes = System.Text.Encoding.ASCII.GetBytes(option); |
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 should use UTF-8 - users can dump anything they want into RuntimeHostConfigurationOption
ItemGroup.
byte[] optionBytes = System.Text.Encoding.ASCII.GetBytes(option); | |
byte[] optionBytes = System.Text.Encoding.UTF8.GetBytes(option); |
We should be already honoring the |
Yes |
|
e4c84c5
to
a0a1a65
Compare
|
||
const ConfigPair* configPairs = (const ConfigPair*)g_embeddedKnobs; | ||
|
||
// Find the first name which matches (case insensitive to be compat with environment variable counterpart) |
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.
TODO: compare with coreclr - is this case insensitive?
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.
Whoops, that TODO was for me, but might as well dump it on you :). Can you compare how this is done in 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.
casesensetive comparison always. for knobs and configs.
const ConfigPair* configPairs = (const ConfigPair*)g_embeddedKnobs; | ||
|
||
// Find the first name which matches (case insensitive to be compat with environment variable counterpart) | ||
for (int iSettings = 0; iSettings < RCV_Count; iSettings++) |
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.
RCV_Count
only make sense if we know the upper bound because this is not something that is user-configurable. RuntimeHostConfigurationOption is unbounded. We need to keep track of the real count. (Same comment applies to other uses of RCV_Count in this file)
@@ -179,6 +191,103 @@ void RhConfig::ReadEmbeddedSettings() | |||
return; | |||
} | |||
|
|||
bool RhConfig::GetEmbeddedKnob(_In_z_ const char* configName, _Out_ const char** configValue) |
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 new methods look very similar to the existing ones. Can we share them?
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 share, we'd delete the concept of RCV_Count
.
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.
Note that there's another PR in flight making changes here so we might want to pause for a moment to avoid conflicts. #86656 cc @elinor-fung
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 sure if sharing make things better, but please take a look.
if (g_pRhConfig->ReadKnobValue(publicKey, &uiValue)) | ||
{ | ||
*value = uiValue != 0; | ||
return 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.
This won't work for settings that specify true
/false
. Could you mirror how this is handled in CoreCLR?
Also pass RuntimeHostConfigurationOption into --runtimeopt ILC parameter Fixes : dotnet#85961
d1a4693
to
b128588
Compare
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.
Thank you!
src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets
Outdated
Show resolved
Hide resolved
Looks like you are tired to babysit me 😄 thank you! |
It was already close enough that we could avoid another round :). Thanks! |
Previously AppContext switches were set by injecting a method that calls `AppContext.SetSwitch` at startup. Use the configuration blob added in dotnet#86068 instead. This makes startup a tiny bit faster and the outputs a tiny bit smaller. Fixes dotnet#77054.
Also pass RuntimeHostConfigurationOption into --runtimeopt ILC parameter Fixes : #85961