commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Hain (JIRA)" <>
Subject [jira] [Commented] (MATH-740) Some "FastMath" functions are slow
Date Thu, 21 Feb 2013 19:44:13 GMT


Jeff Hain commented on MATH-740:

FastMath (of apache, and of jafama/jodk) methods can actually
be (multiple times) slower than Math ones when not JIT-optimized
(run with -Xint to force interpreted calls).

For jafama/jodk FastMath, which I saw you were considering
putting into apache libs (.../apache_commons_math/slides/183/1600_Thomas.pdf),
there are two more causes of slowness:
- caches-misses on look-up tables
- look-up tables initialization overhead (on class load)

That said, once the initialization is done,
if methods are not called a lot their slowness should usually not be a problem,
and if they are, then they should hopefully be JIT-optimized
with look-up tables in some CPU cache.

In jafama/jodk look-up tables are enabled by default (more precisely,
non-delegating to Math is enabled by default), but for a library as
heavily used as apache commons math, I would tend to be conservative,
and disable use of look-up tables by default to avoid surprising people
with the initialization overhead (which on my computer can be as low as
100ms with Java 5, but gets worse with every new milestone of Java, up to
400ms with Java 8).
But maybe people don't expect Java to ever start fast,
in which case it might not be a problem ;)

In latest jafama version (V2, from yesterday), I upgraded
bench class, such as it's now easy to bench methods
with values in various ranges.
If I find out how I can do it, I'll upload it,
stripped to match apache FastMath methods (3.1.1),
so you can run it yourself, as well as the ouput
of a run with -Xint.

> Some "FastMath" functions are slow
> ----------------------------------
>                 Key: MATH-740
>                 URL:
>             Project: Commons Math
>          Issue Type: Wish
>            Reporter: Gilles
>            Priority: Minor
>             Fix For: 3.2
> From the two benchmarks we currently have in "FastMathTestPerfomance", we have that the
following functions are much slower in "FastMath" than in either "Math" or "StrictMath" (the
performance *loss*, for each of the benchmarks, is given in parentheses):
> * log10 (46%, 36%)
> * log1p (68%, 112%)
> * tan (11%, 61%)
> * atan (26%, 125%)
> * atan2 (44%, 40%)

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:

View raw message