Re: Improve LWLock tranche name visibility across backends

From: Sami Imseih <samimseih(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Nathan Bossart <nathandbossart(at)gmail(dot)com>, 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-19 20:52:33
Message-ID: CAA5RZ0sbo-HAOrTGVoqP3giXKDV_LXL0UGaYs8mfjcS33mn3FQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> Nathan Bossart <nathandbossart(at)gmail(dot)com> writes:
> > On Tue, Aug 19, 2025 at 02:37:19PM -0400, Andres Freund wrote:
> >> Sure, but we don't need to support a large number of tranches. Just make it,
> >> idk, 128 entries long. Adding a dynamically allocated dsm to every server
> >> seems like a waste - ever shared mapping makes fork / exit slower...
>
> > The other issue is that there's presently no limit on the length of a
> > tranche name registered via LWLockRegisterTranche(). Life would become
> > much simpler if we're willing to put a limit on both that and the number of
> > tranches, but thus far we've been trying to avoid it.
>
> I can hardly imagine a reason why it wouldn't be okay to limit the
> lengths of tranche names. But especially so if an unlimited length
> causes practical problems.

If we limit the tranche name to NAMEDATALEN and also limit the
number of tranches an extension can register, we can put this
all in static shared memory (We would still need to have a backend local
cache to allow lookups to avoid going to shared memory).

However, I am not sure what the limit would be for the number of tranches,
and if we do impose something, will it break anything that is out there?

--
Sami

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Nathan Bossart 2025-08-19 20:59:39 Re: Improve LWLock tranche name visibility across backends
Previous Message Jelte Fennema-Nio 2025-08-19 20:49:06 Re: BackendKeyData is mandatory?