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

Commit704261e

Browse files
committed
Improve IO accounting for temp relation writes
Both pgstat_database and pgBufferUsage count IO timing for reads of temporaryrelation blocks into local buffers. However, both failed to count write IOtiming for flushes of dirty local buffers. Fix.Additionally, FlushRelationBuffers() seems to have omitted counting writeIO (both count and timing) stats for both pgstat_database andpgBufferUsage. Fix.Author: Melanie Plageman <melanieplageman@gmail.com>Reviewed-by: Andres Freund <andres@anarazel.de>Discussion:https://postgr.es/m/20230321023451.7rzy4kjj2iktrg2r%40awork3.anarazel.de
1 parentbf5a894 commit704261e

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

‎src/backend/storage/buffer/bufmgr.c‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4062,6 +4062,8 @@ FlushRelationBuffers(Relation rel)
40624062
{
40634063
inti;
40644064
BufferDesc*bufHdr;
4065+
instr_timeio_start,
4066+
io_time;
40654067

40664068
if (RelationUsesLocalBuffers(rel))
40674069
{
@@ -4087,6 +4089,11 @@ FlushRelationBuffers(Relation rel)
40874089

40884090
PageSetChecksumInplace(localpage,bufHdr->tag.blockNum);
40894091

4092+
if (track_io_timing)
4093+
INSTR_TIME_SET_CURRENT(io_start);
4094+
else
4095+
INSTR_TIME_SET_ZERO(io_start);
4096+
40904097
smgrwrite(RelationGetSmgr(rel),
40914098
BufTagGetForkNum(&bufHdr->tag),
40924099
bufHdr->tag.blockNum,
@@ -4098,6 +4105,16 @@ FlushRelationBuffers(Relation rel)
40984105

40994106
pgstat_count_io_op(IOOBJECT_TEMP_RELATION,IOCONTEXT_NORMAL,IOOP_WRITE);
41004107

4108+
if (track_io_timing)
4109+
{
4110+
INSTR_TIME_SET_CURRENT(io_time);
4111+
INSTR_TIME_SUBTRACT(io_time,io_start);
4112+
pgstat_count_buffer_write_time(INSTR_TIME_GET_MICROSEC(io_time));
4113+
INSTR_TIME_ADD(pgBufferUsage.blk_write_time,io_time);
4114+
}
4115+
4116+
pgBufferUsage.local_blks_written++;
4117+
41014118
/* Pop the error context stack */
41024119
error_context_stack=errcallback.previous;
41034120
}

‎src/backend/storage/buffer/localbuf.c‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ GetLocalVictimBuffer(void)
176176
inttrycounter;
177177
uint32buf_state;
178178
BufferDesc*bufHdr;
179+
instr_timeio_start,
180+
io_time;
179181

180182
ResourceOwnerEnlargeBuffers(CurrentResourceOwner);
181183

@@ -239,6 +241,11 @@ GetLocalVictimBuffer(void)
239241

240242
PageSetChecksumInplace(localpage,bufHdr->tag.blockNum);
241243

244+
if (track_io_timing)
245+
INSTR_TIME_SET_CURRENT(io_start);
246+
else
247+
INSTR_TIME_SET_ZERO(io_start);
248+
242249
/* And write... */
243250
smgrwrite(oreln,
244251
BufTagGetForkNum(&bufHdr->tag),
@@ -252,6 +259,15 @@ GetLocalVictimBuffer(void)
252259

253260
/* Temporary table I/O does not use Buffer Access Strategies */
254261
pgstat_count_io_op(IOOBJECT_TEMP_RELATION,IOCONTEXT_NORMAL,IOOP_WRITE);
262+
263+
if (track_io_timing)
264+
{
265+
INSTR_TIME_SET_CURRENT(io_time);
266+
INSTR_TIME_SUBTRACT(io_time,io_start);
267+
pgstat_count_buffer_write_time(INSTR_TIME_GET_MICROSEC(io_time));
268+
INSTR_TIME_ADD(pgBufferUsage.blk_write_time,io_time);
269+
}
270+
255271
pgBufferUsage.local_blks_written++;
256272
}
257273

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp