Re: [PATCH] Use optimized single-datum tuplesort in ExecSort - Mailing list pgsql-hackers

From Ranier Vilela
Subject Re: [PATCH] Use optimized single-datum tuplesort in ExecSort
Date
Msg-id CAEudQArTDobADxmj=q_g-jYLaOodvW=JoWEc11ebNVRoG4xVdw@mail.gmail.com
Whole thread Raw
In response to Re: [PATCH] Use optimized single-datum tuplesort in ExecSort  (David Rowley <dgrowleyml@gmail.com>)
List pgsql-hackers
Em qua., 14 de jul. de 2021 às 22:22, David Rowley <dgrowleyml@gmail.com> escreveu:
On Thu, 15 Jul 2021 at 12:30, Ranier Vilela <ranier.vf@gmail.com> wrote:
>
> Em qua., 14 de jul. de 2021 às 21:21, David Rowley <dgrowleyml@gmail.com> escreveu:
>> But, in v8 there is no additional branch, so no branch to mispredict.
>> I don't really see how your explanation fits.
>
> In v8 the branch occurs at :
> + if (ExecGetResultType(outerPlanState(sortstate))->natts == 1)

You do know that branch is in a function that's only executed once
during executor initialization, right?
The branch prediction should work better.
I have no idea why it works worse.

I redid all tests:
notebook 8GB RAM 256GB SSD
ubuntu 64 bits (20.04)
clang-12
powerhigh (charger on)
none configuration (all defaults)


          HEAD          v6         v7b             v8         v6 vs head           v7b vs v6          v8 vs v7b
Test1576,868013940,9472361090,2538591016,0443163,11%115,87%93,19%
Test2184,748363177,6254177,346229178,23025896,14%99,84%100,50%
Test3410,030055541,889704605,843924534,946166132,16%111,80%88,30%
Test4153,331752147,98418148,010894147,77115596,51%100,02%99,84%
Test5268,97555301,979647316,928492300,94932112,27%104,95%94,96%
Test6234,910125259,71483269,851427260,567637110,56%103,90%96,56%
Test7142,704153136,09163136,802695136,93570995,37%100,52%100,10%
Test8498,634855763,482151867,350046804,833884153,11%113,60%92,79%

The values are high here, because now, the tests are made with full power of cpu to all patchs!
I think that more testing is needed with v7b and v8.

Anyway, two functions (ExecSortTuple and ExecSortDatum) are almost equal, maybe not a good idea.

file results attached.

regards,
Ranier Vilela
Attachment

pgsql-hackers by date:

Previous
From: "houzj.fnst@fujitsu.com"
Date:
Subject: RE: Avoid repeated PQfnumber() in pg_dump
Next
From: "liuhuailing@fujitsu.com"
Date:
Subject: RE: SI messages sent when excuting ROLLBACK PREPARED command