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

From Sami Imseih
Subject Re: Improve LWLock tranche name visibility across backends
Date
Msg-id CAA5RZ0vh7jrGDwJgkKtw-LR5fBH-tRNpGJnPivdKedtqJ7HGCQ@mail.gmail.com
Whole thread Raw
In response to Re: Improve LWLock tranche name visibility across backends  (Nathan Bossart <nathandbossart@gmail.com>)
Responses Re: Improve LWLock tranche name visibility across backends
List pgsql-hackers
> 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.

When we lookup from shared array only, we need to take a shared lock
every lookup. Acquiring that lock is what I am trying to avoid. You
are saying it's not worth optimizing that part, correct?

--
Sami



pgsql-hackers by date:

Previous
From: Sami Imseih
Date:
Subject: Re: GetNamedLWLockTranche crashes on Windows in normal backend
Next
From: Nathan Bossart
Date:
Subject: Re: GetNamedLWLockTranche crashes on Windows in normal backend