Re: Inlining comparators as a performance optimisation - Mailing list pgsql-hackers

From Greg Stark
Subject Re: Inlining comparators as a performance optimisation
Date
Msg-id CAM-w4HPw=A_weJVKpCHOTf-H9tu9AZNhY7Qfzf89-mnteuV8xA@mail.gmail.com
Whole thread Raw
In response to Re: Inlining comparators as a performance optimisation  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Wed, Sep 21, 2011 at 5:23 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> None of that stuff is inlinable or constant-foldable today, nor would it
> be with the patch that Peter was proposing AFAICS, because none of the
> flags will ever be compile time constant values.

I was referring to transformations like this which I believe compilers
are already capable of doing:

v = ...;
while (...) if (v) {   if (a < b) ... else ....; } else {   if (a > b) ... else ...; }

turning it into code that looks like:

if (v) {while (....)  if (a<b) ... else ...;
} else { while (....)   if (a>b) ... else ...;
}

which may not look like much -- especially with branch prediction --
but then it's much more likely to be able to unroll the loop and do
clever instruction scheduling and so on than if there's an extra
branch in the middle of the loop. But if there's a function call to an
external function called through a function pointer in the middle of
the loop then the whole endeavour would be for naught.



-- 
greg


pgsql-hackers by date:

Previous
From: Florian Pflug
Date:
Subject: Re: Hot Backup with rsync fails at pg_clog if under load
Next
From: Alvaro Herrera
Date:
Subject: Re: Is there really no interest in SQL Standard?