pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: pg_stat_wal: Accumulate time as instr_time instead of microsecon
Date: Thu, 30 Mar 2023 21:24:17 +0000
Message-ID: <E1phzkm-000X5W-9k@gemulon.postgresql.org> (raw)

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/ca7b3c4c00042038ba9c282c4807e05c0a527e42

Modified Files
--------------
src/backend/access/transam/xlog.c       |  6 ++----
src/backend/storage/file/buffile.c      |  6 ++----
src/backend/utils/activity/pgstat_wal.c | 31 ++++++++++++++++---------------
src/include/pgstat.h                    | 17 ++++++++++++++++-
src/tools/pgindent/typedefs.list        |  1 +
5 files changed, 37 insertions(+), 24 deletions(-)



Message-ID: <E1phzkm-000X5W-9k@gemulon.postgresql.org>
Permalink:  ../E1phzkm-000X5W-9k@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1phzkm-000X5W-9k@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: andres@anarazel.de, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: pg_stat_wal: Accumulate time as instr_time instead of microsecon
  In-Reply-To: <E1phzkm-000X5W-9k@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox