summaryrefslogtreecommitdiff
path: root/src/backend/storage/buffer/bufmgr.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2012-04-05 11:37:31 -0400
committerRobert Haas <rhaas@postgresql.org>2012-04-05 11:40:24 -0400
commit644828908fb132ee1f1da5b8b7975c0d73d6158a (patch)
treecb90eb1d3f1953919b757d16c06ef447463dbdd3 /src/backend/storage/buffer/bufmgr.c
parent05dbd4a7734e09bd1f835f4197d9befa1c00c4f3 (diff)
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.
Diffstat (limited to 'src/backend/storage/buffer/bufmgr.c')
-rw-r--r--src/backend/storage/buffer/bufmgr.c10
1 files changed, 7 insertions, 3 deletions
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++;