Don't Sleep(1) in some spin-wait loops (dotnet/coreclr#21722)
authorKoundinya Veluri <kouvel@users.noreply.github.com>
Mon, 31 Dec 2018 05:56:54 +0000 (21:56 -0800)
committerJan Kotas <jkotas@microsoft.com>
Mon, 31 Dec 2018 05:56:54 +0000 (19:56 -1000)
commitb4f18e87df69066faf8ffb5dfbb6f76a20afcc99
tree0fe6f6e92497c80eea54facab35347b64906e175
parent6a9b7880922609f307545e2e6eb6df1dc48dbe44
Don't Sleep(1) in some spin-wait loops (dotnet/coreclr#21722)

- In spin-wait loops that are not expected to last too long, Sleep(1) significantly delays threads from completing the operation
- From eliminating Sleep(1) in such spin-wait loops, there can be a tradeoff, better fairness vs worse throughput, because Sleep(1) removes threads from contention and in some cases fewer threads can make faster progress at the cost of delaying the Sleep(1) threads relatively significantly. Eliminating the Sleep(1) in such spin-wait loops seems to be a good tradeoff.

Commit migrated from https://github.com/dotnet/coreclr/commit/7bd31ac770062fdcf75ad19dabcd7c8ba60bc29c
src/libraries/System.Private.CoreLib/src/System/Collections/Concurrent/ConcurrentQueueSegment.cs
src/libraries/System.Private.CoreLib/src/System/Threading/ManualResetEventSlim.cs
src/libraries/System.Private.CoreLib/src/System/Threading/SpinWait.cs