Re: Avoiding repeated snapshot computation - Mailing list pgsql-hackers

From Gurjeet Singh
Subject Re: Avoiding repeated snapshot computation
Date
Msg-id CABwTF4UhinaNb+jPTVmcznew1d7HstH8Nqw9t0Ag86tCYji-QQ@mail.gmail.com
Whole thread Raw
In response to Re: Avoiding repeated snapshot computation  (Andres Freund <andres@anarazel.de>)
Responses Re: Avoiding repeated snapshot computation
Re: Avoiding repeated snapshot computation
List pgsql-hackers
On Sat, Nov 26, 2011 at 6:51 PM, Andres Freund <andres@anarazel.de> wrote:
On Saturday, November 26, 2011 11:39:23 PM Robert Haas wrote:
> On Sat, Nov 26, 2011 at 5:28 PM, Andres Freund <andres@anarazel.de> wrote:
> > On Saturday, November 26, 2011 09:52:17 PM Tom Lane wrote:
> >> I'd just as soon keep the fields in a logical order.
> >
> > Btw, I don't think the new order is necessarily worse than the old one.
>
> You forget to attach the benchmark results.
>
> My impression is that cache lines on modern hardware are 64 or 128
> *bytes*, in which case this wouldn't matter a bit.
>
> But testing is even better than guessing.
Being prodded like that I ran a very quick benchmark on my workstation.
Unfortunately that means I cannot work during the time which is why I kept it
rather short...

That machine has 2 E5520@2.27GHz which means 2(sockets) * 4(cores) *
2(threads) and 24GB of ram.

Data was initialized with: pgbench -h /tmp/ --unlogged-tables -i -s 20 pgbench


pgbench -h /tmp/ pgbench -S -j 16 -c 16 -T 60

origsnap:       92825.743958 93145.110901 93389.915474 93175.482351
reordersnap:    93560.183272 93613.333494 93495.263012 93523.368489

pgbench -h /tmp/ pgbench -S -j 32 -c 32 -T 60

origsnap:       81846.743329 81545.175672 81702.755226 81576.576435
81228.154119 81546.047708 81421.436262
reordersnap:    81823.479196 81787.784508 81820.242145 81790.263415
81762.421592 81496.333144 81732.088876

At that point I noticed I had accidentally run with a nearly stock config...
An even shorter run with a more approrioate config yielded:


pgbench -h /tmp/ pgbench -S -j 32 -c 32 -T 20

origsnap:       102234.664020 102003.449741 102119.509053 101722.410387
101973.651318 102056.440561
reordersnap:    103444.877879 103385.888808 103302.318923 103372.659486
103330.157612 103313.833821



Looks like a win to me. Even on this comparatively small machine.

This may not be necessary, but can you please share the modified config you used for the last run.

I tabulated your last results to make it more readable, and added columns to show the improvement.
 
origsnap         reordersnap      diff           %age improvement
------------------------------------------------------------------
102234.66402     103444.877879    1210.213859    1.1837607827
102003.449741    103385.888808    1382.439067    1.3552865815
102119.509053    103302.318923    1182.80987     1.1582604352
101722.410387    103372.659486    1650.249099    1.6223063263
101973.651318    103330.157612    1356.506294    1.3302517626
102056.440561    103313.833821    1257.39326     1.2320567454

That looks like a win to me too. We're getting a little over 1% improvement for free!

Maybe submitting this patch to the commitfest might help get some serious consideration from a reviewer.

Regards,
--
Gurjeet Singh
EnterpriseDB Corporation
The Enterprise PostgreSQL Company

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [PATCH] Replace a long chain of if's in eval_const_expressions_mutator by a switch()
Next
From: Merlin Moncure
Date:
Subject: Re: patch for type privileges