pgsql: Use pgstat_kind_infos to read fixed shared statistics

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Use pgstat_kind_infos to read fixed shared statistics
Date: 2024-07-01 05:27:06
Message-ID: E1sO9ZB-003kWY-MN@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Use pgstat_kind_infos to read fixed shared statistics

Shared statistics with a fixed number of objects are read from the stats
file in pgstat_read_statsfile() using members of PgStat_ShmemControl and
following an order based on their PgStat_Kind value.

Instead of being explicit, this commit changes the stats read to iterate
over the pgstat_kind_infos array to find the memory locations to read
into, based on a new shared_ctl_off in PgStat_KindInfo that can be used
to define the position of this stats kind in shared memory. This makes
the read logic simpler, and eases the introduction of future
improvements aimed at making this area more pluggable for external
modules.

Original idea suggested by Andres Freund.

Author: Tristan Partin
Reviewed-by: Andres Freund, Michael Paquier
Discussion: https://postgr.es/m/D12SQ7OYCD85.20BUVF3DWU5K7@neon.tech

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/9004abf6206e815d25b7b763c756cf97b457f3cd

Modified Files
--------------
src/backend/utils/activity/pgstat.c | 74 ++++++++++++++++++-------------------
src/include/utils/pgstat_internal.h | 6 +++
2 files changed, 42 insertions(+), 38 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2024-07-01 05:35:22 pgsql: Apply COPT to CXXFLAGS as well
Previous Message Tom Lane 2024-07-01 03:21:23 pgsql: Further weaken new pg_createsubscriber test on Windows.