Re: pg_stat_io not tracking smgrwriteback() is confusing

Jonathan S. Katz <jkatz@postgresql.org>

From: "Jonathan S. Katz" <jkatz@postgresql.org>
To: Andres Freund <andres@anarazel.de>, pgsql-hackers@postgresql.org, Melanie Plageman <melanieplageman@gmail.com>
Cc: Amit Kapila <amit.kapila16@gmail.com>, Alvaro Herrera <alvherre@alvh.no-ip.org>
Date: 2023-04-22T19:25:11Z
Lists: pgsql-hackers
On 4/19/23 1:23 PM, Andres Freund wrote:
> Hi,
> 
> I noticed that the numbers in pg_stat_io dont't quite add up to what I
> expected in write heavy workloads. Particularly for checkpointer, the numbers
> for "write" in log_checkpoints output are larger than what is visible in
> pg_stat_io.
> 
> That partially is because log_checkpoints' "write" covers way too many things,
> but there's an issue with pg_stat_io as well:
> 
> Checkpoints, and some other sources of writes, will often end up doing a lot
> of smgrwriteback() calls - which pg_stat_io doesn't track. Nor do any
> pre-existing forms of IO statistics.
> 
> It seems pretty clear that we should track writeback as well. I wonder if it's
> worth doing so for 16? It'd give a more complete picture that way. The
> counter-argument I see is that we didn't track the time for it in existing
> stats either, and that nobody complained - but I suspect that's mostly because
> nobody knew to look.

[RMT hat]

(sorry for slow reply on this, I've been out for a few days).

It does sound generally helpful to track writeback to ensure anyone 
building around pg_stat_io can see tthe more granular picture. How big 
of an effort is this? Do you think this helps to complete the feature 
for v16?

Thanks,

Jonathan

Commits

  1. Add writeback to pg_stat_io

  2. Update parameter name context to wb_context

  3. Use BUFFER_USAGE_LIMIT to reduce needed test table size