pgsql: Make pg_stat_io count IOs as bytes instead of blocks for some op

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Make pg_stat_io count IOs as bytes instead of blocks for some op
Date: 2025-01-14 03:15:36
Message-ID: E1tXXOy-001PdI-71@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Make pg_stat_io count IOs as bytes instead of blocks for some operations

Currently in pg_stat_io view, IOs are counted as blocks of size
BLCKSZ. There are two limitations with this design:
* The actual number of I/O requests sent to the kernel is lower because
I/O requests may be merged before being sent. Additionally, it gives
the impression that all I/Os are done in block size, which shadows the
benefits of merging I/O requests.
* Some patches are under work to extend pg_stat_io for the tracking of
operations that may not be linked to the block size. For example, WAL
read IOs are done in variable bytes and it is not possible to correctly
show these IOs in pg_stat_io view, and we want to keep all this data in
a single system view rather than spread it across multiple relations to
ease monitoring.

WaitReadBuffers() can now be tracked as a single read operation
worth N blocks. Same for ExtendBufferedRelShared() and
ExtendBufferedRelLocal() for extensions.

Three columns are added to pg_stat_io for reads, writes and extensions
for the byte calculations. op_bytes, which was always hardcoded to
BLCKSZ, is removed. IO backend statistics are updated to reflect these
changes.

Bump catalog version.

Author: Nazir Bilal Yavuz
Reviewed-by: Bertrand Drouvot, Melanie Plageman
Discussion: https://postgr.es/m/CAN55FZ0oqxBaaHAEsj=xFqkzE3n5P=3RA1V_igXwL-RV7QRzyw@mail.gmail.com

Branch
------
master

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

Modified Files
--------------
doc/src/sgml/monitoring.sgml | 51 ++++++++++-------
src/backend/catalog/system_views.sql | 4 +-
src/backend/storage/buffer/bufmgr.c | 14 ++---
src/backend/storage/buffer/localbuf.c | 7 ++-
src/backend/storage/smgr/md.c | 4 +-
src/backend/utils/activity/pgstat_backend.c | 2 +
src/backend/utils/activity/pgstat_io.c | 20 ++++++-
src/backend/utils/adt/pgstatfuncs.c | 86 ++++++++++++++++++++++-------
src/include/catalog/catversion.h | 2 +-
src/include/catalog/pg_proc.dat | 12 ++--
src/include/pgstat.h | 27 +++++++--
src/test/regress/expected/rules.out | 6 +-
12 files changed, 164 insertions(+), 71 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2025-01-14 03:28:46 pgsql: Remove assertion in pgstat_count_io_op()
Previous Message Alena Rybakina 2025-01-13 23:51:47 Re: pgsql: Consolidate docs for vacuum-related GUCs in new subsection