Bug 15267

Summary: Fix libm performance by relaxing ULP errors.
Product: glibc Reporter: Siddhesh Poyarekar <siddhesh>
Component: manualAssignee: Not yet assigned to anyone <unassigned>
Status: NEW ---    
Severity: normal CC: bugdal, carlos, manu, mtk.manpages, nszabolcs, roland, wdijkstr
Priority: P2 Flags: fweimer: security-
Version: unspecified   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:

Description Siddhesh Poyarekar 2013-03-11 06:35:05 UTC
libm has a fallback to multiprecision calculation for some functions (log, exp, atan, pow, etc.) which is much slower than the fast path.  While the inputs that trigger this are unknown, it would be useful to document the fact that there is such a performance difference, along with an explanation of why the multiprecision stage is needed at all.
Comment 1 Manuel López-Ibáñez 2013-03-11 09:10:09 UTC
Some background on why such documentation could save a lot of frustration can be found in bug 13932, and in http://entropymine.com/imageworsener/slowpow/, and simply by googling "slowpow".
Comment 2 Rich Felker 2013-03-15 05:57:21 UTC
Shouldn't this issue just be fixed? IEEE specifically omits the requirement of correct rounding for transcendental functions because of the long-known issue that there's no known efficient way to compute the correctly-rounded results. As far as I can tell, no other libm implementations have these performance bugs; they're unique to glibc and the "IBM Accurate Mathematical Library" written for glibc.
Comment 3 Carlos O'Donell 2013-03-15 14:37:59 UTC
(In reply to comment #2)
> Shouldn't this issue just be fixed? IEEE specifically omits the requirement of
> correct rounding for transcendental functions because of the long-known issue
> that there's no known efficient way to compute the correctly-rounded results.
> As far as I can tell, no other libm implementations have these performance
> bugs; they're unique to glibc and the "IBM Accurate Mathematical Library"
> written for glibc.

Sorry, are you advocating we "fix it" as opposed to "document it?"

If you are then I agree, but documenting things until you fix them is a good intermediate step.
Comment 4 Manuel López-Ibáñez 2017-06-08 20:27:55 UTC
At least since release 4.04, the Linux man-pages say:

On 64-bits, pow() may be more than 10,000 times slower for some (rare) inputs than for other nearby inputs.  This affects only pow(), and not powf() nor powl().
Comment 5 Carlos O'Donell 2020-05-19 13:53:13 UTC
I'm going to retitle this bug and instead of saying we're going to document the performance issues, we should fix them.

We have already agreed to relax the ULPs to 9 ULPs for all functions and thus remove the MP-fallback paths in these cases.

We have just had a user report that:

* acos
* asin

Both have MP-fallback cases that are very bad and should be fixed.

Szabolcs Nagy from Arm has worked on many of these fixes.
Comment 6 Wilco 2021-03-11 14:46:00 UTC
All slow paths have now been removed from all math functions.