-
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
Avoid long busy-waiting between hijack retries. #103212
Conversation
return; | ||
} | ||
#else | ||
if (usecs > 10) |
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 is the actual fix. When we need to pause for longer than 10 microseconds, we sleep instead of spinning, thus freeing compute resources to other threads (including ones that we want to progress towards suspending).
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.
10
is a somewhat arbitrary number in the order of context switch cost. (2-10 microseconds).
We are not very sensitive to the exact value. It just means "too short for the sleep to have any advantages".
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 other reason for 10
is that the default timer slack on Linux is 50 microseconds. So the shortest sleep could be on average 25 microseconds anyways if our wakeups are bunched up with other sleepers.
Thus 10
seems like a reasonable threshold to use sleep.
Performance impact on Stage1 ASP.Net benchmark. ======================================================== arm64
======================================================= x64
commands used:
|
Tagging subscribers to this area: @mangod9 |
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
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
Thanks! |
Fixes: #102832
minipal_microdelay
- to have the same implementation for CoreCLR and NativeAOT(not responsible for the regression, just possible corner cases noticed while investigating)