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: Add callbacks to control flush of fixed-numbered stats
Date: Mon, 09 Sep 2024 02:14:45 +0000
Message-ID: <E1snTvR-000DjY-BN@gemulon.postgresql.org> (raw)

Add callbacks to control flush of fixed-numbered stats

This commit adds two callbacks in pgstats to have a better control of
the flush timing of pgstat_report_stat(), whose operation depends on the
three PGSTAT_*_INTERVAL variables:
- have_fixed_pending_cb(), to check if a stats kind has any pending
data waiting for a flush.  This is used as a fast path if there are no
pending statistics to flush, and this check is done for fixed-numbered
statistics only if there are no variable-numbered statistics to flush.
A flush will need to happen if at least one callback reports any pending
data.
- flush_fixed_cb(), to do the actual flush.

These callbacks are currently used by the SLRU, WAL and IO statistics,
generalizing the concept for all stats kinds (builtin and custom).

The SLRU and IO stats relied each on one global variable to determine
whether a flush should happen; these are now local to pgstat_slru.c and
pgstat_io.c, cleaning up a bit how the pending flush states are tracked
in pgstat.c.

pgstat_flush_io() and pgstat_flush_wal() are still required, but we do
not need to check their return result anymore.

Reviewed-by: Bertrand Drouvot, Kyotaro Horiguchi
Discussion: https://postgr.es/m/ZtaVO0N-aTwiAk3w@paquier.xyz

Branch
------
master

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

Modified Files
--------------
src/backend/utils/activity/pgstat.c      | 63 ++++++++++++++++++++++++++------
src/backend/utils/activity/pgstat_io.c   | 22 ++++++++++-
src/backend/utils/activity/pgstat_slru.c | 13 ++++++-
src/backend/utils/activity/pgstat_wal.c  | 19 +++++++---
src/include/utils/pgstat_internal.h      | 42 +++++++++++----------
5 files changed, 119 insertions(+), 40 deletions(-)



Message-ID: <E1snTvR-000DjY-BN@gemulon.postgresql.org>
Permalink:  ../E1snTvR-000DjY-BN@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1snTvR-000DjY-BN@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: Add callbacks to control flush of fixed-numbered stats
  In-Reply-To: <E1snTvR-000DjY-BN@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