pgsql: Refactor how user-defined LWLock tranches are stored in shmem

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Refactor how user-defined LWLock tranches are stored in shmem
Date: 2026-03-26 22:03:58
Message-ID: E1w5so1-001bOD-12@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Refactor how user-defined LWLock tranches are stored in shmem

Merge the LWLockTranches and NamedLWLockTrancheRequest data structures
in shared memory into one array of user-defined tranches. The
NamedLWLockTrancheRequest list is now only used in postmaster, to hold
the requests until shared memory is initialized.

Introduce a C struct, LWLockTranches, to hold all the different fields
kept in shared memory. This gives an easier overview of what are all
the things kept in shared memory. Previously, we had separate pointers
for LWLockTrancheNames, LWLockCounter and the (shared memory copy of)
NamedLWLockTrancheRequestArray.

Reviewed-by: Nathan Bossart <nathandbossart(at)gmail(dot)com>
Discussion: https://www.postgresql.org/message-id/47aaf57e-1b7b-4e12-bda2-0316081ff50e@iki.fi

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/d6eba30a245cd258e0b62753088202284dc59dc0

Modified Files
--------------
src/backend/postmaster/launch_backend.c | 15 +-
src/backend/storage/lmgr/lwlock.c | 325 ++++++++++++++------------------
src/include/storage/lwlock.h | 7 +-
src/tools/pgindent/typedefs.list | 1 +
4 files changed, 145 insertions(+), 203 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Robert Haas 2026-03-27 00:54:47 pgsql: pg_plan_advice: pgindent
Previous Message Heikki Linnakangas 2026-03-26 21:46:49 pgsql: Rename MAX_NAMED_TRANCHES to MAX_USER_DEFINED_TRANCHES