PostgreSQL Source Code  git master
pgstat_checkpointer.c File Reference
#include "postgres.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_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_reset_all_cb()

void pgstat_checkpointer_reset_all_cb ( TimestampTz  ts)

Definition at line 82 of file pgstat_checkpointer.c.

83 {
85 
86  /* see explanation above PgStatShared_Checkpointer for the reset protocol */
87  LWLockAcquire(&stats_shmem->lock, LW_EXCLUSIVE);
89  &stats_shmem->stats,
90  sizeof(stats_shmem->stats),
91  &stats_shmem->changecount);
92  LWLockRelease(&stats_shmem->lock);
93 }
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1196
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1800
@ LW_EXCLUSIVE
Definition: lwlock.h:104
PgStat_LocalState pgStatLocal
Definition: pgstat.c:195
static void pgstat_copy_changecounted_stats(void *dst, void *src, size_t len, uint32 *cc)
PgStat_CheckpointerStats reset_offset
PgStat_CheckpointerStats stats
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, and PgStatShared_Checkpointer::stats.

◆ pgstat_checkpointer_snapshot_cb()

void pgstat_checkpointer_snapshot_cb ( void  )

Definition at line 96 of file pgstat_checkpointer.c.

97 {
99  PgStat_CheckpointerStats *reset_offset = &stats_shmem->reset_offset;
101 
103  &stats_shmem->stats,
104  sizeof(stats_shmem->stats),
105  &stats_shmem->changecount);
106 
107  LWLockAcquire(&stats_shmem->lock, LW_SHARED);
108  memcpy(&reset, reset_offset, sizeof(stats_shmem->stats));
109  LWLockRelease(&stats_shmem->lock);
110 
111  /* compensate by reset offsets */
112 #define CHECKPOINTER_COMP(fld) pgStatLocal.snapshot.checkpointer.fld -= reset.fld;
113  CHECKPOINTER_COMP(timed_checkpoints);
114  CHECKPOINTER_COMP(requested_checkpoints);
115  CHECKPOINTER_COMP(checkpoint_write_time);
116  CHECKPOINTER_COMP(checkpoint_sync_time);
117  CHECKPOINTER_COMP(buf_written_checkpoints);
118  CHECKPOINTER_COMP(buf_written_backend);
119  CHECKPOINTER_COMP(buf_fsync_backend);
120 #undef CHECKPOINTER_COMP
121 }
@ LW_SHARED
Definition: lwlock.h:105
#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 30 of file pgstat_checkpointer.c.

31 {
32  /* We assume this initializes to zeroes */
33  static const PgStat_CheckpointerStats all_zeroes;
35 
38 
39  /*
40  * This function can be called even if nothing at all has happened. In
41  * this case, avoid unnecessarily modifying the stats entry.
42  */
43  if (memcmp(&PendingCheckpointerStats, &all_zeroes,
44  sizeof(all_zeroes)) == 0)
45  return;
46 
48 
49 #define CHECKPOINTER_ACC(fld) stats_shmem->stats.fld += PendingCheckpointerStats.fld
50  CHECKPOINTER_ACC(timed_checkpoints);
51  CHECKPOINTER_ACC(requested_checkpoints);
52  CHECKPOINTER_ACC(checkpoint_write_time);
53  CHECKPOINTER_ACC(checkpoint_sync_time);
54  CHECKPOINTER_ACC(buf_written_checkpoints);
55  CHECKPOINTER_ACC(buf_written_backend);
56  CHECKPOINTER_ACC(buf_fsync_backend);
57 #undef CHECKPOINTER_ACC
58 
60 
61  /*
62  * Clear out the statistics buffer, so it can be re-used.
63  */
65 }
#define MemSet(start, val, len)
Definition: c.h:1008
Assert(fmt[strlen(fmt) - 1] !='\n')
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)

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

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

Variable Documentation

◆ PendingCheckpointerStats