You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The dispatch_cascade test is very slow on Windows right now (often taking 4-5
minutes to execute on my machine and sometimes locking it up entirely) because
contention is not being handled correctly.
`_dispatch_contention_usleep()` is expected to put the thread to sleep, but on
Windows it spins on `QueryPerformanceCounter()`. This is causing a huge amount
of starvation in the dispatch_cascade test. Implement it using `Sleep()`, and
accordingly adjust `DISPATCH_CONTENTION_USLEEP_START` to be 1ms on Windows.
Additionally, `_dispatch_contention_spins()` is currently implemented using the
`rand_s()` function. This is slow (and experimentally seems to be slower than
not randomizing the spin count at all!) because `rand_s()` guarantees
cryptographic security, which is unnecessary for dispatch's use case. Replace it
with a basic linear congruential generator (from K&R) since there isn't any
other `rand_r()` equivalent. Based on the average wall clock times reported by
bsdtestharness, this is around 35% faster on my PC (i7-8700K).
These changes bring the runtime of the dispatch_cascade test down to around 1-2s
at most for me. (It's even faster than this if stdout isn't a console window
because that slows down the histogram display.)
0 commit comments