Re: Lockless queue of waiters in LWLock - Mailing list pgsql-hackers

From Alexander Korotkov
Subject Re: Lockless queue of waiters in LWLock
Date
Msg-id CAPpHfduRgLH9a+U=6pYR7KawCosNO764ojCZkSajdFAbbE8sgQ@mail.gmail.com
Whole thread Raw
In response to Re: Lockless queue of waiters in LWLock  (Andres Freund <andres@anarazel.de>)
Responses Re: Lockless queue of waiters in LWLock
List pgsql-hackers
Hi, Andres!

On Fri, Nov 4, 2022 at 10:07 PM Andres Freund <andres@anarazel.de> wrote:
> The use of cmpxchg vs lock inc/lock add/xadd is one of the major reasons why
> lwlocks are slower than a spinlock (but obviously are better under contention
> nonetheless).
>
>
> I have a benchmark program that starts a thread for each physical core and
> just increments a counter on an atomic value.

Thank you for this insight!  I didn't know xadd is much cheaper than
cmpxchg unless there are retries.  I also wonder how cmpxchg becomes
faster with higher concurrency.

------
Regards,
Alexander Korotkov



pgsql-hackers by date:

Previous
From: Pavel Luzanov
Date:
Subject: Re: Add proper planner support for ORDER BY / DISTINCT aggregates
Next
From: John Naylor
Date:
Subject: Re: [PoC] Improve dead tuple storage for lazy vacuum