mirror of
https://github.com/postgres/postgres.git
synced 2025-10-21 02:52:47 +03:00
Improve management of SLRU statistics collection.
Instead of re-identifying which statistics bucket to use for a given
SLRU on every counter increment, do it once during shmem initialization.
This saves a fair number of cycles, and there's no real cost because
we could not have a bucket assignment that varies over time or across
backends anyway.
Also, get rid of the ill-considered decision to let pgstat.c pry
directly into SLRU's shared state; it's cleaner just to have slru.c
pass the stats bucket number.
In consequence of these changes, there's no longer any need to store
an SLRU's LWLock tranche info in shared memory, so get rid of that,
making this a net reduction in shmem consumption. (That partly
reverts fe702a7b3.)
This is basically code review for 28cac71bd
, so I also cleaned up
some comments, removed a dangling extern declaration, fixed some
things that should be static and/or const, etc.
Discussion: https://postgr.es/m/3618.1589313035@sss.pgh.pa.us
This commit is contained in:
@@ -32,9 +32,6 @@
|
||||
*/
|
||||
#define SLRU_PAGES_PER_SEGMENT 32
|
||||
|
||||
/* Maximum length of an SLRU name */
|
||||
#define SLRU_MAX_NAME_LENGTH 32
|
||||
|
||||
/*
|
||||
* Page status codes. Note that these do not include the "dirty" bit.
|
||||
* page_dirty can be true only in the VALID or WRITE_IN_PROGRESS states;
|
||||
@@ -68,6 +65,7 @@ typedef struct SlruSharedData
|
||||
bool *page_dirty;
|
||||
int *page_number;
|
||||
int *page_lru_count;
|
||||
LWLockPadded *buffer_locks;
|
||||
|
||||
/*
|
||||
* Optional array of WAL flush LSNs associated with entries in the SLRU
|
||||
@@ -98,10 +96,8 @@ typedef struct SlruSharedData
|
||||
*/
|
||||
int latest_page_number;
|
||||
|
||||
/* LWLocks */
|
||||
int lwlock_tranche_id;
|
||||
char lwlock_tranche_name[SLRU_MAX_NAME_LENGTH];
|
||||
LWLockPadded *buffer_locks;
|
||||
/* SLRU's index for statistics purposes (might not be unique) */
|
||||
int slru_stats_idx;
|
||||
} SlruSharedData;
|
||||
|
||||
typedef SlruSharedData *SlruShared;
|
||||
|
Reference in New Issue
Block a user