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

Commitf199436

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 parent68d3585 commitf199436

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
@@ -317,9 +317,7 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
317317
PgStat_Counterstartreadtime=0,
318318
startwritetime=0;
319319
WalUsagestartwalusage=pgWalUsage;
320-
int64StartPageHit=VacuumPageHit,
321-
StartPageMiss=VacuumPageMiss,
322-
StartPageDirty=VacuumPageDirty;
320+
BufferUsagestartbufferusage=pgBufferUsage;
323321
ErrorContextCallbackerrcallback;
324322
char**indnames=NULL;
325323

@@ -611,18 +609,18 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
611609
longsecs_dur;
612610
intusecs_dur;
613611
WalUsagewalusage;
612+
BufferUsagebufferusage;
614613
StringInfoDatabuf;
615614
char*msgfmt;
616615
int32diff;
617-
int64PageHitOp=VacuumPageHit-StartPageHit,
618-
PageMissOp=VacuumPageMiss-StartPageMiss,
619-
PageDirtyOp=VacuumPageDirty-StartPageDirty;
620616
doubleread_rate=0,
621617
write_rate=0;
622618

623619
TimestampDifference(starttime,endtime,&secs_dur,&usecs_dur);
624620
memset(&walusage,0,sizeof(WalUsage));
625621
WalUsageAccumDiff(&walusage,&pgWalUsage,&startwalusage);
622+
memset(&bufferusage,0,sizeof(BufferUsage));
623+
BufferUsageAccumDiff(&bufferusage,&pgBufferUsage,&startbufferusage);
626624

627625
initStringInfo(&buf);
628626
if (verbose)
@@ -749,18 +747,18 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
749747
}
750748
if (secs_dur>0||usecs_dur>0)
751749
{
752-
read_rate= (double)BLCKSZ*PageMissOp / (1024*1024) /
753-
(secs_dur+usecs_dur /1000000.0);
754-
write_rate= (double)BLCKSZ*PageDirtyOp / (1024*1024) /
755-
(secs_dur+usecs_dur /1000000.0);
750+
read_rate= (double)BLCKSZ*(bufferusage.shared_blks_read+bufferusage.local_blks_read) /
751+
(1024*1024) / (secs_dur+usecs_dur /1000000.0);
752+
write_rate= (double)BLCKSZ*(bufferusage.shared_blks_dirtied+bufferusage.local_blks_dirtied) /
753+
(1024*1024) / (secs_dur+usecs_dur /1000000.0);
756754
}
757755
appendStringInfo(&buf,_("avg read rate: %.3f MB/s, avg write rate: %.3f MB/s\n"),
758756
read_rate,write_rate);
759757
appendStringInfo(&buf,
760758
_("buffer usage: %lld hits, %lld misses, %lld dirtied\n"),
761-
(long long)PageHitOp,
762-
(long long)PageMissOp,
763-
(long long)PageDirtyOp);
759+
(long long)(bufferusage.shared_blks_hit+bufferusage.local_blks_hit),
760+
(long long)(bufferusage.shared_blks_read+bufferusage.local_blks_read),
761+
(long long)(bufferusage.shared_blks_dirtied+bufferusage.local_blks_dirtied));
764762
appendStringInfo(&buf,
765763
_("WAL usage: %lld records, %lld full page images, %llu bytes\n"),
766764
(long long)walusage.wal_records,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp