Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pwh8Q-0006eW-FK for pgsql-hackers@arkaria.postgresql.org; Wed, 10 May 2023 10:33:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pwh8O-0004MU-Lq for pgsql-hackers@arkaria.postgresql.org; Wed, 10 May 2023 10:33:24 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pwh8O-0004MI-Cc for pgsql-hackers@lists.postgresql.org; Wed, 10 May 2023 10:33:24 +0000 Received: from mail-oi1-x22d.google.com ([2607:f8b0:4864:20::22d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1pwh8J-001Y5I-Bb for pgsql-hackers@postgresql.org; Wed, 10 May 2023 10:33:23 +0000 Received: by mail-oi1-x22d.google.com with SMTP id 5614622812f47-3941c3ba226so827960b6e.0 for ; Wed, 10 May 2023 03:33:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683714798; x=1686306798; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=f40Nbu3LU1JjkUlMJ4o6e29Q534Mlt1jMOH532LHqdk=; b=De8XYREdtVlDSl2JV7R+jMwZaKI4b6odDj/MSek0xMLwvaNhqSqxiRIxlsoMsEFGyO k6Pd5h4q3EwQs2weCqW4k48TGgoN87zKvBY1Z8GXCs6hw3UXlAhURzfIFaPFcSbdxywC ZxwJAb61p5Jw2fTuUed1SCM9CbvTVP7J/cqrfO09RkfR/mt6+j7I4wpeMB609KwF6r0z lZC82MYQbKHnYCv5IGPYcS5Fe5uKtxOPZIZbBbweXbSGi8lsHkvu8iXmNm/PqJoggIrf +SqHDOTshEcGsyazvwu+4yeRXZM2hIcfdcN7hRJmNU1CfIrLSP5Y9yDCkCUULP8TjJmB Xs8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683714798; x=1686306798; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=f40Nbu3LU1JjkUlMJ4o6e29Q534Mlt1jMOH532LHqdk=; b=aWj8Sf+z3tz5zso5ygz5ymjffytr7rW95jqxR46fawYa4KeKfxhq4E7G8dKwZRTNw+ CEjlSeEUqtEt84iTZAh+WFTPomlKX1NjnT85rm4RH6q9bWkBqObChfdpCFuN+u7Ryk4O jeD8ehL/9X9ejNA3/xo+qOuOzIJegsRY6LLxmBocIXk7F3RF2buI0p5bb7OpDOYzQn1B Ou889GJgX2YlTu+Ne6MhTzMtFauuyrPcnAQGW8CmTc+D6U6cqrAiruIDuw8eVJrhNTyS b14wp/JRXmfe1XcDMKsUSOjjCbXGV2VdN/zRDYOb2T0oZbRK6fu0VTFL81sLXEfEz6EX ccKQ== X-Gm-Message-State: AC+VfDwSDAQ4eTZuNHHk5O8oOfH9gSY681YLOjhlR7HSpptfIqunHo0u kRqZZoal85u4ho78QPgp9C3q0J0n8NkbaV/HHsvFy6Rjq4x2aw== X-Google-Smtp-Source: ACHHUZ5k9gxX2hafDH2oKJHvt0mZlELws7Sc6D3ooVj7oqUxpvojqxLQO9WJYwdNVR0bpeg8ySEioiUfG1v/IPNAKww= X-Received: by 2002:a05:6808:3cf:b0:38d:f585:882f with SMTP id o15-20020a05680803cf00b0038df585882fmr2923618oie.13.1683714798455; Wed, 10 May 2023 03:33:18 -0700 (PDT) MIME-Version: 1.0 References: <20230509190247.3rrplhdgem6su6cg@awork3.anarazel.de> In-Reply-To: From: Amit Kapila Date: Wed, 10 May 2023 16:03:07 +0530 Message-ID: Subject: Re: walsender performance regression due to logical decoding on standby changes To: "Zhijie Hou (Fujitsu)" Cc: Bharath Rupireddy , "pgsql-hackers@postgresql.org" , "Drouvot, Bertrand" , Jeff Davis , Robert Haas , Masahiko Sawada , Andres Freund Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, May 10, 2023 at 3:41=E2=80=AFPM Zhijie Hou (Fujitsu) wrote: > > On Wednesday, May 10, 2023 2:36 PM Bharath Rupireddy wrote: > > > > > > > My current guess is that mis-using a condition variable is the best b= et. I > > > think it should work to use ConditionVariablePrepareToSleep() before = a > > > WalSndWait(), and then ConditionVariableCancelSleep(). I.e. to never = use > > > ConditionVariableSleep(). The latch set from ConditionVariableBroadca= st() > > > would still cause the necessary wakeup. > > > > How about something like the attached? Recovery and subscription tests > > don't complain with the patch. > > Thanks for the patch. I noticed one place where the logic is different fr= om before and > just to confirm: > > if (AllowCascadeReplication()) > - WalSndWakeup(switchedTLI, true); > + ConditionVariableBroadcast(&WalSndCtl->cv); > > After the change, we wakeup physical walsender regardless of switchedTLI = flag. > Is this intentional ? if so, I think It would be better to update the com= ments above this. > This raises the question of whether we need this condition variable logic for physical walsenders? --=20 With Regards, Amit Kapila.