Re: Improve LWLock tranche name visibility across backends - Mailing list pgsql-hackers

From Nathan Bossart
Subject Re: Improve LWLock tranche name visibility across backends
Date
Msg-id aHGJBt37dg37f1bE@nathan
Whole thread Raw
In response to Re: Improve LWLock tranche name visibility across backends  (Sami Imseih <samimseih@gmail.com>)
List pgsql-hackers
On Fri, Jul 11, 2025 at 04:32:13PM -0500, Sami Imseih wrote:
> Now, what I think will be a good API is to provide an alternative to
> LWLockRegisterTranche,
> which now takes in both a tranche ID and tranche_name. The new API I propose is
> LWLockRegisterTrancheWaitEventCustom which takes only a tranche_name
> and internally
> calls WaitEventCustomNew to add a new wait_event_info to the hash
> table. The wait_event_info
> is made up of classId = PG_WAIT_LWLOCK and LWLockNewTrancheId().
> 
> I prefer we implement a new API for this to make it explicit that this
> API will both register
> a tranche and create a custom wait event. I do not think we should get
> rid of LWLockRegisterTranche
> because it is used by CreateLWLocks during startup and I don't see a
> reason to change that.
> See the attached v1.

Hm.  I was thinking we could have LWLockNewTrancheId() take care of
registering the name.  The CreateLWLocks() case strikes me as a special
path.  IMHO LWLockRegisterTranche() should go away.

> Is there a concern with a custom wait event to be created implicitly
> via the GetNamed* APIs?

I'm not sure I see any particular advantage to using custom wait events
versus a dedicated LWLock tranche name table.  If anything, the limits on
the number of tranches and the lengths of the names gives me pause.

-- 
nathan



pgsql-hackers by date:

Previous
From: Aleksander Alekseev
Date:
Subject: Re: XLogCtl->ckptFullXid is unused
Next
From: Melanie Plageman
Date:
Subject: Re: eliminate xl_heap_visible to reduce WAL (and eventually set VM on-access)