Re: PoC: history of recent vacuum/checkpoint runs (using new hooks)

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Tomas Vondra <tomas(at)vondra(dot)me>
Cc: wenhui qiu <qiuwenhuifx(at)gmail(dot)com>, Robert Treat <rob(at)xzilla(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PoC: history of recent vacuum/checkpoint runs (using new hooks)
Date: 2024-12-31 01:06:45
Message-ID: Z3NDpUslYaRW4Yo4@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Dec 28, 2024 at 02:25:16AM +0100, Tomas Vondra wrote:
> And the more I think about it the more I'm convinced we don't need to
> keep the data about past runs in memory, a file should be enough (except
> maybe for a small buffer). That would mean we don't need to worry about
> dynamic shared memory, etc. I initially rejected this because it seemed
> like a regression to how pgstat worked initially (sharing data through
> files), but I don't think that's actually true - this data is different
> (almost append-only), etc.

Right, I was looking a bit at 0003 that introduces the extension. I
am wondering if we are not repeating the errors of pgss by using a
different file, and if we should not just use pgstats and its single
file instead to store this data through an extension. You are right
that as an append-only pattern using the dshash of pgstat does not fit
well into this picture. How about the second type of stats kinds:
the fixed-numbered stats kind? These allocate a fixed amount of
shared memory, meaning that you could allocate N entries of history
and just manage a queue of them, then do a memcpy() of the whole set
if adding new history at the head of the queue, or just append new
ones at the tail of the queue in shmem, memcpy() once the queue is
full. The extension gets simpler:
- No need to manage a new file, flush of the stats is controlled by
pgstats itself.
- The extension could register a fixed-numbered custom stats kind.
- Push the stats with the new hooks.
- Perhaps less useful, but it is possible to control the timing where
the data is pushed.
- Add SQL wrappers on top to fetch the data from pgstat.
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message James Hunter 2024-12-31 01:17:58 Re: Add the ability to limit the amount of memory that can be allocated to backends.
Previous Message James Hunter 2024-12-31 01:05:47 Re: Add the ability to limit the amount of memory that can be allocated to backends.