PostgreSQL Source Code  git master
pgstat_checkpointer.c File Reference
#include "postgres.h"
#include "utils/memutils.h"
#include "utils/pgstat_internal.h"
Include dependency graph for pgstat_checkpointer.c:

Go to the source code of this file.

Macros

#define CHECKPOINTER_ACC(fld)   stats_shmem->stats.fld += PendingCheckpointerStats.fld
 
#define CHECKPOINTER_COMP(fld)   pgStatLocal.snapshot.checkpointer.fld -= reset.fld;
 

Functions

void pgstat_report_checkpointer (void)
 
PgStat_CheckpointerStatspgstat_fetch_stat_checkpointer (void)
 
void pgstat_checkpointer_init_shmem_cb (void *stats)
 
void pgstat_checkpointer_reset_all_cb (TimestampTz ts)
 
void pgstat_checkpointer_snapshot_cb (void)
 

Variables

PgStat_CheckpointerStats PendingCheckpointerStats = {0}
 

Macro Definition Documentation

◆ CHECKPOINTER_ACC

#define CHECKPOINTER_ACC (   fld)    stats_shmem->stats.fld += PendingCheckpointerStats.fld

◆ CHECKPOINTER_COMP

#define CHECKPOINTER_COMP (   fld)    pgStatLocal.snapshot.checkpointer.fld -= reset.fld;

Function Documentation

◆ pgstat_checkpointer_init_shmem_cb()

void pgstat_checkpointer_init_shmem_cb ( void *  stats)

Definition at line 89 of file pgstat_checkpointer.c.

90 {
92 
94 }
void LWLockInitialize(LWLock *lock, int tranche_id)
Definition: lwlock.c:707
@ LWTRANCHE_PGSTATS_DATA
Definition: lwlock.h:205

References PgStatShared_Checkpointer::lock, LWLockInitialize(), and LWTRANCHE_PGSTATS_DATA.

◆ pgstat_checkpointer_reset_all_cb()

void pgstat_checkpointer_reset_all_cb ( TimestampTz  ts)

Definition at line 97 of file pgstat_checkpointer.c.

98 {
100 
101  /* see explanation above PgStatShared_Checkpointer for the reset protocol */
102  LWLockAcquire(&stats_shmem->lock, LW_EXCLUSIVE);
104  &stats_shmem->stats,
105  sizeof(stats_shmem->stats),
106  &stats_shmem->changecount);
107  stats_shmem->stats.stat_reset_timestamp = ts;
108  LWLockRelease(&stats_shmem->lock);
109 }
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1168
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1781
@ LW_EXCLUSIVE
Definition: lwlock.h:114
PgStat_LocalState pgStatLocal
Definition: pgstat.c:212
static void pgstat_copy_changecounted_stats(void *dst, void *src, size_t len, uint32 *cc)
PgStat_CheckpointerStats reset_offset
PgStat_CheckpointerStats stats
TimestampTz stat_reset_timestamp
Definition: pgstat.h:305
PgStat_ShmemControl * shmem
PgStatShared_Checkpointer checkpointer

References PgStatShared_Checkpointer::changecount, PgStat_ShmemControl::checkpointer, PgStatShared_Checkpointer::lock, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), pgstat_copy_changecounted_stats(), pgStatLocal, PgStatShared_Checkpointer::reset_offset, PgStat_LocalState::shmem, PgStat_CheckpointerStats::stat_reset_timestamp, and PgStatShared_Checkpointer::stats.

◆ pgstat_checkpointer_snapshot_cb()

void pgstat_checkpointer_snapshot_cb ( void  )

Definition at line 112 of file pgstat_checkpointer.c.

