Re: per backend I/O statistics

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
Cc: Andres Freund <andres(at)anarazel(dot)de>, Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: per backend I/O statistics
Date: 2025-01-20 06:34:41
Message-ID: Z43ugZPG4oKT3Q_Q@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Jan 18, 2025 at 05:53:31PM +0900, Michael Paquier wrote:
> Hmm. Such special complexities in pgstat.c are annoying. There is
> a stupid thing I am wondering here. For the WAL stats, why couldn't
> we place some calls of pgstat_prep_backend_pending() in strategic
> places like XLogBeginInsert() to force all the allocation steps of the
> pending entry to happen before we would enter the critical sections
> when doing a WAL insertion? As far as I can see, there is a special
> case with 2PC where XLogBeginInsert() could be called in a critical
> section, but that seems to be the only one at quick glance.

I've looked first at this idea over the week-end with a quick hack,
and it did not finish well.

And then it struck me that with a bit of redesign of the callbacks, so
as the existing flush_fixed_cb and have_fixed_pending_cb are usable
with variable-numbered stats, we should be able to avoid the exception
your first version of the patch has introduced. Attached is a patch
to achieve what I have in mind, which is more generic than your
previous patch. I've built my stuff as 0002 on top of your 0001.

One key choice I have made is to hide PendingBackendStats within
pgstat_backend.c so as it is possible to enforce some sanity checks
there.
--
Michael

Attachment Content-Type Size
v2-0001-Rework-per-backend-pending-stats.patch text/x-diff 6.3 KB
v2-0002-More-work-to-allow-backend-statistics-in-critical.patch text/x-diff 17.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amul Sul 2025-01-20 06:41:18 Re: Bug in detaching a partition with a foreign key.
Previous Message Peter Smith 2025-01-20 06:30:27 Re: Adding a '--two-phase' option to 'pg_createsubscriber' utility.