Re: LWLock granular partition lock memory layout

From: Alexandre Felipe <o(dot)alexandre(dot)felipe(at)gmail(dot)com>
To: Nathan Bossart <nathandbossart(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: LWLock granular partition lock memory layout
Date: 2026-10-10 22:43:57
Message-ID: CAE8JnxO699xhiRx=QjBdO3V8wYz32yTkFdhq0aiqa4iXTXwV6w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> I argue that having S partitions is better in several different ways.
>
> a. Concurrency of LW_EXCLUSIVE
> b. Reduced contention on LWLockWaitListLock
> c. Reduced CAS iterations in LWLockAtttemptLock
> d. Reduced waits (that implies wait list access and sleeping)

In theory this has benefits with no compromises.

In practice, it is more impactful than I initially expected.

I thought it would be noticeable only in large scale systems, but even on my
lightweight laptop with 8 cores the results are measurable.

With 128 partitions

clients base patched

1 26371.6 26149.2

8 35659.7 44958.5 +26.1%

Regards,

Alexandre

Attachment Content-Type Size
run-lwlock-aligned-pgbench.sh text/x-sh 2.7 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2026-10-11 00:11:35 Re: index prefetching
Previous Message best xmg 2026-10-10 22:36:49 Re: Hash a ScalarArrayOpExpr whose array is fixed for one execution