On Fri, Jan 31, 2014 at 01:59:02PM -0500, Waiman Long wrote:On 01/31/2014 04:26 AM, Peter Zijlstra wrote:A much more important point for me is that a fair rwlock has a _much_On Thu, Jan 30, 2014 at 04:17:15PM +0100, Peter Zijlstra wrote:Using a ticket lock instead will have the same scalability problem as theThe below is still small and actually works.OK, so having actually worked through the thing; I realized we can
actually do a version without MCS lock and instead use a ticket lock for
the waitqueue.
This is both smaller (back to 8 bytes for the rwlock_t), and should be
faster under moderate contention for not having to touch extra
cachelines.
Completely untested and with a rather crude generic ticket lock
implementation to illustrate the concept:
ticket spinlock as all the waiting threads will spin on the lock cacheline
causing a lot of cache bouncing traffic.
better worst case behaviour than the current mess. That's the reason I
was interested in the qrwlock thing. Not because it can run contended on
a 128 CPU system and be faster at being contended.
If you contend a lock with 128 CPUs you need to go fix that code that
causes this abysmal behaviour in the first place.