-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Added the ability to specify a Spin Count Unit via a GC Configuration #84339
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
Conversation
|
Tagging subscribers to this area: @dotnet/gc Issue DetailsAdded the ability to specify a Spin Count Unit via a GC Configuration and make use of this value in the CC: @mangod9
|
|
Adding @eduardo-vp. Would be good to try out this config to ensure that setting it to something low <10, gets the performance for the app back to 6.0.5 numbers. |
|
how did you test this? you are reading the value from the config very early on in GCHeap::Initialize but we are doing the normal init in initialize_gc which is later. are you seeing that the value is what you specify in the config? |
|
@eduardo-vp, to test this out, you'll need to simply set the environment variable:
|
To test this out, I used a GCPerfSim scenario and debugged both the case where we set Without The Environment VariableIn the Initialize function, we skip setting the In the SetYieldProcessorScalingFactor function, we set the With the Environment Variable Set i.e., DOTNET_GCSpinCountUnit=9In Initialize, I confirmed: In SetYieldProcessorScalingFactor, I confirmed, we weren't updating the yp_spin_count_unit as we were bypassing the original logic altogether as the spin_count_unit_config_p was true: Do let me know if any further tests are needed from a functional perspective. |
|
ok, the new change would work functionally but the code should be moved to next to where we are doing the normal init in initialize_gc, ie, it should be after this code - as this is now part of the initialization logic for this variable. there's no reason to separate the 2 pieces of code which means someone would need to look at 2 places instead of 1. and re your question " if any further tests are needed from a functional perspective." - you should actually let it run and make sure that you are seeing the correct value, for example, if you had dumped the value in |
|
I ran the customer's program with the 48 concurrent instances and got these numbers
It seems for this case the optimal is reached with DOTNET_GCSpinCountUnit=1 and it's even faster than the version they're currently using (6.0.5) |
cshung
left a comment
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.
LGTM
|
/backport to release/7.0 |
|
Started backporting to release/7.0: https://github.com/dotnet/runtime/actions/runs/4633715849 |
|
@mrsharm backporting to release/7.0 failed, the patch most likely resulted in conflicts: $ git am --3way --ignore-whitespace --keep-non-patch changes.patch
Applying: Fixed spin count problem
Using index info to reconstruct a base tree...
M src/coreclr/gc/gc.cpp
M src/coreclr/gc/gcconfig.h
M src/coreclr/gc/gcpriv.h
Falling back to patching base and 3-way merge...
Auto-merging src/coreclr/gc/gcpriv.h
CONFLICT (content): Merge conflict in src/coreclr/gc/gcpriv.h
Auto-merging src/coreclr/gc/gcconfig.h
Auto-merging src/coreclr/gc/gc.cpp
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Fixed spin count problem
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128Please backport manually! |
|
@mrsharm an error occurred while backporting to release/7.0, please check the run log for details! Error: git am failed, most likely due to a merge conflict. |
| uint32_t saved_yp_spin_count_unit = yp_spin_count_unit; | ||
| yp_spin_count_unit = (uint32_t)((float)original_spin_count_unit * scalingFactor / (float)9); | ||
|
|
||
| // It's very suspicious if it becomes 0 and also, we don't want to spin too much. |
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 it's suspicious should it assert (yp_spin_count_unit != 0); again here
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, it makes sense to assert once more. Will work on adding an additional protective assert.
Added the ability to specify a Spin Count Unit via a GC Configuration and make use of this value in the
SetYieldProcessorScalingFactorfunction if the value is valid. If this configuration is not specified, we default to 0 and fall back to the original logic.CC: @mangod9