Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
Name: rmT116609 Date: 01/23/2003 FULL PRODUCT VERSION : java version "1.4.1" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-b21) Java HotSpot(TM) Client VM (build 1.4.1-b21, mixed mode) FULL OPERATING SYSTEM VERSION : glibc-2.3.1-13 kernel 2.4.7-10 Redhat 7.2 Windows 2000 A DESCRIPTION OF THE PROBLEM : There is a performance regression in Math.cos and Math.sin (and possibly other trig. functions I have not tested) between JDK 1.3.1 and JDK 1.4.1. Although I see Math functions such as exp and sqrt work significantly faster in 1.4.1 than in 1.3.1, sin and cos are 2.5 times slower in 1.4.1 than in 1.3.1. This is a large part of the reason for the performance regression reported in the benchmark at http://www.coyotegulch.com/reviews/almabench.html and widely disseminated at various linux-oriented sites. STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : 1. Run the attached microbenchmark under JDK 1.3.1 and JDK 1.4.1 on linux. EXPECTED VERSUS ACTUAL BEHAVIOR : Expected results: All Math functions run at the same speed or faster under 1.4.1 when compared to 1.3.1 Actual results: exp and sqrt do run faster, but sin and cos are significantly slower REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- public class trigbench { public static void main(String [] args) { double v = 0; double t = 0; int n = 30000000; // Warmup JIT for (int i = 0; i < n; i++) { double m = v%(2*Math.PI); t += e(m)*f(m)*g(m)*h(m); v += 0.1; } long tStart, tEnd; tStart = System.currentTimeMillis(); for (int i = 0; i < n; i++) { t += e(v%(2*Math.PI)); v += 0.1; } tEnd = System.currentTimeMillis(); System.out.println("Time for cos (s):"+(tEnd-tStart)/1000.0); tStart = System.currentTimeMillis(); for (int i = 0; i < n; i++) { t += f(v%(2*Math.PI)); v += 0.1; } tEnd = System.currentTimeMillis(); System.out.println("Time for sin (s):"+(tEnd-tStart)/1000.0); tStart = System.currentTimeMillis(); for (int i = 0; i < n; i++) { t += g(v%(2*Math.PI)); v += 0.1; } tEnd = System.currentTimeMillis(); System.out.println("Time for exp (s):"+(tEnd-tStart)/1000.0); tStart = System.currentTimeMillis(); for (int i = 0; i < n; i++) { t += h(v%(2*Math.PI)); v += 0.1; } tEnd = System.currentTimeMillis(); System.out.println("Time for sqrt (s):"+(tEnd-tStart)/1000.0); // Print result to disallow certain optimizations System.out.println("Result:"+t); } public static double e(double v) { double result = Math.cos(v); return result; } public static double f(double v) { double result = Math.sin(v); return result; } public static double g(double v) { double result = Math.exp(v); return result; } public static double h(double v) { double result = Math.sqrt(v); return result; } } ---------- END SOURCE ---------- CUSTOMER WORKAROUND : Use 1.3.1 or code up approximations to the trig functions. Release Regression From : 1.3.1_06 The above release value was the last known release where this bug was known to work. Since then there has been a regression. (Review ID: 179610) ======================================================================
|