From 644828908fb132ee1f1da5b8b7975c0d73d6158a Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Thu, 5 Apr 2012 11:37:31 -0400 Subject: 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. --- src/backend/storage/buffer/bufmgr.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/backend/storage/buffer/bufmgr.c') diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c index 4de6a7212cc..613d7544c63 100644 --- a/src/backend/storage/buffer/bufmgr.c +++ b/src/backend/storage/buffer/bufmgr.c @@ -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++; -- cgit v1.2.3