From 9d3b50244357ef4c4e3b6e01f91de599077179c8 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Fri, 25 Nov 2011 12:10:46 -0300 Subject: Improve logging of autovacuum I/O activity This adds some I/O stats to the logging of autovacuum (when the operation takes long enough that log_autovacuum_min_duration causes it to be logged), so that it is easier to tune. Notably, it adds buffer I/O counts (hits, misses, dirtied) and read and write rate. Authors: Greg Smith and Noah Misch --- src/backend/storage/buffer/bufmgr.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src/backend/storage/buffer/bufmgr.c') diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c index 2342506d679..71fe8c665ec 100644 --- a/src/backend/storage/buffer/bufmgr.c +++ b/src/backend/storage/buffer/bufmgr.c @@ -340,6 +340,7 @@ ReadBuffer_common(SMgrRelation smgr, char relpersistence, ForkNumber forkNum, { /* Just need to update stats before we exit */ *hit = true; + VacuumPageHit++; if (VacuumCostActive) VacuumCostBalance += VacuumCostPageHit; @@ -471,6 +472,7 @@ ReadBuffer_common(SMgrRelation smgr, char relpersistence, ForkNumber forkNum, TerminateBufferIO(bufHdr, false, BM_VALID); } + VacuumPageMiss++; if (VacuumCostActive) VacuumCostBalance += VacuumCostPageMiss; @@ -972,10 +974,14 @@ MarkBufferDirty(Buffer buffer) Assert(bufHdr->refcount > 0); /* - * If the buffer was not dirty already, do vacuum cost accounting. + * If the buffer was not dirty already, do vacuum accounting. */ - if (!(bufHdr->flags & BM_DIRTY) && VacuumCostActive) - VacuumCostBalance += VacuumCostPageDirty; + if (!(bufHdr->flags & BM_DIRTY)) + { + VacuumPageDirty++; + if (VacuumCostActive) + VacuumCostBalance += VacuumCostPageDirty; + } bufHdr->flags |= (BM_DIRTY | BM_JUST_DIRTIED); @@ -2337,8 +2343,12 @@ SetBufferCommitInfoNeedsSave(Buffer buffer) { LockBufHdr(bufHdr); Assert(bufHdr->refcount > 0); - if (!(bufHdr->flags & BM_DIRTY) && VacuumCostActive) - VacuumCostBalance += VacuumCostPageDirty; + if (!(bufHdr->flags & BM_DIRTY)) + { + VacuumPageDirty++; + if (VacuumCostActive) + VacuumCostBalance += VacuumCostPageDirty; + } bufHdr->flags |= (BM_DIRTY | BM_JUST_DIRTIED); UnlockBufHdr(bufHdr); } -- cgit v1.2.3