Re: Optimize LISTEN/NOTIFY
Joel Jacobson <joel@compiler.org>
From: "Joel Jacobson" <joel@compiler.org>
To: "Arseniy Mukhin" <arseniy.mukhin.dev@gmail.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2025-11-13T07:13:28Z
Lists: pgsql-hackers
Attachments
- 0001-optimize_listen_notify-v27.patch (application/octet-stream)
- 0002-optimize_listen_notify-v27.patch (application/octet-stream)
On Thu, Nov 13, 2025, at 07:36, Arseniy Mukhin wrote: > On Thu, Nov 13, 2025 at 9:28 AM Joel Jacobson <joel@compiler.org> wrote: >> I think this confirms that listeners can actually stop somewhere in between >> queueHeadBeforeWrite and queueHeadAfterWrite. > > > Ahh, yes, I think you are right. I missed that notifiers update the > head when they move to the next page. Thank you for the detailed > example and sorry for taking your time with it. I agree that > QUEUE_POS_PRECEDES(pos, queueHeadAfterWrite) is correct and covers > more cases where we can do direct advancement. Thanks for investigating this; we now both have an even stronger mental model of the code. Attached, please find a new version rebased on top of the bug fix patches that just got committed in 0bdc777, 797e9ea, 8eeb4a0, and 1b46990. /Joel