mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
pg_stat_wal: Accumulate time as instr_time instead of microseconds
In instr_time.h it is stated that: * When summing multiple measurements, it's recommended to leave the * running sum in instr_time form (ie, use INSTR_TIME_ADD or * INSTR_TIME_ACCUM_DIFF) and convert to a result format only at the end. The reason for that is that converting to microseconds is not cheap, and can loose precision. Therefore this commit changes 'PendingWalStats' to use 'instr_time' instead of 'PgStat_Counter' while accumulating 'wal_write_time' and 'wal_sync_time'. Author: Nazir Bilal Yavuz <byavuz81@gmail.com> Reviewed-by: Andres Freund <andres@anarazel.de> Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com> Reviewed-by: Melanie Plageman <melanieplageman@gmail.com> Discussion: https://postgr.es/m/1feedb83-7aa9-cb4b-5086-598349d3f555@gmail.com
This commit is contained in:
@@ -469,8 +469,7 @@ BufFileLoadBuffer(BufFile *file)
|
||||
if (track_io_timing)
|
||||
{
|
||||
INSTR_TIME_SET_CURRENT(io_time);
|
||||
INSTR_TIME_SUBTRACT(io_time, io_start);
|
||||
INSTR_TIME_ADD(pgBufferUsage.temp_blk_read_time, io_time);
|
||||
INSTR_TIME_ACCUM_DIFF(pgBufferUsage.temp_blk_read_time, io_time, io_start);
|
||||
}
|
||||
|
||||
/* we choose not to advance curOffset here */
|
||||
@@ -544,8 +543,7 @@ BufFileDumpBuffer(BufFile *file)
|
||||
if (track_io_timing)
|
||||
{
|
||||
INSTR_TIME_SET_CURRENT(io_time);
|
||||
INSTR_TIME_SUBTRACT(io_time, io_start);
|
||||
INSTR_TIME_ADD(pgBufferUsage.temp_blk_write_time, io_time);
|
||||
INSTR_TIME_ACCUM_DIFF(pgBufferUsage.temp_blk_write_time, io_time, io_start);
|
||||
}
|
||||
|
||||
file->curOffset += bytestowrite;
|
||||
|
Reference in New Issue
Block a user