Dave Watson b23336af96 mutex: fix trylock spin wait contention
If there are 3 or more threads spin-waiting on the same mutex,
there will be excessive exclusive cacheline contention because
pthread_trylock() immediately tries to CAS in a new value, instead
of first checking if the lock is locked.

This diff adds a 'locked' hint flag, and we will only spin wait
without trylock()ing while set.  I don't know of any other portable
way to get the same behavior as pthread_mutex_lock().

This is pretty easy to test via ttest, e.g.

./ttest1 500 3 10000 1 100

Throughput is nearly 3x as fast.

This blames to the mutex profiling changes, however, we almost never
have 3 or more threads contending in properly configured production
workloads, but still worth fixing.
2018-11-28 15:17:02 -08:00
..
2017-03-06 15:08:43 -08:00
2017-08-30 16:47:32 -07:00
2018-11-12 13:20:37 -08:00
2018-08-01 13:27:11 -07:00
2018-11-14 07:09:11 -08:00
2018-07-09 21:40:42 -07:00
2018-05-18 11:43:03 -07:00
2018-11-14 08:44:05 -08:00
2017-10-02 20:44:43 -07:00
2018-04-09 16:50:30 -07:00
2017-05-23 12:26:20 -07:00
2017-03-07 10:25:33 -08:00
2018-08-01 13:27:11 -07:00
2018-10-23 12:39:57 -07:00
2018-07-09 21:40:42 -07:00
2018-11-12 13:20:37 -08:00
2018-08-02 10:16:06 -07:00
2017-05-25 16:52:10 -07:00
2017-05-25 16:52:10 -07:00
2017-10-04 18:37:23 -07:00
2018-10-18 08:32:19 -07:00
2018-07-09 21:40:42 -07:00
2017-04-24 15:02:45 -07:00
2018-08-01 13:27:11 -07:00