FULL PRODUCT VERSION :
java version "1.6.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-beta2-b72)
Java HotSpot(TM) Client VM (build 1.6.0-beta2-b72, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Linux localhost.localdomain 2.6.11-1.1369_FC4 #1 Thu Jun 2 22:55:56 EDT 2005 i686 athlon i386 GNU/Linux
EXTRA RELEVANT SYSTEM CONFIGURATION :
Tested on:
AMD Duron 800
Amd Athlon X2 4400+
A DESCRIPTION OF THE PROBLEM :
When executing the sample code the code runs first quite fast till hotspot server completly has "optimized" all methods when suddenly performance falls down and stays there.
There are 3 tests, test 1 and 2 are slower after optimization, only test 3 runs faster after optimization using the server runtime (C2).
I marked this one as regression since the strange behaviour was introduced with java-1.4, java-1.3.1 worked quite well.
With the client jvm a small speedup can be measured during execution, how it should be.
Here are my benchmark results with the code above on a Duron800, a quite outdated CPU:
1.6.0-beta2-b72 / Java HotSpot(TM) Server VM
2.871 secs 2.827 secs 5.525 secs
2.742 secs 2.772 secs 5.473 secs
4.665 secs 4.336 secs 2.784 secs <<--- What happens here?
4.661 secs 4.334 secs 2.78 secs
1.4.2_06-b03 / Java HotSpot(TM) Server VM
3.104 secs 3.01 secs 4.953 secs
4.827 secs 4.2 secs 2.82 secs <<-- Here the same, but earlier
4.832 secs 4.207 secs 2.823 secs
4.832 secs 4.208 secs 2.829 secs
1.3.1_16-b06 / Java HotSpot(TM) Server VM
6.312 secs 6.292 secs 5.875 secs
4.729 secs 4.663 secs 4.676 secs -->> No bug, but slow. right behaviour, everything gets faster...
4.72 secs 4.686 secs 4.666 secs
This is the output of PrintCompilation, tests are labeld with (test):
1.6.0-beta2-b72 / Java HotSpot(TM) Server VM
1% ArrayDemo::test1 @ 46 (103 bytes)
3.077 secs(1) 2% ArrayDemo::test2 @ 46 (100 bytes)
3.033 secs(2) 3% ArrayDemo::test3 @ 46 (87 bytes)
5.65 secs(3)
1 ArrayDemo::test1 (103 bytes)
2.946 secs(1) 2 ArrayDemo::test2 (100 bytes)
2.975 secs(2) 3 ArrayDemo::test3 (87 bytes)
5.599 secs(3)
4.778 secs 4.425 secs 2.982 secs
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
run the sample code using the java server runtime.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
when hotspot has finished with compilation performance should be better instead of worse.
ACTUAL -
when hotspot has finished compilation the test1 and test2 run slower than before.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class ArrayDemo
{
private final int[] a = new int[20*1024];
private final int[] b = new int[a.length];
private final int LOOPS = 5000;
public ArrayDemo()
{
init = false;
for(int k = 0; k < 500; k++) {
test1(LOOPS);
test2(LOOPS);
test3(LOOPS);
System.out.println();
}
}
private long start;
private boolean init = true;
private void end()
{
if(init) return;
long dur = (System.currentTimeMillis() - start);
System.out.print((dur/1000d)+" secs ");
}
private void test1(final int loops)
{
start = System.currentTimeMillis();
for(int k = 0; k < loops; k++) {
int ia = 0;
int ib = 0;
while(true) {
int t = a.length - ia;
if(t == 0) break;
if(t > 1024) t = 1024;
do {
if(b[ib] == 0xfe)break;
a[ia++] = b[ib++];
} while(--t > 0);
}
}
end();
}
private void test2(final int loops)
{
start = System.currentTimeMillis();
for(int k = 0; k < loops; k++) {
int ia = 0;
int ib = 0;
while(true) {
int t = a.length - ia;
if(t == 0) break;
if(t > 1024) t = 1024;
do {
if(b[ib] == 0xfe)/*break*/;
a[ia++] = b[ib++];
} while(--t > 0);
}
}
end();
}
private void test3(final int loops)
{
start = System.currentTimeMillis();
for(int k = 0; k < loops; k++) {
int ia = 0;
int ib = 0;
while(true) {
int t = a.length - ia;
if(t == 0) break;
if(t > 1024) t = 1024;
do {
/* if(b[ib] == 0xfe)break;*/
a[ia++] = b[ib++];
} while(--t > 0);
}
}
end();
}
public static void main(String[] args)
{
System.out.println(System.getProperty("java.vm.version")+" / "+System.getProperty("java.vm.name"));
new ArrayDemo();
}
}
---------- END SOURCE ----------