Re: Lockless queue of waiters in LWLock

From: Alexander Korotkov <aekorotkov(at)gmail(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Pavel Borisov <pashkin(dot)elfe(at)gmail(dot)com>, Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Lockless queue of waiters in LWLock
Date: 2022-11-05 09:05:43
Message-ID: CAPpHfduRgLH9a+U=6pYR7KawCosNO764ojCZkSajdFAbbE8sgQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi, Andres!

On Fri, Nov 4, 2022 at 10:07 PM Andres Freund <andres(at)anarazel(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message John Naylor 2022-11-05 09:22:54 Re: [PoC] Improve dead tuple storage for lazy vacuum
Previous Message Pavel Luzanov 2022-11-05 08:51:23 Re: Add proper planner support for ORDER BY / DISTINCT aggregates