Re: Improve LWLock tranche name visibility across backends

From: Sami Imseih <samimseih(at)gmail(dot)com>
To: Nathan Bossart <nathandbossart(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andres Freund <andres(at)anarazel(dot)de>, Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>, Rahila Syed <rahilasyed90(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Improve LWLock tranche name visibility across backends
Date: 2025-08-26 19:56:22
Message-ID: CAA5RZ0u=Fb8dDdPrEzawYjVqAmYB_PTP4Yy3tV78=_gcvXrjjA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> > On Mon, Aug 25, 2025 at 04:59:41PM -0500, Sami Imseih wrote:
> > > hmm, can we really avoid a shared lock when reading from shared memory?
> > > considering access for both reads and writes can be concurrent to shared
> > > memory. We are also taking an exclusive lock when writing a new tranche.
> >
> > We probably want to hold a lock while we 1) increment LWLockCounter and
> > copy a new tranche name to memory and
>
> In the last rev, I removed the spinlock acquired on ShmemLock in-lieu of
> a LWLock. This is because I wanted a single LWLock acquisition while
> both incrementing LWLockCounter and writing to shared memory, and
> doing this much work, particularly writing to shared memory,
> with a spinlock seemed inappropriate. With that said, this is not high
> concurrency of performance sensitive activity at all, so perhaps I was
> being overly paranoid.

Here is v12 that replaces the LWLock to access the shared memory with a
ShmemLock and implements a local counter.

--
Sami

Attachment Content-Type Size
v12-0002-Tests-for-LWLock-tranche-registration-improvemen.patch application/octet-stream 11.0 KB
v12-0001-Improve-LWLock-tranche-registration.patch application/octet-stream 26.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kirill Reshke 2025-08-26 20:01:24 Re: eliminate xl_heap_visible to reduce WAL (and eventually set VM on-access)
Previous Message Nathan Bossart 2025-08-26 19:52:28 Re: vacuumdb --missing-stats-only and permission issue