Re: Stack-based tracking of per-node WAL/buffer usage

Lukas Fittl <lukas@fittl.com>

From: Lukas Fittl <lukas@fittl.com>
To: Heikki Linnakangas <hlinnaka@iki.fi>
Cc: Zsolt Parragi <zsolt.parragi@percona.com>, Andres Freund <andres@anarazel.de>, Tomas Vondra <tomas@vondra.me>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>, Peter Smith <smithpb2250@gmail.com>
Date: 2026-03-27T07:21:23Z
Lists: pgsql-hackers

Attachments

On Wed, Mar 25, 2026 at 5:41 PM Lukas Fittl <lukas@fittl.com> wrote:
> On Wed, Mar 25, 2026 at 3:47 AM Heikki Linnakangas <hlinnaka@iki.fi> wrote:
> > This patch could use an overview README file, I'm struggling to
> > understand how the this all works. Here's my understanding so far,
> > please correct me if I'm wrong:
>
> Sure, happy to put this together - I wonder where would place that
> best - probably src/backend/executor/README.instrument ?

I've gone ahead and added that in
src/backend/executor/README.instrument for now, trying to take some of
your prior email as inspiration, whilst not fully committing to
describing it as a tree - but happy to revise that if we feel its
important for clarity.

See attached v11, rebased after the pgBufferUsage calls were moved in
df09452c3209, and also fixing the issues that Zsolt noted in a
previous email reviewing v10.

I've also moved pg_session_buffer_usage to be a
test_session_buffer_usage module instead, since its not intended as a
user accessible module. If we wanted to commit that (not sure if its
worth the cycles), we could potentially merge it with the 0004 commit
that expands the main regression tests.

Thanks,
Lukas

-- 
Lukas Fittl

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. instrumentation: Allocate query level instrumentation in ExecutorStart

  2. instrumentation: Move ExecProcNodeInstr to allow inlining

  3. instrumentation: Separate per-node logic from other uses

  4. instrumentation: Separate trigger logic from other uses

  5. instrumentation: Rename INSTR_TIME_LT macro to INSTR_TIME_GT

  6. instrumentation: Keep time fields as instrtime, convert in callers