pgsql: Introduce a new mechanism for registering shared memory areas

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Introduce a new mechanism for registering shared memory areas
Date: 2026-04-05 23:27:43
Message-ID: E1w9WsZ-00399s-08@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Introduce a new mechanism for registering shared memory areas

This replaces the [Subsystem]ShmemSize() and [Subsystem]ShmemInit()
functions called at postmaster startup with a new set of callbacks.
The new mechanism is designed to be more ergonomic. Notably, the size
of each shmem area is specified in the same ShmemRequestStruct() call,
together with its name. The same mechanism is used in extensions,
replacing the shmem_{request/startup}_hooks.

ShmemInitStruct() and ShmemInitHash() become backwards-compatibility
wrappers around the new functions. In future commits, I will replace
all ShmemInitStruct() and ShmemInitHash() calls with the new
functions, although we'll still need to keep them around for
extensions.

Co-authored-by: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
Reviewed-by: Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>
Reviewed-by: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
Reviewed-by: Robert Haas <robertmhaas(at)gmail(dot)com>
Reviewed-by: Daniel Gustafsson <daniel(at)yesql(dot)se>
Discussion: https://www.postgresql.org/message-id/CAExHW5vM1bneLYfg0wGeAa=52UiJ3z4vKd3AJ72X8Fw6k3KKrg@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/283e823f9dcb03d0be720928b261628af06d3fd4

Modified Files
--------------
doc/src/sgml/system-views.sgml | 4 +-
doc/src/sgml/xfunc.sgml | 158 ++++--
src/backend/bootstrap/bootstrap.c | 2 +
src/backend/postmaster/launch_backend.c | 4 +
src/backend/postmaster/postmaster.c | 19 +-
src/backend/storage/ipc/ipci.c | 29 +-
src/backend/storage/ipc/shmem.c | 824 ++++++++++++++++++++++++++++----
src/backend/storage/ipc/shmem_hash.c | 79 ++-
src/backend/storage/lmgr/proc.c | 3 +
src/backend/tcop/postgres.c | 10 +-
src/backend/utils/hash/dynahash.c | 4 +-
src/include/storage/shmem.h | 159 +++++-
src/include/storage/shmem_internal.h | 41 +-
src/tools/pgindent/typedefs.list | 7 +-
14 files changed, 1144 insertions(+), 199 deletions(-)

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Heikki Linnakangas 2026-04-05 23:27:44 pgsql: Convert buffer manager to use the new shmem allocation functions
Previous Message Andres Freund 2026-04-05 23:11:55 pgsql: instrumentation: Separate per-node logic from other uses