I have a simple benchmark that loses performance the more you parallelize it beyond 4-6 cores, until eventually it becomes slower than the single-threaded case [1]. And contention on that is not actually that high. That's still better than the macOS case, where performance goes to hell for even two threads, of course.
Here's the output of time for 32 threads (running on a 48-core system):
./a.out -p 32 7.72s user 75.04s system 2603% cpu 3.179 total
as opposed to the sequential case: ./a.out -p 0 1.94s user 0.00s system 99% cpu 1.942 total
As you can see, the program spends the vast majority of the time in the kernel due to blocking constantly. (Note that other factors add to the overhead, too.)In short, you do not want a high degree of contention, anyway. The macOS locks just make contention hurt much more.
[1] https://gist.github.com/rbehrends/27a1ca27ddec7016cd42428b9c...
I'm not saying there's no use case for a fair mutex anywhere (though I'll come really close and say that if you want fairness a lock is the wrong abstraction), I'm saying that stuffing a context switch into every contended call to pthread_mutex_unlock() is a terrible design decision.
Windows locks are fair by default too, BTW (IIRC anyway). People just use the unfair version when they need performance.
Windows XP tried to implement some amount of fairness in its locks but did not guarantee it. Windows Vista gave up on fairness entirely.
You should just be using unfair locks. Thread starvation is rare in most OSes at this point.
Seems like it would be more effective for the WebKit folks to just work on their Darwin compatriots to fix the C library locks, no?