Bug 16531 - cosine very occasionally takes an exceptionally long time
Summary: cosine very occasionally takes an exceptionally long time
Status: RESOLVED DUPLICATE of bug 5781
Alias: None
Product: glibc
Classification: Unclassified
Component: math (show other bugs)
Version: 2.18
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-05 15:56 UTC by John Wilkinson
Modified: 2014-06-13 08:41 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments
demo code (827 bytes, text/plain)
2014-02-05 15:56 UTC, John Wilkinson
Details

Note You need to log in before you can comment on or make changes to this bug.
Description John Wilkinson 2014-02-05 15:56:59 UTC
Created attachment 7394 [details]
demo code

The cosine function, cos, can be exceedingly slow for a few number of values. From my measurement on my PC using the attached C++ program I find that cos almost always takes in the order of 2e-8 seconds, but occasionally it will take around 1.5e-4 seconds, 0.15ms. It always takes around this time for particular values, e.g. 1.27730245420149213 (radians). (This difference, 4 order of magnitude, is quite a problem for us as we have to repeatedly perform a large number of calculations within 1ms.)

GCC versions 4.6.3 and 4.7.2, GLIBC version 2.15, 2.18, i7 PCs, Ubuntu 12.04, Yocto
Comment 1 Ondrej Bilka 2014-02-05 16:05:38 UTC
That is known issue, see bug 5997. It is caused by wanting cos error to be at most ulp.

*** This bug has been marked as a duplicate of bug 5997 ***
Comment 2 John Wilkinson 2014-02-05 21:03:50 UTC
I don't think this is a duplicate of bug 5997 which concerns large multiples of PI. It looks more like a potential duplicate of bug 5781 although this seems specific to AMD64 whilst this reported problem is on Intel i7s.

Please note this is a critical problem for those implementing high performance real-time systems. A time of 0.15 ms is a massive amount of time for a modern processor. There are very few numbers for which cos takes this time but they are fatal for any guarantee of real-time performance.
Comment 3 jsm-csl@polyomino.org.uk 2014-02-05 21:20:11 UTC
On Wed, 5 Feb 2014, john.wilkinson at spirent dot com wrote:

> I don't think this is a duplicate of bug 5997 which concerns large multiples of
> PI. It looks more like a potential duplicate of bug 5781 although this seems
> specific to AMD64 whilst this reported problem is on Intel i7s.

The AMD64 mention there is simply because that was the system the 
submitter used for testing.  This is a duplicate of 5781, which is not 
architecture-specific at all.
Comment 4 John Wilkinson 2014-02-06 07:40:52 UTC
OK, I'll close this as duplicate of 5781.

*** This bug has been marked as a duplicate of bug 5781 ***