1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-26 12:21:12 +03:00

Expose track_iotiming data via the statistics collector.

Ants Aasma's original patch to add timing information for buffer I/O
requests exposed this data at the relation level, which was judged too
costly.  I've here exposed it at the database level instead.
This commit is contained in:
Robert Haas
2012-04-05 11:37:31 -04:00
parent 05dbd4a773
commit 644828908f
10 changed files with 99 additions and 9 deletions

View File

@ -450,6 +450,7 @@ ReadBuffer_common(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
{
INSTR_TIME_SET_CURRENT(io_time);
INSTR_TIME_SUBTRACT(io_time, io_start);
pgstat_count_buffer_read_time(INSTR_TIME_GET_MICROSEC(io_time));
INSTR_TIME_ADD(pgBufferUsage.time_read, io_time);
}
@ -1888,7 +1889,8 @@ FlushBuffer(volatile BufferDesc *buf, SMgrRelation reln)
{
XLogRecPtr recptr;
ErrorContextCallback errcontext;
instr_time io_start, io_end;
instr_time io_start,
io_time;
/*
* Acquire the buffer's io_in_progress lock. If StartBufferIO returns
@ -1947,8 +1949,10 @@ FlushBuffer(volatile BufferDesc *buf, SMgrRelation reln)
if (track_iotiming)
{
INSTR_TIME_SET_CURRENT(io_end);
INSTR_TIME_ACCUM_DIFF(pgBufferUsage.time_write, io_end, io_start);
INSTR_TIME_SET_CURRENT(io_time);
INSTR_TIME_SUBTRACT(io_time, io_start);
pgstat_count_buffer_write_time(INSTR_TIME_GET_MICROSEC(io_time));
INSTR_TIME_ADD(pgBufferUsage.time_write, io_time);
}
pgBufferUsage.shared_blks_written++;