Refactor calculations to use instr_time

Nazir Bilal Yavuz <byavuz81@gmail.com>

From: Nazir Bilal Yavuz <byavuz81@gmail.com>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2023-02-16T13:19:02Z
Lists: pgsql-hackers

Attachments

Hi,


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.


So, I refactored 'PendingWalStats' to use 'instr_time' instead of 
'PgStat_Counter' while accumulating 'wal_write_time' and 
'wal_sync_time'. Also, I refactored some calculations to use 
'INSTR_TIME_ACCUM_DIFF' instead of using 'INSTR_TIME_SUBTRACT' and 
'INSTR_TIME_ADD'. What do you think?


Regards,
Nazir Bilal Yavuz
Microsoft

Commits

  1. pg_stat_wal: Accumulate time as instr_time instead of microseconds