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

Nazir Bilal Yavuz <byavuz81@gmail.com>

From: Nazir Bilal Yavuz <byavuz81@gmail.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>, Melanie Plageman <melanieplageman@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-01-09T07:59:52Z
Lists: pgsql-hackers

Attachments

Hi,

On Thu, 9 Jan 2025 at 10:15, Nazir Bilal Yavuz <byavuz81@gmail.com> wrote:
>
> On Thu, 9 Jan 2025 at 05:59, Michael Paquier <michael@paquier.xyz> wrote:
> >
> >
> > +static inline bool
> > +is_ioop_tracked_in_bytes(IOOp io_op)
> > +{
> > +    Assert((unsigned int) io_op < IOOP_NUM_TYPES);
> > +    return io_op >= IOOP_EXTEND;
> > +}
> >
> > This is only used in an assertion of pgstat_count_io_op_n() in
> > pgstat_io.c.  Let's also keep it this routine local to the file.  The
> > assert to make sure that the callers don't assign bytes to the
> > operations that don't support the counters is a good idea.
>
> Makes sense, done.
>
> v5 is attached.

I missed a compilation error. Since the is_ioop_tracked_in_bytes() is
only used in the assert and the asserts are disabled in the production
builds, CompilerWarnings task gives -Wunused-function error:

pgstat_io.c:28:1: error: unused function 'is_ioop_tracked_in_bytes'
[-Werror,-Wunused-function]

pg_attribute_unused() is added to the function to silence that. v6 is attached.

--
Regards,
Nazir Bilal Yavuz
Microsoft

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()