Name: rmT116609 Date: 01/31/2002
FULL PRODUCT VERSION :
java version "1.4.0-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-rc-b91)
Java HotSpot(TM) Client VM (build 1.4.0-rc-b91, mixed mode)
Operating System: Windows 2000
SYSTEM CONFIGURATION : 1.7Ghz Pentium 4, 1GB RAM
DESCRIPTION OF THE PROBLEM :
The division and modulo operations are significantly (about 10 times) slower under Hotspot than under the JIT included with the 1.1, 1.1.8 and 1.2releases.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the test with 50,000,000 iterations with Hotspot and with the JIT included in either JDK1.1 or JDK1.1.8. You can see that the problem is with modulo and division because if you replace the modulo operation to multiplication for example you will get results close to the earlier JITs. If you replace the modulo with division however, the 10 fold decrease in performance remains.
EXPECTED VERSUS ACTUAL BEHAVIOR :
I would expect Hotspot not to be any slower than the earlier JITs.
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
/**
* This tests basic operations (multiplication, subtraction, modulo).
*/
public
class Test1{
public static void main(String [] args){
if (args.length==0){
System.err.println("You must specify the amount of iterations to perform");
return;
}
int iterationsCount;
try{
iterationsCount = Integer.parseInt(args[0]);
} catch(NumberFormatException e){
System.err.println("Unparseable argument: "+args[0]+",must be an integer");
return;
}
System.out.println("JVM vendor:"+System.getProperty("java.vendor"));
System.out.println("JVM version:"+System.getProperty("java.version"));
System.out.println();
// Warm up loop
System.out.println("Warm up:");
for (int i=0;i<5;i++){
long startTime = System.currentTimeMillis();
int result = method(iterationsCount);
long endTime = System.currentTimeMillis();
System.out.println((i+1)+") Result: "+result+" Took: "+(endTime-startTime)+"ms.");
}
// The real thing
System.out.println();
System.out.println("The real thing:");
for (int i=0;i<5;i++){
long startTime =
System.currentTimeMillis();
int result = method(iterationsCount);
long endTime = System.currentTimeMillis();
System.out.println((i+1)+") Result: "+result+" Took:
"+(endTime-startTime)+"ms.");
}
}
public static int method(int iterationsCount){
int sum = 0;
for (int i=0;i<iterationsCount;i++){
sum += (i*5-1)%4;
}
return sum;
}
}
---------- END SOURCE ----------
Test Results:
JVM vendor: Sun Microsystems Inc.
JVM version: 1.1.8
Warm up:
1) Result: 74999996 Took: 131ms.
2) Result: 74999996 Took: 120ms.
3) Result: 74999996 Took: 120ms.
4) Result: 74999996 Took: 120ms.
5) Result: 74999996 Took: 120ms.
The real thing:
1) Result: 74999996 Took: 120ms.
2) Result: 74999996 Took: 121ms.
3) Result: 74999996 Took: 120ms.
4) Result: 74999996 Took: 120ms.
5) Result: 74999996 Took: 120ms.
---- Sun 1.2 ----
[c:\java\tests]C:\java\JDK1.2\bin\java Test1 50000000
JVM vendor: Sun Microsystems Inc.
JVM version: 1.2.2
Warm up:
1) Result: 74999996 Took: 120ms.
2) Result: 74999996 Took: 130ms.
3) Result: 74999996 Took: 120ms.
4) Result: 74999996 Took: 121ms.
5) Result: 74999996 Took: 130ms.
The real thing:
1) Result: 74999996 Took: 120ms.
2) Result: 74999996 Took: 130ms.
3) Result: 74999996 Took: 120ms.
4) Result: 74999996 Took: 121ms.
5) Result: 74999996 Took: 120ms.
---- Sun 1.3 (Hotspot) ----
[c:\java\tests]java Test1 50000000
JVM vendor: Sun Microsystems Inc.
JVM version: 1.3.1_02
Warm up:
1) Result: 74999996 Took: 1813ms.
2) Result: 74999996 Took: 1772ms.
3) Result: 74999996 Took: 1823ms.
4) Result: 74999996 Took: 1782ms.
5) Result: 74999996 Took: 1813ms.
The real thing:
1) Result: 74999996 Took: 1772ms.
2) Result: 74999996 Took: 1833ms.
3) Result: 74999996 Took: 1773ms.
4) Result: 74999996 Took: 1832ms.
5) Result: 74999996 Took: 1773ms.
---- Sun 1.4 (Hotspot) ----
[c:\java\tests]C:\Java\JDK1.4\bin\java Test1 50000000
JVM vendor: Sun Microsystems Inc.
JVM version: 1.4.0-beta3
Warm up:
1) Result: 74999996 Took: 1783ms.
2) Result: 74999996 Took: 1792ms.
3) Result: 74999996 Took: 1743ms.
4) Result: 74999996 Took: 1742ms.
5) Result: 74999996 Took: 1793ms.
The real thing:
1) Result: 74999996 Took: 1742ms.
2) Result: 74999996 Took: 1793ms.
3) Result: 74999996 Took: 1743ms.
4) Result: 74999996 Took: 1782ms.
5) Result: 74999996 Took: 1753ms.
I used the latest releases of all the JVMs. I am sure that if you run my test under the same environment I did you will get the same results as I have been able to reproduce them on all computers I have tested on.
Also note that this is not a Pentium 4 specific problem -- I have reproduced it under Pentium 2 as well, although under P4 the performance decrease is x15 while only x10 on my P2.
(Review ID: 138520)
======================================================================