Thread

  1. Re: Optimize LISTEN/NOTIFY

    Joel Jacobson <joel@compiler.org> — 2025-11-05T01:06:54Z

    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