pgsql: Improve accounting for PredXactList, RWConflictPool and PGPROC

From: Tomas Vondra <tomas(dot)vondra(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Improve accounting for PredXactList, RWConflictPool and PGPROC
Date: 2025-04-02 15:16:37
Message-ID: E1tzzpV-002JTh-1K@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Improve accounting for PredXactList, RWConflictPool and PGPROC

Various places allocated shared memory by first allocating a small chunk
using ShmemInitStruct(), followed by ShmemAlloc() calls to allocate more
memory. Unfortunately, ShmemAlloc() does not update ShmemIndex, so this
affected pg_shmem_allocations - it only shown the initial chunk.

This commit modifies the following allocations, to allocate everything
as a single chunk, and then split it internally.

- PredXactList
- RWConflictPool
- PGPROC structures
- Fast-Path Lock Array

The fast-path lock array is allocated separately, not as a part of the
PGPROC structures allocation.

Author: Rahila Syed <rahilasyed90(at)gmail(dot)com>
Reviewed-by: Andres Freund <andres(at)anarazel(dot)de>
Reviewed-by: Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com>
Reviewed-by: Tomas Vondra <tomas(at)vondra(dot)me>
Discussion: https://postgr.es/m/CAH2L28vHzRankszhqz7deXURxKncxfirnuW68zD7+hVAqaS5GQ@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/46df9487d973d00c83a7962935063f3a6518939c

Modified Files
--------------
src/backend/storage/lmgr/predicate.c | 30 ++++++++----
src/backend/storage/lmgr/proc.c | 93 +++++++++++++++++++++++++++---------
2 files changed, 91 insertions(+), 32 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Heikki Linnakangas 2025-04-02 15:21:40 pgsql: docs: Fix column count attribute in table
Previous Message Tom Lane 2025-04-02 15:13:18 pgsql: Need to do CommandCounterIncrement after StoreAttrMissingVal.