Re: Optimize LISTEN/NOTIFY

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Joel Jacobson" <joel(at)compiler(dot)org>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Optimize LISTEN/NOTIFY
Date: 2026-01-14 23:09:05
Message-ID: 422696.1768432145@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I wrote:
> I think that if we have a backend that isn't interested in our
> notifications, and we can't direct-advance it, we should apply
> the same behavior that was previously used for backends in other
> databases. That was basically a conservative approximation to
> "isn't interested", and I don't see why it wouldn't work fine
> when we have a more accurate idea of "isn't interested".

I spent some time trying to measure the impact of that point,
by modifying the test program you posted upthread so that
some notifiers go at full speed while others respond to the
rate-limit switch so that they can be made to go slowly.
I couldn't really see any difference between what you have in v34
and doing this the old way. Maybe I just failed to construct the
right test case to stress this behavior. But anyway, without
concrete evidence for a change I think we should stick to the
old behavior. When that was put in, it was to ameliorate a
demonstrable "thundering herd" problem, and it seems likely to me
that we'll bring that back for some usage patterns if we eagerly
awaken backends that don't really need to do anything right away.

So, here's a reworked v35, which also incorporates quite a lot
of cosmetic modifications as well as some bug fixes (mostly
to do with being sure we recover from foreseeble problems like
OOM partway through commit). I think this is pretty close to
committable, but if you see anything you don't like, let me know.

regards, tom lane

Attachment Content-Type Size
v35-0001-Improve-LISTEN-NOTIFY-test-coverage.patch text/x-diff 9.6 KB
v35-0002-Optimize-LISTEN-NOTIFY-via-shared-channel-map-an.patch text/x-diff 62.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jelte Fennema-Nio 2026-01-14 23:12:03 Re: Proposal to allow setting cursor options on Portals
Previous Message Jacob Champion 2026-01-14 22:56:50 Re: libpq: Bump protocol version to version 3.2 at least until the first/second beta