1/* -------------------------------------------------------------------------
3 * pgstat_checkpointer.c
4 * Implementation of checkpoint statistics.
6 * This file contains the implementation of checkpoint statistics. It is kept
7 * separate from pgstat.c to enforce the line between the statistics access /
8 * storage implementation and the details about individual types of
11 * Copyright (c) 2001-2025, PostgreSQL Global Development Group
14 * src/backend/utils/activity/pgstat_checkpointer.c
15 * -------------------------------------------------------------------------
28 * Report checkpointer and IO statistics
39 * This function can be called even if nothing at all has happened. In
40 * this case, avoid unnecessarily modifying the stats entry.
48#define CHECKPOINTER_ACC(fld) stats_shmem->stats.fld += PendingCheckpointerStats.fld
59#undef CHECKPOINTER_ACC
64 * Clear out the statistics buffer, so it can be re-used.
69 * Report IO statistics
75 * pgstat_fetch_stat_checkpointer() -
77 * Support function for the SQL-callable pgstat* functions. Returns
78 * a pointer to the checkpointer statistics struct.
101 /* see explanation above PgStatShared_Checkpointer for the reset protocol */
105 sizeof(stats_shmem->
stats),
120 sizeof(stats_shmem->
stats),
124 memcpy(&
reset, reset_offset,
sizeof(stats_shmem->
stats));
127 /* compensate by reset offsets */
128#define CHECKPOINTER_COMP(fld) pgStatLocal.snapshot.checkpointer.fld -= reset.fld;
139#undef CHECKPOINTER_COMP
#define MemSet(start, val, len)
Assert(PointerIsAligned(start, uint64))
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
void LWLockRelease(LWLock *lock)
void LWLockInitialize(LWLock *lock, int tranche_id)
static bool pg_memory_is_all_zeros(const void *ptr, size_t len)
void pgstat_snapshot_fixed(PgStat_Kind kind)
PgStat_LocalState pgStatLocal
void pgstat_checkpointer_snapshot_cb(void)
void pgstat_checkpointer_init_shmem_cb(void *stats)
#define CHECKPOINTER_COMP(fld)
void pgstat_report_checkpointer(void)
void pgstat_checkpointer_reset_all_cb(TimestampTz ts)
PgStat_CheckpointerStats * pgstat_fetch_stat_checkpointer(void)
PgStat_CheckpointerStats PendingCheckpointerStats
#define CHECKPOINTER_ACC(fld)
static void pgstat_end_changecount_write(uint32 *cc)
#define pgstat_assert_is_up()
static void pgstat_begin_changecount_write(uint32 *cc)
static void pgstat_copy_changecounted_stats(void *dst, void *src, size_t len, uint32 *cc)
void pgstat_flush_io(bool nowait)
#define PGSTAT_KIND_CHECKPOINTER
PgStat_CheckpointerStats reset_offset
PgStat_CheckpointerStats stats
TimestampTz stat_reset_timestamp
PgStat_ShmemControl * shmem
PgStatShared_Checkpointer checkpointer
PgStat_CheckpointerStats checkpointer