Re: Review: Patch for phypot - Pygmy Hippotause

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Andrew Geery" <andrew(dot)geery(at)gmail(dot)com>,<plm(at)netspace(dot)net(dot)au>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Review: Patch for phypot - Pygmy Hippotause
Date: 2010-07-17 15:39:37
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andrew Geery <andrew(dot)geery(at)gmail(dot)com> wrote:

> The HYPOT macro executed 100 million times in 11 seconds and the
> phypot function executed the same number of times in 22 seconds.

Or, to put that another way, the new function adds 110 nanoseconds
to each hypotenuse calculation.

> With both -O2 and -O3, the HYPOT macro executed in 8 seconds and
> the phypot in 18.

Or, with these optimizations, it adds 100 nanoseconds to each
hypotenuse calculation.

I don't know about others, but that seems a reasonable price to pay
to eliminate all possible underflows, all overflows except where the
result doesn't fit in the result data type, and make NaN and Inf
processing more standard compliant.

> I found that the difference in the two calculations were always
> less than 0.000001. However, about a third of the calculations
> differed at one more magnitude of precision (that is, there were
> differences in the calculations that were greater than 0.0000001).

That's harder for me to evaluate in terms of whether it's
acceptable. It *is* an *approximate* data type, and the differences
are all less than 0.0001%; however, that seems like a pretty weak
guarantee if it's making the answer less accurate. If we could take
some of these cases with relatively large differences and see which
of the calculations is more accurate, that might help make a
decision. I'm not sure which technique would tend to be more
accurate. Since they're algebraically equivalent, and what we're
using now pushes toward underflow and overflow more readily, it
seems possible that the differences will generally reflect a greater
accuracy in the patch's technique.


In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Kevin Grittner 2010-07-17 16:25:20 Re: Review: Row-level Locks & SERIALIZABLE transactions, postgres vs. Oracle
Previous Message Kevin Grittner 2010-07-17 15:14:29 Re: SHOW TABLES