Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5cd72cc

Browse files
Fix parallel vacuum buffer usage reporting.
A parallel worker's buffer usage is accumulated to its pgBufferUsageand then is accumulated into the leader's one at the end of theparallel vacuum. However, since the leader process used to usededicated VacuumPage{Hit, Miss, Dirty} globals for the buffer usagereporting, the worker's buffer usage was not included, leading to anincorrect buffer usage report.To fix the problem, this commit makes vacuum use pgBufferUsageinstruments for buffer usage reporting instead of VacuumPage{Hit,Miss, Dirty} globals. These global variables are still used by ANALYZEcommand and autoanalyze.This also fixes the buffer usage report of vacuuming on temporarytables, since the buffers dirtied by MarkLocalBufferDirty() were nottracked by the VacuumPageDirty variable.Parallel vacuum was introduced in 13, but the buffer usage reportingfor VACUUM command with the VERBOSE option was implemented in15. So backpatch to 15.Reported-by: Anthonin BonnefoyAuthor: Anthonin BonnefoyReviewed-by: Alena Rybakina, Masahiko SawadaDiscussion:https://postgr.es/m/CAO6_XqrQk+QZQcYs_C6nk0cMfHuUWk85vT9CrcA1NffFbAVE2A@mail.gmail.comBackpatch-through: 15
1 parent2800fbb commit5cd72cc

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

‎src/backend/access/heap/vacuumlazy.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,7 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
309309
PgStat_Counterstartreadtime=0,
310310
startwritetime=0;
311311
WalUsagestartwalusage=pgWalUsage;
312-
int64StartPageHit=VacuumPageHit,
313-
StartPageMiss=VacuumPageMiss,
314-
StartPageDirty=VacuumPageDirty;
312+
BufferUsagestartbufferusage=pgBufferUsage;
315313
ErrorContextCallbackerrcallback;
316314
char**indnames=NULL;
317315

@@ -604,18 +602,18 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
604602
longsecs_dur;
605603
intusecs_dur;
606604
WalUsagewalusage;
605+
BufferUsagebufferusage;
607606
StringInfoDatabuf;
608607
char*msgfmt;
609608
int32diff;
610-
int64PageHitOp=VacuumPageHit-StartPageHit,
611-
PageMissOp=VacuumPageMiss-StartPageMiss,
612-
PageDirtyOp=VacuumPageDirty-StartPageDirty;
613609
doubleread_rate=0,
614610
write_rate=0;
615611

616612
TimestampDifference(starttime,endtime,&secs_dur,&usecs_dur);
617613
memset(&walusage,0,sizeof(WalUsage));
618614
WalUsageAccumDiff(&walusage,&pgWalUsage,&startwalusage);
615+
memset(&bufferusage,0,sizeof(BufferUsage));
616+
BufferUsageAccumDiff(&bufferusage,&pgBufferUsage,&startbufferusage);
619617

620618
initStringInfo(&buf);
621619
if (verbose)
@@ -742,18 +740,18 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
742740
}
743741
if (secs_dur>0||usecs_dur>0)
744742
{
745-
read_rate= (double)BLCKSZ*PageMissOp / (1024*1024) /
746-
(secs_dur+usecs_dur /1000000.0);
747-
write_rate= (double)BLCKSZ*PageDirtyOp / (1024*1024) /
748-
(secs_dur+usecs_dur /1000000.0);
743+
read_rate= (double)BLCKSZ*(bufferusage.shared_blks_read+bufferusage.local_blks_read) /
744+
(1024*1024) / (secs_dur+usecs_dur /1000000.0);
745+
write_rate= (double)BLCKSZ*(bufferusage.shared_blks_dirtied+bufferusage.local_blks_dirtied) /
746+
(1024*1024) / (secs_dur+usecs_dur /1000000.0);
749747
}
750748
appendStringInfo(&buf,_("avg read rate: %.3f MB/s, avg write rate: %.3f MB/s\n"),
751749
read_rate,write_rate);
752750
appendStringInfo(&buf,
753751
_("buffer usage: %lld hits, %lld misses, %lld dirtied\n"),
754-
(long long)PageHitOp,
755-
(long long)PageMissOp,
756-
(long long)PageDirtyOp);
752+
(long long)(bufferusage.shared_blks_hit+bufferusage.local_blks_hit),
753+
(long long)(bufferusage.shared_blks_read+bufferusage.local_blks_read),
754+
(long long)(bufferusage.shared_blks_dirtied+bufferusage.local_blks_dirtied));
757755
appendStringInfo(&buf,
758756
_("WAL usage: %lld records, %lld full page images, %llu bytes\n"),
759757
(long long)walusage.wal_records,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp