-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Garbage collection method is not manageable by environment variables in .net 6 #61674
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Tagging subscribers to this area: @dotnet/gc Issue DetailsDescribe the bugDocumentation mentions that user is able to change the default Server garbage collection to Workstation garbage collection via either To Reproduce
Further technical details
dotnet --info Output
|
I can reproduce this one. I'm wondering what happens if you have both the environment variable and the value set in runtimeconfig.json |
so are you observing that the value in runtimeconfig.json is now overriding what is set in the env. variable? |
In general, the design is that the environment variable should override the settings in The Unfortunately, the The startupFlags are set in Not sure what is going wrong - @davidfowl, can you help us to debug what is happening in these two functions? Maybe we can find the bug there. |
So does this only repro on linux or windows too? |
Windows as well. |
I have found the culprit of this bug, it appears to be this line: runtime/src/coreclr/utilcode/clrconfig.cpp Line 453 in cc44d43
So first thing first, while confusing, Following the analysis above, when the runtime startup, it uses runtime/src/coreclr/utilcode/configuration.cpp Lines 108 to 121 in cc44d43
In the majority of the cases, the code is fine, because there is really no point for someone to specify an environment variable with value that is exactly the default value (for the runtime). Unfortunately, if the user wanted to disable server GC in WebAPI, then the user would set the value to be 0, which also happened to be the default value for the runtime. Now the culprit line of Apparently, that behavior is not what we want in this issue. Given the analysis, it isn't difficult to fix this one, but I wonder why one put in that specific ignore there. In particular, I don't want to regress something else. @AaronRobinsonMSFT, do you know why we want to specifically ignore the cases where the user explicitly specified the environment variable with exactly the default value? |
If I recall that logic was previously there from long back https://github.com/dotnet/coreclr/blob/1d483901530c2d5b8a943fab932e8c184d2c5f36/src/utilcode/clrconfig.cpp#L295-L300 I tried to maintain the identical behavior but it seems there was a branch in the GC case that I missed. The old logic was so intertwined with registry access I'm not sure which part has changed though. |
I would fix this outside of the runtime/src/coreclr/utilcode/clrconfig.cpp Line 580 in cc44d43
|
Thanks for investigating @cshung. We should make a fix in 7 and will possibly need to port to 6. Is the workaround to just remove the setting from runtimeconfig.json then? |
Describe the bug
Documentation mentions that user is able to change the default Server garbage collection to Workstation garbage collection via either
COMPlus_gcServer
(pre .net6) orDOTNET_gcServer
(in .net6) Environment variable.It was working (the COMPlus env) in .net5, but after project upgrade to .net6, both methods seems to be doing nothing, gcServer is always set to true.
MSBuild property is still functioning, we can add
/p:ServerGarbageCollection=false
to the build parameters and we will achieve exactly that.The problem seems to be asp.net related, Console application (with default gc set to Workstation) can be overridden by both of those env variables to Server.
To Reproduce
dotnet new webapi
in .net6System.Runtime.GCSettings.IsServerGC
on startup)Further technical details
dotnet --info Output
The text was updated successfully, but these errors were encountered: