Fix Lock spin-waiting on single-proc machines#101513
Fix Lock spin-waiting on single-proc machines#101513kouvel merged 2 commits intodotnet:mainfrom kouvel:LockSingleProcFix
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.
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.
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.
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.
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.
Yea that's the actual fix
* 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.