Re: Make pg_stat_io view count IOs as bytes instead of blocks

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Nazir Bilal Yavuz <byavuz81@gmail.com>, Bertrand Drouvot <bertranddrouvot.pg@gmail.com>, Melanie Plageman <melanieplageman@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-01-16T04:14:31Z
Lists: pgsql-hackers

Attachments

On Wed, Jan 15, 2025 at 12:19:03PM -0500, Tom Lane wrote:
> I don't see a reasonable way to alter that check to suppress this;
> for instance, "(io_op) <= IOOP_WRITE" would probably still draw the
> same warning.  I think most likely we have to remove that check, ie
> 
>  #define pgstat_is_ioop_tracked_in_bytes(io_op) \
> -	((io_op) < IOOP_NUM_TYPES && (io_op) >= IOOP_EXTEND)
> +	((io_op) >= IOOP_EXTEND)
> 
> I suppose one alternative is to re-order the enum so that the
> upper-limit check in this macro *isn't* tautological ... but
> that seems a bit silly.

I cannot reproduce that, perhaps I'm just missing something with these
switches.  Do you think that a cast would cool things?  Please see the
attached for the idea.
--
Michael

Commits

  1. Rework macro pgstat_is_ioop_tracked_in_bytes()

  2. Remove assertion in pgstat_count_io_op()

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

  4. Merge pgstat_count_io_op_n() and pgstat_count_io_op()