mirror of
https://github.com/postgres/postgres.git
synced 2025-10-08 00:03:59 -04:00
Generate pgstat_count_slru*() functions for slru using macros
This change replaces seven functions definitions by macros, reducing a bit some repetitive patterns in the code. An interesting side effect is that this removes an inconsistency in the naming of SLRU increment functions with the field names. This change is similar to 850f4b4c8cab, 8018ffbf5895 or 83a1a1b56645. Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com> Discussion: https://postgr.es/m/aLHA//gr4dTpDHHC@ip-10-97-1-34.eu-west-3.compute.internal
This commit is contained in:
parent
a850be2fe6
commit
eccba079c2
@ -408,7 +408,7 @@ SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
|
||||
pg_atomic_write_u64(&shared->latest_page_number, pageno);
|
||||
|
||||
/* update the stats counter of zeroed pages */
|
||||
pgstat_count_slru_page_zeroed(shared->slru_stats_idx);
|
||||
pgstat_count_slru_blocks_zeroed(shared->slru_stats_idx);
|
||||
|
||||
return slotno;
|
||||
}
|
||||
@ -560,7 +560,7 @@ SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
|
||||
SlruRecentlyUsed(shared, slotno);
|
||||
|
||||
/* update the stats counter of pages found in the SLRU */
|
||||
pgstat_count_slru_page_hit(shared->slru_stats_idx);
|
||||
pgstat_count_slru_blocks_hit(shared->slru_stats_idx);
|
||||
|
||||
return slotno;
|
||||
}
|
||||
@ -605,7 +605,7 @@ SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
|
||||
SlruRecentlyUsed(shared, slotno);
|
||||
|
||||
/* update the stats counter of pages not found in SLRU */
|
||||
pgstat_count_slru_page_read(shared->slru_stats_idx);
|
||||
pgstat_count_slru_blocks_read(shared->slru_stats_idx);
|
||||
|
||||
return slotno;
|
||||
}
|
||||
@ -648,7 +648,7 @@ SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
|
||||
SlruRecentlyUsed(shared, slotno);
|
||||
|
||||
/* update the stats counter of pages found in the SLRU */
|
||||
pgstat_count_slru_page_hit(shared->slru_stats_idx);
|
||||
pgstat_count_slru_blocks_hit(shared->slru_stats_idx);
|
||||
|
||||
return slotno;
|
||||
}
|
||||
@ -778,7 +778,7 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
|
||||
off_t endpos;
|
||||
|
||||
/* update the stats counter of checked pages */
|
||||
pgstat_count_slru_page_exists(ctl->shared->slru_stats_idx);
|
||||
pgstat_count_slru_blocks_exists(ctl->shared->slru_stats_idx);
|
||||
|
||||
SlruFileName(ctl, path, segno);
|
||||
|
||||
@ -907,7 +907,7 @@ SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
|
||||
int fd = -1;
|
||||
|
||||
/* update the stats counter of written pages */
|
||||
pgstat_count_slru_page_written(shared->slru_stats_idx);
|
||||
pgstat_count_slru_blocks_written(shared->slru_stats_idx);
|
||||
|
||||
/*
|
||||
* Honor the write-WAL-before-data rule, if appropriate, so that we do not
|
||||
|
@ -55,47 +55,33 @@ pgstat_reset_slru(const char *name)
|
||||
* SLRU statistics count accumulation functions --- called from slru.c
|
||||
*/
|
||||
|
||||
void
|
||||
pgstat_count_slru_page_zeroed(int slru_idx)
|
||||
{
|
||||
get_slru_entry(slru_idx)->blocks_zeroed += 1;
|
||||
#define PGSTAT_COUNT_SLRU(stat) \
|
||||
void \
|
||||
CppConcat(pgstat_count_slru_,stat)(int slru_idx) \
|
||||
{ \
|
||||
get_slru_entry(slru_idx)->stat += 1; \
|
||||
}
|
||||
|
||||
void
|
||||
pgstat_count_slru_page_hit(int slru_idx)
|
||||
{
|
||||
get_slru_entry(slru_idx)->blocks_hit += 1;
|
||||
}
|
||||
/* pgstat_count_slru_blocks_zeroed */
|
||||
PGSTAT_COUNT_SLRU(blocks_zeroed)
|
||||
|
||||
void
|
||||
pgstat_count_slru_page_exists(int slru_idx)
|
||||
{
|
||||
get_slru_entry(slru_idx)->blocks_exists += 1;
|
||||
}
|
||||
/* pgstat_count_slru_blocks_hit */
|
||||
PGSTAT_COUNT_SLRU(blocks_hit)
|
||||
|
||||
void
|
||||
pgstat_count_slru_page_read(int slru_idx)
|
||||
{
|
||||
get_slru_entry(slru_idx)->blocks_read += 1;
|
||||
}
|
||||
/* pgstat_count_slru_blocks_exists */
|
||||
PGSTAT_COUNT_SLRU(blocks_exists)
|
||||
|
||||
void
|
||||
pgstat_count_slru_page_written(int slru_idx)
|
||||
{
|
||||
get_slru_entry(slru_idx)->blocks_written += 1;
|
||||
}
|
||||
/* pgstat_count_slru_blocks_read */
|
||||
PGSTAT_COUNT_SLRU(blocks_read)
|
||||
|
||||
void
|
||||
pgstat_count_slru_flush(int slru_idx)
|
||||
{
|
||||
get_slru_entry(slru_idx)->flush += 1;
|
||||
}
|
||||
/* pgstat_count_slru_blocks_written */
|
||||
PGSTAT_COUNT_SLRU(blocks_written)
|
||||
|
||||
void
|
||||
pgstat_count_slru_truncate(int slru_idx)
|
||||
{
|
||||
get_slru_entry(slru_idx)->truncate += 1;
|
||||
}
|
||||
/* pgstat_count_slru_flush */
|
||||
PGSTAT_COUNT_SLRU(flush)
|
||||
|
||||
/* pgstat_count_slru_truncate */
|
||||
PGSTAT_COUNT_SLRU(truncate)
|
||||
|
||||
/*
|
||||
* Support function for the SQL-callable pgstat* functions. Returns
|
||||
|
@ -747,11 +747,11 @@ extern PgStat_StatReplSlotEntry *pgstat_fetch_replslot(NameData slotname);
|
||||
*/
|
||||
|
||||
extern void pgstat_reset_slru(const char *);
|
||||
extern void pgstat_count_slru_page_zeroed(int slru_idx);
|
||||
extern void pgstat_count_slru_page_hit(int slru_idx);
|
||||
extern void pgstat_count_slru_page_read(int slru_idx);
|
||||
extern void pgstat_count_slru_page_written(int slru_idx);
|
||||
extern void pgstat_count_slru_page_exists(int slru_idx);
|
||||
extern void pgstat_count_slru_blocks_zeroed(int slru_idx);
|
||||
extern void pgstat_count_slru_blocks_hit(int slru_idx);
|
||||
extern void pgstat_count_slru_blocks_read(int slru_idx);
|
||||
extern void pgstat_count_slru_blocks_written(int slru_idx);
|
||||
extern void pgstat_count_slru_blocks_exists(int slru_idx);
|
||||
extern void pgstat_count_slru_flush(int slru_idx);
|
||||
extern void pgstat_count_slru_truncate(int slru_idx);
|
||||
extern const char *pgstat_get_slru_name(int slru_idx);
|
||||
|
Loading…
x
Reference in New Issue
Block a user