From: | Andres Freund <andres(at)anarazel(dot)de> |
---|---|
To: | Alexander Korotkov <aekorotkov(at)gmail(dot)com> |
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 19:32:40 |
Message-ID: | 20221105193240.7vmjirvrlj5qse5h@awork3.anarazel.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
On 2022-11-05 12:05:43 +0300, Alexander Korotkov wrote:
> 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.
The magnitude of the effect is somewhat surprising, I agree. Some difference
makes sense to me, but...
> I also wonder how cmpxchg becomes faster with higher concurrency.
If you're referring to the leading 32/64 that's not concurrency, that's
32/64bit values. Sorry for not being clearer on that.
Greetings,
Andres Freund
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2022-11-05 19:33:10 | Re: Check SubPlan clause for nonnullable rels/Vars |
Previous Message | Andres Freund | 2022-11-05 19:26:45 | Re: pg_reload_conf() synchronously |