Re: Slaying the HYPOTamus

From: Greg Stark <gsstark(at)mit(dot)edu>
To: Paul Matthews <plm(at)netspace(dot)net(dot)au>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Slaying the HYPOTamus
Date: 2009-08-23 04:39:52
Message-ID: 407d949e0908222139t35ad3ad2q3e6b15646a27dd64@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Aug 23, 2009 at 4:54 AM, Paul Matthews<plm(at)netspace(dot)net(dot)au> wrote:
>
> The hypot() function has been part of the C standard since C99 (ie 10
> years ago)

Postgres targets C89. The date of the standard is when the standard
came out, it takes years before it's widely available and then years
again before the systems with the old compiler are no longer
interesting.

If there's a performance advantage then we could add a configure test
and define the macro to call hypot(). You said it existed before C99
though, how widespread was it? If it's in all the platforms we support
it might be reasonable to just go with it.

> The function is designed not to fail where the current naive macro would
> result in overflow.

The code seems to be blissfully unaware of overflow dangers :( Even if
hypot() avoids spurious overflows it's always possible for there to be
a legitimate overflow which we ought to detect and handle properly.

--
greg
http://mit.edu/~gsstark/resume.pdf

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Stark 2009-08-23 04:42:23 Re: BUG #4996: postgres.exe memory consumption keeps going up
Previous Message Craig Ringer 2009-08-23 03:58:01 Re: BUG #4996: postgres.exe memory consumption keeps going up