113 {
115  PgStat_CheckpointerStats *reset_offset = &stats_shmem->reset_offset;
117 
119  &stats_shmem->stats,
120  sizeof(stats_shmem->stats),
121  &stats_shmem->changecount);
122 
123  LWLockAcquire(&stats_shmem->lock, LW_SHARED);
124  memcpy(&reset, reset_offset, sizeof(stats_shmem->stats));
125  LWLockRelease(&stats_shmem->lock);
126 
127  /* compensate by reset offsets */
128 #define CHECKPOINTER_COMP(fld) pgStatLocal.snapshot.checkpointer.fld -= reset.fld;
129  CHECKPOINTER_COMP(num_timed);
130  CHECKPOINTER_COMP(num_requested);
131  CHECKPOINTER_COMP(num_performed);
132  CHECKPOINTER_COMP(restartpoints_timed);
133  CHECKPOINTER_COMP(restartpoints_requested);
134  CHECKPOINTER_COMP(restartpoints_performed);
135  CHECKPOINTER_COMP(write_time);
136  CHECKPOINTER_COMP(sync_time);
137  CHECKPOINTER_COMP(buffers_written);
138  CHECKPOINTER_COMP(slru_written);
139 #undef CHECKPOINTER_COMP
140 }
@ LW_SHARED
Definition: lwlock.h:115
#define CHECKPOINTER_COMP(fld)
void reset(void)
Definition: sql-declare.c:600
PgStat_Snapshot snapshot
PgStat_CheckpointerStats checkpointer

References PgStatShared_Checkpointer::changecount, PgStat_ShmemControl::checkpointer, PgStat_Snapshot::checkpointer, CHECKPOINTER_COMP, PgStatShared_Checkpointer::lock, LW_SHARED, LWLockAcquire(), LWLockRelease(), pgstat_copy_changecounted_stats(), pgStatLocal, reset(), PgStatShared_Checkpointer::reset_offset, PgStat_LocalState::shmem, PgStat_LocalState::snapshot, and PgStatShared_Checkpointer::stats.

◆ pgstat_fetch_stat_checkpointer()

◆ pgstat_report_checkpointer()

void pgstat_report_checkpointer ( void  )

Definition at line 31 of file pgstat_checkpointer.c.

32 {
34 
37 
38  /*
39  * This function can be called even if nothing at all has happened. In
40  * this case, avoid unnecessarily modifying the stats entry.
41  */
43  sizeof(struct PgStat_CheckpointerStats)))
44  return;
45 
47 
48 #define CHECKPOINTER_ACC(fld) stats_shmem->stats.fld += PendingCheckpointerStats.fld
49  CHECKPOINTER_ACC(num_timed);
50  CHECKPOINTER_ACC(num_requested);
51  CHECKPOINTER_ACC(num_performed);
52  CHECKPOINTER_ACC(restartpoints_timed);
53  CHECKPOINTER_ACC(restartpoints_requested);
54  CHECKPOINTER_ACC(restartpoints_performed);
55  CHECKPOINTER_ACC(write_time);
56  CHECKPOINTER_ACC(sync_time);
57  CHECKPOINTER_ACC(buffers_written);
58  CHECKPOINTER_ACC(slru_written);
59 #undef CHECKPOINTER_ACC
60 
62 
63  /*
64  * Clear out the statistics buffer, so it can be re-used.
65  */
67 
68  /*
69  * Report IO statistics
70  */
71  pgstat_flush_io(false);
72 }
#define Assert(condition)
Definition: c.h:837
#define MemSet(start, val, len)
Definition: c.h:999
static bool pg_memory_is_all_zeros(const void *ptr, size_t len)
Definition: memutils.h:219
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)
void pgstat_flush_io(bool nowait)
Definition: pgstat_io.c:177

References Assert, PgStatShared_Checkpointer::changecount, PgStat_ShmemControl::checkpointer, CHECKPOINTER_ACC, PgStat_ShmemControl::is_shutdown, MemSet, PendingCheckpointerStats, pg_memory_is_all_zeros(), pgstat_assert_is_up, pgstat_begin_changecount_write(), pgstat_end_changecount_write(), pgstat_flush_io(), pgStatLocal, and PgStat_LocalState::shmem.

Referenced by CheckpointerMain(), CheckpointWriteDelay(), and HandleCheckpointerInterrupts().

Variable Documentation

◆ PendingCheckpointerStats