-
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
Fix Lock spin-waiting on single-proc machines #101513
Conversation
Small fix to check for a single proc during initialization. Also renamed things referring to "minSpinCount" to clarify it a bit.
Tagging subscribers to this area: @mangod9 |
|
||
private static short DetermineMinSpinCount() | ||
private static short DetermineMinSpinCountForAdaptiveSpin() |
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 there is a Min and Max spin count - the actual spincount is obviously computed to be somewhere in the range. Not sure the name change makes it more or less clear.
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 min spin count with adaptive spin is just used as a limit for how low the _spinCount field can go, it can be negative, in which case it's just used as a counter for contentions while skipping spin-waiting until it reaches a value where it tries spin-waiting again. Maybe there's a better name, I can add a comment as well.
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 think it is ok either way.
_spinCount
has dual purpose, but the limit is just a limit.
There are two ways to disable adaptiveness - by setting Min to be equal to Max or by setting it to a negative number. I think it was kind of obvious already.
{ | ||
if (IsSingleProcessor) | ||
{ | ||
return 0; |
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.
Is this the actual fix? - to force "no spin" in singleproc case, even if user specified something max spin 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.
Yea that's the actual fix
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. Thanks!
* Fix Lock spin-waiting on single-proc machines Small fix to check for a single proc during initialization. Also renamed things referring to "minSpinCount" to clarify it a bit.
* Fix Lock spin-waiting on single-proc machines Small fix to check for a single proc during initialization. Also renamed things referring to "minSpinCount" to clarify it a bit.
Small fix to check for a single proc during initialization. Also renamed things referring to "minSpinCount" to clarify it a bit.