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

Commitfaba2f8

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 parent52f21f9 commitfaba2f8

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
@@ -328,9 +328,7 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
328328
PgStat_Counterstartreadtime=0,
329329
startwritetime=0;
330330
WalUsagestartwalusage=pgWalUsage;
331-
int64StartPageHit=VacuumPageHit,
332-
StartPageMiss=VacuumPageMiss,
333-
StartPageDirty=VacuumPageDirty;
331+
BufferUsagestartbufferusage=pgBufferUsage;
334332
ErrorContextCallbackerrcallback;
335333
char**indnames=NULL;
336334

@@ -639,18 +637,18 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
639637
longsecs_dur;
640638
intusecs_dur;
641639
WalUsagewalusage;
640+
BufferUsagebufferusage;
642641
StringInfoDatabuf;
643642
char*msgfmt;
644643
int32diff;
645-
int64PageHitOp=VacuumPageHit-StartPageHit,
646-
PageMissOp=VacuumPageMiss-StartPageMiss,
647-
PageDirtyOp=VacuumPageDirty-StartPageDirty;
648644
doubleread_rate=0,
649645
write_rate=0;
650646

651647
TimestampDifference(starttime,endtime,&secs_dur,&usecs_dur);
652648
memset(&walusage,0,sizeof(WalUsage));
653649
WalUsageAccumDiff(&walusage,&pgWalUsage,&startwalusage);
650+
memset(&bufferusage,0,sizeof(BufferUsage));
651+
BufferUsageAccumDiff(&bufferusage,&pgBufferUsage,&startbufferusage);
654652

655653
initStringInfo(&buf);
656654
if (verbose)
@@ -769,18 +767,18 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
769767
}
770768
if (secs_dur>0||usecs_dur>0)
771769
{
772-
read_rate= (double)BLCKSZ*PageMissOp / (1024*1024) /
773-
(secs_dur+usecs_dur /1000000.0);
774-
write_rate= (double)BLCKSZ*PageDirtyOp / (1024*1024) /
775-
(secs_dur+usecs_dur /1000000.0);
770+
read_rate= (double)BLCKSZ*(bufferusage.shared_blks_read+bufferusage.local_blks_read) /
771+
(1024*1024) / (secs_dur+usecs_dur /1000000.0);
772+
write_rate= (double)BLCKSZ*(bufferusage.shared_blks_dirtied+bufferusage.local_blks_dirtied) /
773+
(1024*1024) / (secs_dur+usecs_dur /1000000.0);
776774
}
777775
appendStringInfo(&buf,_("avg read rate: %.3f MB/s, avg write rate: %.3f MB/s\n"),
778776
read_rate,write_rate);
779777
appendStringInfo(&buf,
780778
_("buffer usage: %lld hits, %lld misses, %lld dirtied\n"),
781-
(long long)PageHitOp,
782-
(long long)PageMissOp,
783-
(long long)PageDirtyOp);
779+
(long long)(bufferusage.shared_blks_hit+bufferusage.local_blks_hit),
780+
(long long)(bufferusage.shared_blks_read+bufferusage.local_blks_read),
781+
(long long)(bufferusage.shared_blks_dirtied+bufferusage.local_blks_dirtied));
784782
appendStringInfo(&buf,
785783
_("WAL usage: %lld records, %lld full page images, %llu bytes\n"),
786784
(long long)walusage.wal_records,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp