Re: Get rid of pgstat_count_backend_io_op*() functions

From: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Andres Freund <andres(at)anarazel(dot)de>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Get rid of pgstat_count_backend_io_op*() functions
Date: 2025-09-24 07:48:32
Message-ID: aNOiUEZBjDo9uGjz@ip-10-97-1-34.eu-west-3.compute.internal
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Wed, Sep 03, 2025 at 07:33:37AM +0000, Bertrand Drouvot wrote:
> Hi,
>
> On Wed, Sep 03, 2025 at 02:47:51PM +0900, Michael Paquier wrote:
> > On Tue, Sep 02, 2025 at 12:42:54PM -0400, Andres Freund wrote:
> > > I think that's the wrong direction to go. Diffing stats is far from cheap and
> > > gets more expensive the more detail you add to stats.
> >
> > Even if we only do the diffs calculations when flushing the pending
> > stats in the flush callbacks?
>
> If my math are correct we have 3 × 5 × 8 = 120 array positions and for each
> we'd do the diff on counts, bytes and times. That means 360 diff operations per
> flush. That means 720 diff operations to flush the global and per backend IO
> stats. That's certainly more expensive than "just" copying the pending stats
> as proposed in v1.
>
> As far the ordering concern for v1, what about:
>
> - let backend kind enum defined as 6
> - move the backend flush outside of the loop in pgstat_report_stat()
>
> That way the backend are flushed last and that solves your concern about custom
> stats kind.
>
> The backend would not be the "only" exception in pgstat_report_stat(), the db
> stats are already handled as exception with pgstat_update_dbstats().

That would give something like v3 attached, thoughts?

Once we agree on the approach to deal with per backend pending stats, I'll make
use of the same in [1] and [2].

[1]: https://www.postgresql.org/message-id/flat/aJDBwNlyiFuJOoPx(at)ip-10-97-1-34(dot)eu-west-3(dot)compute(dot)internal
[2]: https://www.postgresql.org/message-id/flat/aJrxug4LCg4Hm5Mm(at)ip-10-97-1-34(dot)eu-west-3(dot)compute(dot)internal

Regards,

--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

Attachment Content-Type Size
v3-0001-Get-rid-of-pgstat_count_backend_io_op-functions.patch text/x-diff 6.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Richard Guo 2025-09-24 08:18:35 Re: Inconsistent Behavior of GROUP BY ROLLUP in v17 vs master
Previous Message Daniel Gustafsson 2025-09-24 07:44:40 Re: thoughts on v18 RMT