Skip site navigation (1) Skip section navigation (2)

Re: WIP: Faster Expression Processing v4

From: Andres Freund <andres(at)anarazel(dot)de>
To: Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: WIP: Faster Expression Processing v4
Date: 2017-03-14 06:53:00
Message-ID: 20170314065259.ffef4tfhgbsaieoe@alap3.anarazel.de (view raw, whole thread or download thread mbox)
Thread:
Lists: pgsql-hackers
Hi,

On 2017-03-13 22:37:51 +0100, Tomas Vondra wrote:
> On 03/13/2017 09:03 AM, Andres Freund wrote:
> > Hi,
> >
> > On 2017-03-12 05:40:51 +0100, Tomas Vondra wrote:
> > > I wanted to do a bit of testing and benchmarking on this, but 0004 seems to
> > > be a bit broken.
> >
> > Well, "broken" in the sense that it's already outdated, because other
> > stuff that got merged.
> >
>
> Yes, that's what I meant. Sorry for not being quite clear.

And the patch already again has conflicts. Updated version, with a good
chunk of other changes, attached.

> >
> > > The patch does not apply anymore - there are some conflicts
> > > in execQual.c, but I think I fixed those. But then I ran into a bunch of
> > > compile-time errors, because some of the executor nodes still reference bits
> > > that were moved elsewhere.
> >
> > Updated patch attached.  Note that this patch has two changes I've not
> > yet evaluated performance-wise.
> >
>
> And which are those?

Primarily around minor performance regressions for the evaluation of
very simple (i.e. single Var/Const) expressions.  I did a fair amount of
work hunting these down.


Besides that, this version has:
- pgindented most of the affected pieces (i.e. all significant new code
  has been reindent, not all touched one)
- Transported missing comments from execQual.c - afaics all relevant
  ones have been moved over
- Replaced ExprState->cb with evalfunc - that's what it was named
  previously, and I see no reason to diverge.
- significantly expanded header comments, especially in
  execInterpExpr.c, explaining the basic approach of expression
  evaluation.  Feedback here would be greatly appreciated - I've spent
  so much time neck deep into this, that I don't quite know in how much
  detail to go.
- Initial polished commit messages and such.


My current plan is to not do very much on this tomorrow, do another full
pass on Wednesday, and push it, unless there's protest till then.


> I plan to do a bit of testing / benchmarking on this later this week,
> depending on other testing already happening on my machine.

Cool.


I've performed a bunch more benchmarks, and the results have been pretty
favorable.  Due to some more work hunting down minor regressions I can't
make any tpc-h query perform worse than on master, with either
best/average of three executions.  I also did a bunch of runs with
parallelism, and the results there are also pretty good - even better
than non-parallel sometimes.

These results include parallelism, but were done *before* rebasing ontop
of Noah's changes.  There was also, during all runs, a browser and emacs
running, so it's certainly possible that there's some skew.

-par is with parallelism enabled to 8, with is without.  Otherwise same
setup as two mails up.

master-par q01 min: 4629.643 master min: 15108.813 [diff +69.36] dev min: 12629.0 [diff +63.34] dev-par min: 3458.899 [diff -33.85]
master-par q02 min: 1048.511 master min: 1196.596 [diff +12.38] dev min: 1182.652 [diff +11.34] dev-par min: 1044.876 [diff -0.35]
master-par q03 min: 4651.492 master min: 6949.525 [diff +33.07] dev min: 6441.467 [diff +27.79] dev-par min: 3928.919 [diff -18.39]
master-par q04 min: 698.037 master min: 981.081 [diff +28.85] dev min: 947.506 [diff +26.33] dev-par min: 341.855 [diff -104.19]
master-par q05 min: 871.528 master min: 5119.728 [diff +82.98] dev min: 4979.498 [diff +82.50] dev-par min: 702.3 [diff -24.10]
master-par q06 min: 1107.307 master min: 1807.433 [diff +38.74] dev min: 1694.513 [diff +34.65] dev-par min: 738.037 [diff -50.03]
master-par q07 min: 4867.412 master min: 4745.141 [diff -2.58] dev min: 4682.068 [diff -3.96] dev-par min: 4207.644 [diff -15.68]
master-par q08 min: 432.159 master min: 1465.219 [diff +70.51] dev min: 1416.691 [diff +69.50] dev-par min: 418.331 [diff -3.31]
master-par q09 min: 3965.76 master min: 6441.099 [diff +38.43] dev min: 6220.095 [diff +36.24] dev-par min: 3875.673 [diff -2.32]
master-par q10 min: 1129.351 master min: 5818.318 [diff +80.59] dev min: 5406.125 [diff +79.11] dev-par min: 1107.759 [diff -1.95]
master-par q11 min: 247.598 master min: 291.061 [diff +14.93] dev min: 277.18 [diff +10.67] dev-par min: 241.983 [diff -2.32]
master-par q12 min: 1532.855 master min: 4552.034 [diff +66.33] dev min: 4431.584 [diff +65.41] dev-par min: 1395.703 [diff -9.83]
master-par q13 min: 8638.503 master min: 8009.64 [diff -7.85] dev min: 7891.661 [diff -9.46] dev-par min: 8314.437 [diff -3.90]
master-par q14 min: 723.878 master min: 764.35 [diff +5.29] dev min: 730.526 [diff +0.91] dev-par min: 717.66 [diff -0.87]
master-par q15 min: 1991.915 master min: 1809.162 [diff -10.10] dev min: 1716.983 [diff -16.01] dev-par min: 1879.927 [diff -5.96]
master-par q16 min: 1596.643 master min: 1843.553 [diff +13.39] dev min: 1728.467 [diff +7.63] dev-par min: 1429.103 [diff -11.72]
master-par q17 min: 354.357 master min: 418.761 [diff +15.38] dev min: 414.958 [diff +14.60] dev-par min: 322.471 [diff -9.89]
master-par q18 min: 11707.479 master min: 14216.567 [diff +17.65] dev min: 14206.893 [diff +17.59] dev-par min: 11642.863 [diff -0.55]
master-par q19 min: 116.819 master min: 325.531 [diff +64.11] dev min: 287.497 [diff +59.37] dev-par min: 102.909 [diff -13.52]
master-par q20 min: 430.85 master min: 500.92 [diff +13.99] dev min: 478.536 [diff +9.96] dev-par min: 410.548 [diff -4.95]
master-par q22 min: 460.712 master min: 626.207 [diff +26.43] dev min: 595.708 [diff +22.66] dev-par min: 434.851 [diff -5.95]

Thees seem like pretty neat results.  Sorry for not cleaning up the
representation - too tired.

Greetings,

Andres Freund

Attachment: 0001-Add-expression-dependencies-on-composite-type-whole-.patch.gz
Description: application/x-patch-gzip (5.0 KB)
Attachment: 0002-Make-get_last_attnums-more-generic.patch.gz
Description: application/x-patch-gzip (1.6 KB)
Attachment: 0003-Add-autoconf-test-for-computed-goto-support.patch.gz
Description: application/x-patch-gzip (1.7 KB)
Attachment: 0004-Faster-expression-evaluation-and-targetlist-projecti.patch.gz
Description: application/x-patch-gzip (101.8 KB)

In response to

Responses

pgsql-hackers by date

Next:From: Michael PaquierDate: 2017-03-14 07:03:05
Subject: Re: allow referring to functions without arguments when unique
Previous:From: Vaishnavi PrabakaranDate: 2017-03-14 06:50:19
Subject: Re: PATCH: Batch/pipelining support for libpq

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group