aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2025-01-21 11:30:42 +0900
committerMichael Paquier <michael@paquier.xyz>2025-01-21 11:30:42 +0900
commit4feba03d8b925c4cdda460927611d6b17fb01803 (patch)
treee46af58de4754468de9617dc906bd5770aecc5ea /src/include
parent28de66cee5f45e2f173fa60dd6867c810ecabe38 (diff)
downloadpostgresql-4feba03d8b925c4cdda460927611d6b17fb01803.tar.gz
postgresql-4feba03d8b925c4cdda460927611d6b17fb01803.zip
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
Diffstat (limited to 'src/include')
-rw-r--r--src/include/pgstat.h9
-rw-r--r--src/include/utils/pgstat_internal.h9
2 files changed, 14 insertions, 4 deletions
diff --git a/src/include/pgstat.h b/src/include/pgstat.h
index 2d40fe3e70f..d0d45150977 100644
--- a/src/include/pgstat.h
+++ b/src/include/pgstat.h
@@ -540,6 +540,15 @@ extern PgStat_ArchiverStats *pgstat_fetch_stat_archiver(void);
* Functions in pgstat_backend.c
*/
+/* used by pgstat_io.c for I/O stats tracked in backends */
+extern void pgstat_count_backend_io_op_time(IOObject io_object,
+ IOContext io_context,
+ IOOp io_op,
+ instr_time io_time);
+extern void pgstat_count_backend_io_op(IOObject io_object,
+ IOContext io_context,
+ IOOp io_op, uint32 cnt,
+ uint64 bytes);
extern PgStat_Backend *pgstat_fetch_stat_backend(ProcNumber procNumber);
extern bool pgstat_tracks_backend_bktype(BackendType bktype);
extern void pgstat_create_backend(ProcNumber procnum);
diff --git a/src/include/utils/pgstat_internal.h b/src/include/utils/pgstat_internal.h
index 8914aaca9ab..a3d39d2b725 100644
--- a/src/include/utils/pgstat_internal.h
+++ b/src/include/utils/pgstat_internal.h
@@ -624,10 +624,11 @@ extern void pgstat_archiver_snapshot_cb(void);
#define PGSTAT_BACKEND_FLUSH_IO (1 << 0) /* Flush I/O statistics */
#define PGSTAT_BACKEND_FLUSH_ALL (PGSTAT_BACKEND_FLUSH_IO)
-extern void pgstat_flush_backend(bool nowait, bits32 flags);
-extern PgStat_BackendPending *pgstat_prep_backend_pending(ProcNumber procnum);
-extern bool pgstat_backend_flush_cb(PgStat_EntryRef *entry_ref, bool nowait);
-extern void pgstat_backend_reset_timestamp_cb(PgStatShared_Common *header, TimestampTz ts);
+extern bool pgstat_flush_backend(bool nowait, bits32 flags);
+extern bool pgstat_backend_flush_cb(bool nowait);
+extern bool pgstat_backend_have_pending_cb(void);
+extern void pgstat_backend_reset_timestamp_cb(PgStatShared_Common *header,
+ TimestampTz ts);
/*
* Functions in pgstat_bgwriter.c