Re: pg_stat_io_histogram

From: Jakub Wartak <jakub(dot)wartak(at)enterprisedb(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pg_stat_io_histogram
Date: 2026-02-05 12:13:46
Message-ID: CAKZiRmztDbC5rDfpWngOO0shqzgtoYNy-rzf1rZ7Ok9_h8uE8A@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jan 30, 2026 at 2:43 PM Jakub Wartak
<jakub(dot)wartak(at)enterprisedb(dot)com> wrote:
[..]
> I'm attaching v3 which has now default switched to __builtin_clzl() which
> works ok for uint64 (not sure if I need to care about __builtin_clzll
> on Windows?).

Here comes the v4:

1. Rebased just in case.
2. Earlier appears to the uncomplete patch without local changes (comment
mentioned use of __builtin_clzl, but actually code called
__builtin_clz -- 32-bit one not long one), fixed that with the new
version.
3. I've added discovery of __builtin_clzl into autoconf/meson as it was
missing (although comment there says "We assume that we needn't test
all widths of these explicitly:", but isn't it safer we test explicitly
what we use?
4. And then I've spotted that pg_leftmost_one_pos64() in pg_binutils.h uses on
master the __builtin_clzl already, so I've tweaked it to use check
HAVE__BUILTIN_CLZL (not CLZ) too once we have that now.

Open questions:
0. Should I pursue more benchmarking or the above results are enough?
1. Should I add per-PID backend stats too or skip that to avoid causing
potential further overhead? (probably yet another memcpy...)
2. Shouldn't we fix that mdsyncfiletag() mentioned earlier we seem to have
pgstat_count_io_op_time() *after* potential FileClose() (as per my
earlier question)

-J.

Attachment Content-Type Size
v4-0001-Add-pg_stat_io_histogram-view-to-provide-more-det.patch text/x-patch 35.2 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2026-02-05 13:07:36 Re: FileFallocate misbehaving on XFS
Previous Message Jim Jones 2026-02-05 11:53:22 Re: Truncate logs by max_log_size