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

Zsolt Parragi <zsolt.parragi@percona.com>

From: Zsolt Parragi <zsolt.parragi@percona.com>
To: Lukas Fittl <lukas@fittl.com>
Cc: Heikki Linnakangas <hlinnaka@iki.fi>, 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-24T22:59:45Z
Lists: pgsql-hackers
I like the new approach, but doesn't `EXPLAIN (BUFFERS)` leak some
memory because the resource owner isn't registered on that path? It
seems to be visible with pg_log_backend_memory_contexts.

 #define INSTR_BUFUSAGE_ADD(fld,val) do { \
- pgBufferUsage.fld += val; \
+ instr_stack.current->bufusage.fld += val; \

 #define INSTR_WALUSAGE_ADD(fld,val) do { \
  pgWalUsage.fld += val; \
+ instr_stack.current->walusage.fld += val; \

Nitpick, but these could use += (val)



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