aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/access')
-rw-r--r--src/backend/access/transam/slru.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index b2316af7794..3ba9fc9c493 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -191,6 +191,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
/* shared->latest_page_number will be set later */
+ shared->slru_stats_idx = pgstat_slru_index(name);
+
ptr = (char *) shared;
offset = MAXALIGN(sizeof(SlruSharedData));
shared->page_buffer = (char **) (ptr + offset);
@@ -214,15 +216,11 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * nlsns * sizeof(XLogRecPtr));
}
- Assert(strlen(name) + 1 < SLRU_MAX_NAME_LENGTH);
- strlcpy(shared->lwlock_tranche_name, name, SLRU_MAX_NAME_LENGTH);
- shared->lwlock_tranche_id = tranche_id;
-
ptr += BUFFERALIGN(offset);
for (slotno = 0; slotno < nslots; slotno++)
{
LWLockInitialize(&shared->buffer_locks[slotno].lock,
- shared->lwlock_tranche_id);
+ tranche_id);
shared->page_buffer[slotno] = ptr;
shared->page_status[slotno] = SLRU_PAGE_EMPTY;
@@ -238,8 +236,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
Assert(found);
/* Register SLRU tranche in the main tranches array */
- LWLockRegisterTranche(shared->lwlock_tranche_id,
- shared->lwlock_tranche_name);
+ LWLockRegisterTranche(tranche_id, name);
/*
* Initialize the unshared control struct, including directory path. We
@@ -287,7 +284,7 @@ SimpleLruZeroPage(SlruCtl ctl, int pageno)
shared->latest_page_number = pageno;
/* update the stats counter of zeroed pages */
- pgstat_count_slru_page_zeroed(ctl);
+ pgstat_count_slru_page_zeroed(shared->slru_stats_idx);
return slotno;
}
@@ -408,7 +405,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
SlruRecentlyUsed(shared, slotno);
/* update the stats counter of pages found in the SLRU */
- pgstat_count_slru_page_hit(ctl);
+ pgstat_count_slru_page_hit(shared->slru_stats_idx);
return slotno;
}
@@ -453,7 +450,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
SlruRecentlyUsed(shared, slotno);
/* update the stats counter of pages not found in SLRU */
- pgstat_count_slru_page_read(ctl);
+ pgstat_count_slru_page_read(shared->slru_stats_idx);
return slotno;
}
@@ -493,7 +490,7 @@ SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
SlruRecentlyUsed(shared, slotno);
/* update the stats counter of pages found in the SLRU */
- pgstat_count_slru_page_hit(ctl);
+ pgstat_count_slru_page_hit(shared->slru_stats_idx);
return slotno;
}
@@ -612,7 +609,7 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
off_t endpos;
/* update the stats counter of checked pages */
- pgstat_count_slru_page_exists(ctl);
+ pgstat_count_slru_page_exists(ctl->shared->slru_stats_idx);
SlruFileName(ctl, path, segno);
@@ -749,7 +746,7 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruFlush fdata)
int fd = -1;
/* update the stats counter of written pages */
- pgstat_count_slru_page_written(ctl);
+ pgstat_count_slru_page_written(shared->slru_stats_idx);
/*
* Honor the write-WAL-before-data rule, if appropriate, so that we do not
@@ -1147,7 +1144,7 @@ SimpleLruFlush(SlruCtl ctl, bool allow_redirtied)
bool ok;
/* update the stats counter of flushes */
- pgstat_count_slru_flush(ctl);
+ pgstat_count_slru_flush(shared->slru_stats_idx);
/*
* Find and write dirty pages
@@ -1211,7 +1208,7 @@ SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
int slotno;
/* update the stats counter of truncates */
- pgstat_count_slru_truncate(ctl);
+ pgstat_count_slru_truncate(shared->slru_stats_idx);
/*
* The cutoff point is the start of the segment containing cutoffPage.