pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Rework handling of pending data for backend statistics
Date: Tue, 21 Jan 2025 02:31:41 +0000
Message-ID: <E1ta43J-002edn-Kf@gemulon.postgresql.org> (raw)

Rework handling of pending data for backend statistics

9aea73fc61d4 has added support for backend statistics, relying on
PgStat_EntryRef->pending for its data pending for flush.  This design
lacks in flexibility, because the pending list does some memory
allocation, making it unsuitable if incrementing counters in critical
sections.

Pending data of backend statistics is reworked so the implementation
does not depend on PgStat_EntryRef->pending anymore, relying on a static
area of memory to store the counters that are flushed when stats are
reported to the pgstats dshash.  An advantage of this approach is to
allow the pending data to be manipulated in critical sections; some
patches are under discussion and require that.

The pending data is tracked by PendingBackendStats, local to
pgstat_backend.c.  Two routines are introduced to allow IO statistics to
update the backend-side counters.  have_static_pending_cb and
flush_static_cb are used for the flush, instead of flush_pending_cb.

Author: Bertrand Drouvot, Michael Paquier
Discussion: https://postgr.es/m/66efowskppsns35v5u2m7k4sdnl7yoz5bo64tdjwq7r5lhplrz@y7dme5xwh2r5

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/4feba03d8b925c4cdda460927611d6b17fb01803

Modified Files
--------------
src/backend/utils/activity/pgstat.c          |   4 +-
src/backend/utils/activity/pgstat_backend.c  | 140 ++++++++++++++++++---------
src/backend/utils/activity/pgstat_io.c       |  23 ++---
src/backend/utils/activity/pgstat_relation.c |   4 +-
src/include/pgstat.h                         |   9 ++
src/include/utils/pgstat_internal.h          |   9 +-
6 files changed, 116 insertions(+), 73 deletions(-)



Message-ID: <E1ta43J-002edn-Kf@gemulon.postgresql.org>
Permalink:  ../E1ta43J-002edn-Kf@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1ta43J-002edn-Kf@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Rework handling of pending data for backend statistics
  In-Reply-To: <E1ta43J-002edn-Kf@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox