Re: [HACKERS] Sun performance - Major discovery!

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Marko Karppinen <marko(at)karppinen(dot)fi>
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, PostgreSQL Performance <pgsql-performance(at)postgresql(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [HACKERS] Sun performance - Major discovery!
Date: 2003-10-14 16:52:57
Message-ID: 10568.1066150377@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-performance

Marko Karppinen <marko(at)karppinen(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2003-10-14 17:13:33 Re: pg_ctl reload - is it safe?
Previous Message Manfred Spraul 2003-10-14 16:26:34 Re: fix for strict-alias warnings

Browse pgsql-performance by date

  From Date Subject
Next Message Jeremy M. Guthrie 2003-10-14 16:54:16 free space map usage
Previous Message Wei Weng 2003-10-14 16:48:06 Re: [SQL] sql performance and cache