Re: Optimize LISTEN/NOTIFY - Mailing list pgsql-hackers

From Joel Jacobson
Subject Re: Optimize LISTEN/NOTIFY
Date
Msg-id 956ecc50-b0af-4865-be1f-97b082cb6b1f@app.fastmail.com
Whole thread Raw
In response to Re: Optimize LISTEN/NOTIFY  ("Joel Jacobson" <joel@compiler.org>)
List pgsql-hackers
On Wed, Nov 5, 2025, at 01:58, Joel Jacobson wrote:
> Changes since v22:
>
> * Optimize listening on thousands of channels per backend by replacing
>   the listenChannels List with a local hash table, renamed to
>   listenChannelsHash to avoid confusion.

I forgot to say that this is per idea from Heikki in the other thread [1]:

"The elephant in the room of course is that a lookup in a linked list is 
O(n) and it would be very straightforward to replace it with e.g. a hash 
table. We should do that irrespective of this bug fix. But I'm inclined 
to do it as a separate followup patch."

[1] https://www.postgresql.org/message-id/66213fee-00ff-4952-802d-c06454e521ac%40iki.fi

> * Removed advisoryPos, since it was not actually used. We only needed
>   advancingPos to fix the bug with truncation of the queue. It's possible
>   that the bottleneck in some workloads is no longer the wakeups, but I'm
>   not sure yet; I'll do some more benchmarking to get a better
>   understanding of whether it would be worthwhile to pursue further
>   optimization.
>
> * Removed asyncQueuePageDiff, since it's no longer used.

/Joel



pgsql-hackers by date:

Previous
From: "Joel Jacobson"
Date:
Subject: Re: Optimize LISTEN/NOTIFY
Next
From: "Joel Jacobson"
Date:
Subject: Re: LISTEN/NOTIFY bug: VACUUM sets frozenxid past a xid in async queue