Re: [HACKERS] Sun performance - Major discovery! - Mailing list pgsql-performance

From Tom Lane
Subject Re: [HACKERS] Sun performance - Major discovery!
Date
Msg-id 10568.1066150377@sss.pgh.pa.us
Whole thread Raw
In response to Re: [HACKERS] Sun performance - Major discovery!  (Marko Karppinen <marko@karppinen.fi>)
List pgsql-performance
Marko Karppinen <marko@karppinen.fi> writes:
> At least the --fast-math part causes problems, seeing that PostgreSQL
> actually checks for the __FAST_MATH__ macro to make sure that it isn't
> turned on. There might be other problems with Apple's flags, but I
> think that the __FAST_MATH__ check should be altered.

Removing the check is not acceptable --- we spent far too much time
fighting bug reports that turned out to trace to -ffast-math.
See for example
http://archives.postgresql.org/pgsql-bugs/2002-09/msg00169.php

> As you know, setting --fast-math in GCC is the equivalent of setting
> -fno-math-errno, -funsafe-math-optimizations, -fno-trapping-math,
> -ffinite-math-only and -fno-signaling-nans.

I suspect that -funsafe-math-optimizations is the only one of those that
really affects the datetime code, but I would be quite worried about the
side-effects of any of them on the float8 arithmetic routines.  Also I
think the behavior of -ffast-math has changed over time; in the gcc
2.95.3 manual I see none of the above and only the description

`-ffast-math'
     This option allows GCC to violate some ANSI or IEEE rules and/or
     specifications in the interest of optimizing code for speed.  For
     example, it allows the compiler to assume arguments to the `sqrt'
     function are non-negative numbers and that no floating-point values
     are NaNs.

Since we certainly do use NaNs, it would be very bad to allow -ffast-math
in gcc 2.95.

gcc 3.2 has some but not all of the sub-flags you list above, so
apparently the behavior changed again as of gcc 3.3.

This means that relaxing the check would require (a) finding out which
of the sub-flags break our code and which don't; (b) finding out how the
answer to (a) has varied with gcc release; and (c) finding out how we
can test whether a given sub-flag is set --- are there #defines for each
of them in gcc 3?

This does not sound real practical to me...

> This would allow people to use CFLAGS="-fast" on their G5s, beat some
> Xeon speed records, and not worry about esoteric IEEE math standards.

In the words of the sage, "I can make this code *arbitrarily* fast ...
if it doesn't have to give the right answer."  Those "esoteric"
standards make the difference between printing 5:00:00 and printing
4:59:60.

            regards, tom lane

pgsql-performance by date:

Previous
From: "Relaxin"
Date:
Subject: Re: One or more processor ?
Next
From: Josh Berkus
Date:
Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL