public inbox for [email protected]
help / color / mirror / Atom feedFrom: [email protected] <[email protected]>
To: Amit Kapila <[email protected]>
To: Masahiko Sawada <[email protected]>
Cc: [email protected] <[email protected]>
Cc: [email protected] <[email protected]>
Cc: Dilip Kumar <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Cc: Peter Smith <[email protected]>
Subject: RE: Perform streaming logical transactions by background workers and parallel apply
Date: Thu, 27 Oct 2022 02:34:24 +0000
Message-ID: <OSZPR01MB631065ECB16022359116FDE6FD339@OSZPR01MB6310.jpnprd01.prod.outlook.com> (raw)
In-Reply-To: <CAA4eK1LKLb+fD=o0BfPofzkbqSwRqrvBFXpkiujqDg9Uk9Q_=Q@mail.gmail.com>
References: <OS0PR01MB5716730C06159452335D870D947F9@OS0PR01MB5716.jpnprd01.prod.outlook.com>
<CAA4eK1Lu-6oXMk7ZaGYLwm3CRLBuzueGbasyHnNpJxu6Mq3mmg@mail.gmail.com>
<OS3PR01MB6275F145878B4A44586C46CE9E499@OS3PR01MB6275.jpnprd01.prod.outlook.com>
<CAA4eK1LMVdS6uM7Tw7ANL0BetAd76TKkmAXNNQa0haTe2tax6g@mail.gmail.com>
<OS3PR01MB6275EFC4B707650DAB9392859E4D9@OS3PR01MB6275.jpnprd01.prod.outlook.com>
<CAHut+PuVjRgGr4saN7qwq0oB8DANHVR7UfDiciB1Q3cYN54F6A@mail.gmail.com>
<OS3PR01MB627567CF4B96A23DAFAF77269E4E9@OS3PR01MB6275.jpnprd01.prod.outlook.com>
<CAA4eK1KEf6w1azJytYnLhd2Lo-=rPkRh1Jv2ePcvs=SKqNQnAQ@mail.gmail.com>
<CAA4eK1KjGNA8T8O77rRhkv6bRT6OsdQaEy--2hNrJFCc80bN0A@mail.gmail.com>
<OS0PR01MB571620741B90C769D2727D7F94559@OS0PR01MB5716.jpnprd01.prod.outlook.com>
<CAHut+PvFENKb5fcMko5HHtNEAaZyNwGhu3PASrcBt+HFoFL=Fw@mail.gmail.com>
<OS0PR01MB5716B400CD81565E868616DB945F9@OS0PR01MB5716.jpnprd01.prod.outlook.com>
<OS3PR01MB6275328AD1B56164C66A552D9E229@OS3PR01MB6275.jpnprd01.prod.outlook.com>
<CAA4eK1Jp4xEC_hJvanrcroo-DGX8CMjZw_D4SqZOe7Az+xrPQA@mail.gmail.com>
<OS0PR01MB57160760B34E1655718F4D1994249@OS0PR01MB5716.jpnprd01.prod.outlook.com>
<CAHut+PsY0aevdVqeCUJOrRQMrwpg5Wz3-Mo+bU=mCxW2+9EBTg@mail.gmail.com>
<OS0PR01MB57160B0C0FDDCED638639696942B9@OS0PR01MB5716.jpnprd01.prod.outlook.com>
<CAHut+Ps0HXawMD=zQ5YUncc9kjGy+md_39Y4Fdf=sKjt-LE92g@mail.gmail.com>
<CAA4eK1+C=rDCVLS0axEx=kVeA6FTAZce+4nL_y=qZ2P+NAVjow@mail.gmail.com>
<OS0PR01MB57163F73F6FA5741F3FF2176942D9@OS0PR01MB5716.jpnprd01.prod.outlook.com>
<CAD21AoDfuaCQhJKBQjcrAKT9bqwuyvDzPxdJrupRDs7_7c22Nw@mail.gmail.com>
<CAA4eK1LKLb+fD=o0BfPofzkbqSwRqrvBFXpkiujqDg9Uk9Q_=Q@mail.gmail.com>
On Wed, Oct 26, 2022 7:19 PM Amit Kapila <[email protected]> wrote:
>
> On Tue, Oct 25, 2022 at 8:38 AM Masahiko Sawada
> <[email protected]> wrote:
> >
> > On Fri, Oct 21, 2022 at 6:32 PM [email protected]
> > <[email protected]> wrote:
> >
> > I've started to review this patch. I tested v40-0001 patch and have
> > one question:
> >
> > IIUC even when most of the changes in the transaction are filtered out
> > in pgoutput (eg., by relation filter or row filter), the walsender
> > sends STREAM_START. This means that the subscriber could end up
> > launching parallel apply workers also for almost empty (and streamed)
> > transactions. For example, I created three subscriptions each of which
> > subscribes to a different table. When I loaded a large amount of data
> > into one table, all three (leader) apply workers received START_STREAM
> > and launched their parallel apply workers.
> >
>
> The apply workers will be launched just the first time then we
> maintain a pool so that we don't need to restart them.
>
> > However, two of them
> > finished without applying any data. I think this behaviour looks
> > problematic since it wastes workers and rather decreases the apply
> > performance if the changes are not large. Is it worth considering a
> > way to delay launching a parallel apply worker until we find out the
> > amount of changes is actually large?
> >
>
> I think even if changes are less there may not be much difference
> because we have observed that the performance improvement comes from
> not writing to file.
>
> > For example, the leader worker
> > writes the streamed changes to files as usual and launches a parallel
> > worker if the amount of changes exceeds a threshold or the leader
> > receives the second segment. After that, the leader worker switches to
> > send the streamed changes to parallel workers via shm_mq instead of
> > files.
> >
>
> I think writing to file won't be a good idea as that can hamper the
> performance benefit in some cases and not sure if it is worth.
>
I tried to test some cases that only a small part of the transaction or an empty
transaction is sent to subscriber, to see if using streaming parallel will bring
performance degradation.
The test was performed ten times, and the average was taken.
The results are as follows. The details and the script of the test is attached.
10% of rows are sent
----------------------------------
HEAD 24.4595
patched 18.4545
5% of rows are sent
----------------------------------
HEAD 21.244
patched 17.9655
0% of rows are sent
----------------------------------
HEAD 18.0605
patched 17.893
It shows that when only 5% or 10% of rows are sent to subscriber, using parallel
apply takes less time than HEAD, and even if all rows are filtered there's no
performance degradation.
Regards
Shi yu
Attachments:
[application/x-zip-compressed] script.zip (3.0K, ../OSZPR01MB631065ECB16022359116FDE6FD339@OSZPR01MB6310.jpnprd01.prod.outlook.com/2-script.zip)
download
view thread (625+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: RE: Perform streaming logical transactions by background workers and parallel apply
In-Reply-To: <OSZPR01MB631065ECB16022359116FDE6FD339@OSZPR01MB6310.jpnprd01.prod.outlook.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox