1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

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
This commit is contained in:
Michael Paquier
2025-01-14 12:14:29 +09:00
parent b4a07f532b
commit f92c854cf4
12 changed files with 170 additions and 77 deletions

View File

@ -2692,8 +2692,18 @@ description | Waiting for a newly initialized WAL file to reach durable storage
<structfield>reads</structfield> <type>bigint</type>
</para>
<para>
Number of read operations, each of the size specified in
<varname>op_bytes</varname>.
Number of read operations.
</para>
</entry>
</row>
<row>
<entry role="catalog_table_entry">
<para role="column_definition">
<structfield>read_bytes</structfield> <type>numeric</type>
</para>
<para>
The total size of read operations in bytes.
</para>
</entry>
</row>
@ -2716,8 +2726,18 @@ description | Waiting for a newly initialized WAL file to reach durable storage
<structfield>writes</structfield> <type>bigint</type>
</para>
<para>
Number of write operations, each of the size specified in
<varname>op_bytes</varname>.
Number of write operations.
</para>
</entry>
</row>
<row>
<entry role="catalog_table_entry">
<para role="column_definition">
<structfield>write_bytes</structfield> <type>numeric</type>
</para>
<para>
The total size of write operations in bytes.
</para>
</entry>
</row>
@ -2740,8 +2760,8 @@ description | Waiting for a newly initialized WAL file to reach durable storage
<structfield>writebacks</structfield> <type>bigint</type>
</para>
<para>
Number of units of size <varname>op_bytes</varname> which the process
requested the kernel write out to permanent storage.
Number of units of size <symbol>BLCKSZ</symbol> (typically 8kB) which
the process requested the kernel write out to permanent storage.
</para>
</entry>
</row>
@ -2766,8 +2786,18 @@ description | Waiting for a newly initialized WAL file to reach durable storage
<structfield>extends</structfield> <type>bigint</type>
</para>
<para>
Number of relation extend operations, each of the size specified in
<varname>op_bytes</varname>.
Number of relation extend operations.
</para>
</entry>
</row>
<row>
<entry role="catalog_table_entry">
<para role="column_definition">
<structfield>extend_bytes</structfield> <type>numeric</type>
</para>
<para>
The total size of relation extend operations in bytes.
</para>
</entry>
</row>
@ -2784,23 +2814,6 @@ description | Waiting for a newly initialized WAL file to reach durable storage
</entry>
</row>
<row>
<entry role="catalog_table_entry">
<para role="column_definition">
<structfield>op_bytes</structfield> <type>bigint</type>
</para>
<para>
The number of bytes per unit of I/O read, written, or extended.
</para>
<para>
Relation data reads, writes, and extends are done in
<varname>block_size</varname> units, derived from the build-time
parameter <symbol>BLCKSZ</symbol>, which is <literal>8192</literal> by
default.
</para>
</entry>
</row>
<row>
<entry role="catalog_table_entry">
<para role="column_definition">