diff options
author | Michael Paquier | 2025-01-14 03:14:29 +0000 |
---|---|---|
committer | Michael Paquier | 2025-01-14 03:14:29 +0000 |
commit | f92c854cf406a5ad34c9aa92416d578819704aa2 (patch) | |
tree | 7c7497959b4f5c5c439c6d07998c823dbc2d8afd /src/include/pgstat.h | |
parent | b4a07f532b40a64fb4714a3f7ab6063435411edb (diff) |
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
Diffstat (limited to 'src/include/pgstat.h')
-rw-r--r-- | src/include/pgstat.h | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/include/pgstat.h b/src/include/pgstat.h index 6475889c58c..7cd9396aced 100644 --- a/src/include/pgstat.h +++ b/src/include/pgstat.h @@ -343,28 +343,42 @@ typedef enum IOContext #define IOCONTEXT_NUM_TYPES (IOCONTEXT_VACUUM + 1) +/* + * Enumeration of IO operations. + * + * This enum categorizes IO operations into two groups, depending on if + * byte operations are supported. + * + * Ensure IOOP_EXTEND is the first and IOOP_WRITE is the last ones in the + * tracked in bytes group and that the groups stay in that order. + */ typedef enum IOOp { + /* IOs not tracked in bytes */ IOOP_EVICT, - IOOP_EXTEND, IOOP_FSYNC, IOOP_HIT, - IOOP_READ, IOOP_REUSE, - IOOP_WRITE, IOOP_WRITEBACK, + + /* IOs tracked in bytes */ + IOOP_EXTEND, + IOOP_READ, + IOOP_WRITE, } IOOp; -#define IOOP_NUM_TYPES (IOOP_WRITEBACK + 1) +#define IOOP_NUM_TYPES (IOOP_WRITE + 1) typedef struct PgStat_BktypeIO { + uint64 bytes[IOOBJECT_NUM_TYPES][IOCONTEXT_NUM_TYPES][IOOP_NUM_TYPES]; PgStat_Counter counts[IOOBJECT_NUM_TYPES][IOCONTEXT_NUM_TYPES][IOOP_NUM_TYPES]; PgStat_Counter times[IOOBJECT_NUM_TYPES][IOCONTEXT_NUM_TYPES][IOOP_NUM_TYPES]; } PgStat_BktypeIO; typedef struct PgStat_PendingIO { + uint64 bytes[IOOBJECT_NUM_TYPES][IOCONTEXT_NUM_TYPES][IOOP_NUM_TYPES]; PgStat_Counter counts[IOOBJECT_NUM_TYPES][IOCONTEXT_NUM_TYPES][IOOP_NUM_TYPES]; instr_time pending_times[IOOBJECT_NUM_TYPES][IOCONTEXT_NUM_TYPES][IOOP_NUM_TYPES]; } PgStat_PendingIO; @@ -604,10 +618,11 @@ extern PgStat_CheckpointerStats *pgstat_fetch_stat_checkpointer(void); extern bool pgstat_bktype_io_stats_valid(PgStat_BktypeIO *backend_io, BackendType bktype); extern void pgstat_count_io_op(IOObject io_object, IOContext io_context, - IOOp io_op, uint32 cnt); + IOOp io_op, uint32 cnt, uint64 bytes); extern instr_time pgstat_prepare_io_time(bool track_io_guc); extern void pgstat_count_io_op_time(IOObject io_object, IOContext io_context, - IOOp io_op, instr_time start_time, uint32 cnt); + IOOp io_op, instr_time start_time, + uint32 cnt, uint64 bytes); extern PgStat_IO *pgstat_fetch_stat_io(void); extern const char *pgstat_get_io_context_name(IOContext io_context); |