Remove some unnecessary spinning (#21437)
authorStephen Toub <stoub@microsoft.com>
Sat, 8 Dec 2018 02:14:44 +0000 (21:14 -0500)
committerJan Kotas <jkotas@microsoft.com>
Sat, 8 Dec 2018 02:14:44 +0000 (18:14 -0800)
commit1cba6f8c32a74a7e7e20fad004be6796a7282c94
tree0c93ffddcde45cd2649bbdf995c2301c1f0ee819
parent615a321f5226e0d9389741f4fcec9b6944e319cb
Remove some unnecessary spinning (#21437)

Most of the use of SpinWait in CoreLib involves waiting for some short-lived operation to complete on another thread, in which case the spinning thread should backoff as it's unable to make forward progress until the other operation completes.  In a few cases, however, SpinWait is being used just around CompareExchange operations, such that at least one thread running this code path is guaranteed to make forward progress, and the backoff in the spinning doesn't actually help (in theory it could help to reduce contention if lots of threads were all trying to CompareExchange concurrently, but in such cases you'd actually want more randomized backoff, as otherwise it's likely all the threads would re-attempt at around the same time and similarly re-encounter contention).
src/System.Private.CoreLib/shared/System/Collections/Concurrent/ConcurrentQueueSegment.cs
src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs