On Sat, Mar 24, 2007 at 09:37:07PM +0000, Gregory Stark wrote:
> It sounds like a fine idea from the point of view of flexibility. But as far
> as faster... I guess it depends on how often HeapTupleSatisfiesVisibility is
> used in contexts where the compiler is able to optimize away the conditionals
> or the cpu is able to predict them accurately. I suspect in the cases where we
> actually care--scans where it's being called thousands of times quickly--the
> latter is quite effective.
Dunno, this test by someone suggests that calling through a function
pointer doesn't cost anything at all, if anything it's faster. Though
that may differ on other machines obviously.
http://gcc.gnu.org/ml/gcc/2004-06/msg01308.html
In any case, looking at the code I don't think the compiler can
optimise HeapTupleSatisfiesVisibility at all ever, because it's never
specified explicitly.
> Function pointers are notoriously hard to optimize around and can actually
> make the surrounding code harder to optimize as well especially since we
> compile with -fno-strict-aliasing. So whether it's faster or slower may depend
> a lot on the specific call site.
The costs of -fno-strict-aliasing are probably measurable, but I don't
think we can do anything about that...
Have a nice day,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.