Re: Optimize LISTEN/NOTIFY
Thomas Munro <thomas.munro@gmail.com>
From: Thomas Munro <thomas.munro@gmail.com>
To: Joel Jacobson <joel@compiler.org>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>,
Heikki Linnakangas <hlinnaka@iki.fi>, Rishu Bagga <rishu.postgres@gmail.com>
Date: 2025-07-23T02:44:29Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Optimize LISTEN/NOTIFY via shared channel map and direct advancement.
- 282b1cde9ded 19 (unreleased) landed
-
Fix incorrect logic for caching ResultRelInfos for triggers
- 39dcfda2d23a 19 (unreleased) cited
On Wed, Jul 23, 2025 at 1:39 PM Joel Jacobson <joel@compiler.org> wrote: > In their patch, in asyn.c's SignalBackends(), they do > SendInterrupt(INTERRUPT_ASYNC_NOTIFY, procno) instead of > SendProcSignal(pid, PROCSIG_NOTIFY_INTERRUPT, procnos[i]). They don't > seem to check if the backend is already signalled or not, but maybe > SendInterrupt() has signal coalescing built-in so it would be a noop > with almost no cost? Yeah: + old_pending = pg_atomic_fetch_or_u32(&proc->pendingInterrupts, interruptMask); + + /* + * If the process is currently blocked waiting for an interrupt to arrive, + * and the interrupt wasn't already pending, wake it up. + */ + if ((old_pending & (interruptMask | SLEEPING_ON_INTERRUPTS)) == SLEEPING_ON_INTERRUPTS) + WakeupOtherProc(proc);