pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Nathan Bossart <nathandbossart@gmail.com>
To: Sami Imseih <samimseih@gmail.com>
Cc: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: Improve LWLock tranche name visibility across backends
Date: Fri, 11 Jul 2025 16:58:30 -0500
Message-ID: <aHGJBt37dg37f1bE@nathan> (raw)
In-Reply-To: <CAA5RZ0vK_EuHwGj8nWkb1UwYjDbqvj+ZyiYPYn3CRsU8uwKUsQ@mail.gmail.com>
References: <CAA5RZ0vvED3naph8My8Szv6DL4AxOVK3eTPS0qXsaKi=bVdW2A@mail.gmail.com>
	<aG9/OKQRgPUCxmsX@ip-10-97-1-34.eu-west-3.compute.internal>
	<CAA5RZ0ui5+=Q3ouxbrjSKa1xJvOjDD2tNYfkG-UtJJNNc-4E=g@mail.gmail.com>
	<aHDYHKdEyZiV/Aob@ip-10-97-1-34.eu-west-3.compute.internal>
	<CAA5RZ0vK_EuHwGj8nWkb1UwYjDbqvj+ZyiYPYn3CRsU8uwKUsQ@mail.gmail.com>

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





view thread (107+ messages)  latest in thread

Message-ID: <aHGJBt37dg37f1bE@nathan>
Permalink:  ../aHGJBt37dg37f1bE@nathan/
Also on:    postgresql.org/message-id/aHGJBt37dg37f1bE@nathan

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: nathandbossart@gmail.com, samimseih@gmail.com, bertranddrouvot.pg@gmail.com
  Subject: Re: Improve LWLock tranche name visibility across backends
  In-Reply-To: <aHGJBt37dg37f1bE@nathan>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox