Re: walsender performance regression due to logical decoding on standby changes

From: Andres Freund <andres(at)anarazel(dot)de>
To: "Drouvot, Bertrand" <bertranddrouvot(dot)pg(at)gmail(dot)com>
Cc: Jeff Davis <pgsql(at)j-davis(dot)com>, pgsql-hackers(at)postgresql(dot)org, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Subject: Re: walsender performance regression due to logical decoding on standby changes
Date: 2023-05-17 19:34:48
Message-ID: 20230517193448.qu5afhsy3ig4u5wu@awork3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2023-05-10 08:39:08 +0200, Drouvot, Bertrand wrote:
> On 5/9/23 11:00 PM, Andres Freund wrote:
> > Hi,
> >
> > On 2023-05-09 13:38:24 -0700, Jeff Davis wrote:
> > > On Tue, 2023-05-09 at 12:02 -0700, Andres Freund wrote:
> > > > I don't think the approach of not having any sort of "registry" of
> > > > whether
> > > > anybody is waiting for the replay position to be updated is
> > > > feasible. Iterating over all walsenders slots is just too expensive -
> > >
> > > Would it work to use a shared counter for the waiters (or, two
> > > counters, one for physical and one for logical), and just early exit if
> > > the count is zero?
> >
> > That doesn't really fix the problem - once you have a single walsender
> > connected, performance is bad again.
> >
>
> Just to clarify, do you mean that if there is only one remaining active walsender that, say,
> has been located at slot n, then we’d still have to loop from 0 to n in WalSndWakeup()?

I understood Jeff's proposal to just have an early exit if there are no
walsenders connected at all. But yes, even if we stopped iterating after
finding the number of slots we needed to, having to iterate over empty slots
would be an issue.

But TBH, even if we only did work for connected walsenders, I think this would
still be a performance issue. Acquiring O(#connected-walsenders) spinlocks for
every record is just too expensive.

Greetings,

Andres Freund

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2023-05-17 19:34:54 Re: Assert failure of the cross-check for nullingrels
Previous Message Jonathan S. Katz 2023-05-17 19:23:13 Re: Possible regression setting GUCs on \connect