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: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Andres Freund <andres@anarazel.de>
Cc: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Cc: Rahila Syed <rahilasyed90@gmail.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: Improve LWLock tranche name visibility across backends
Date: Mon, 25 Aug 2025 16:04:56 -0500
Message-ID: <aKzP-H-KzPay-ByM@nathan> (raw)
In-Reply-To: <CAA5RZ0tKoQeTuRsFmUjPAOEXBiyEGyePsqCAy-_oX4eFHSCmHw@mail.gmail.com>
References: <34drxi6kshtzu5aerftjflrm6wfxxw54emyvy4gqemdpxxuhvm@gymw6its72o7>
	<aKTDB5mvSowmC0Lf@nathan>
	<5to6tftuml6nkas4jaaljfzecasvslxq3mumeslh74wsol4mzw@rgxpxxlqqwtf>
	<aKTGF9Fv1ioXa9P5@nathan>
	<876523.1755635201@sss.pgh.pa.us>
	<CAA5RZ0sbo-HAOrTGVoqP3giXKDV_LXL0UGaYs8mfjcS33mn3FQ@mail.gmail.com>
	<aKTlu7mHhx4owx6r@nathan>
	<CAA5RZ0tg0-O3KVrP9UrZWm18OECxK87WNJo=cZy=Gevc+Ui5oA@mail.gmail.com>
	<aKTqiofwo1Eif_3w@nathan>
	<CAA5RZ0tKoQeTuRsFmUjPAOEXBiyEGyePsqCAy-_oX4eFHSCmHw@mail.gmail.com>

On Fri, Aug 22, 2025 at 03:01:53PM -0500, Sami Imseih wrote:
> I kept the local array to serve consecutive reads and to avoid having to
> take a shared lock on shared memory every time GetLWTrancheName is
> called. A new LWLock to protect this array is required.

I'm not seeing why we need this cache anymore.  This is an append-only
list, so we could instead keep a backend-local copy of LWLockCounter that
gets updated as needed.  As long as the ID is less than our backend-local
counter, we can go straight to the shared array.  If it is greater, we'll
have to first update our counter, which should be rare and inexpensive.

-- 
nathan





view thread (107+ messages)  latest in thread

Message-ID: <aKzP-H-KzPay-ByM@nathan>
Permalink:  ../aKzP-H-KzPay-ByM@nathan/
Also on:    postgresql.org/message-id/aKzP-H-KzPay-ByM@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, tgl@sss.pgh.pa.us, andres@anarazel.de, bertranddrouvot.pg@gmail.com, rahilasyed90@gmail.com
  Subject: Re: Improve LWLock tranche name visibility across backends
  In-Reply-To: <aKzP-H-KzPay-ByM@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