JDK-6454577 : program needs the double time with jdk1.6 as with jdk1.5
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2006-07-31
  • Updated: 2011-02-16
  • Resolved: 2006-08-07
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.6.0-rc"
Java(TM) SE Runtime Environment (build 1.6.0-rc-b93)
Java HotSpot(TM) Client VM (build 1.6.0-rc-b93, mixed mode)


FULL OS VERSION :
Linux name.informatik.uni-stuttgart.de 2.6.16-1.2111_FC4 #1 Sat May 20 19:59:40 EDT 2006 i686 i686 i386 GNU/Linux


A DESCRIPTION OF THE PROBLEM :
The program below needs the following run times (with option -client):

With jdk1.5: 14 seconds
With jdk1.6: 26 seconds

When commenting-in one System.out.println the program needs the same time with jdk1.5 but 3 seconds more with jdk1.6.


THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: Did not try

THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: No

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
time jdk1.5/bin/java -client Test
time jre1.6.0/bin/java -client Test

Comment-in the line with System.out.println (delete the "//").

time jdk1.5/bin/java -client Test
time jre1.6.0/bin/java -client Test


EXPECTED VERSUS ACTUAL BEHAVIOR :
1. With jdk1.6 the program should not need almost the double time as with jdk1.5
2. When commenting-in one println the program should not need 3 seconds more.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.util.Random;
import java.util.BitSet;
import java.util.Arrays;
import java.util.HashSet;

public class Test {

    private static final int ITERATIONS = 10000;

    private static final int ARRAY_SIZE = 10000;

    private static final int MAX_VALUE = 50000;

    public static void main(String[] args) {
        Random  rand;
        HashSet numberSet;
        BitSet  bitSet;
        int[]   numbers;
        long    unused1;
        long    unused2;
        int     number;
        int     errorCounter;

        // Initialize.
        rand = new Random(1);
        errorCounter = 0;
        unused1 = 0;
        unused2 = 0;

        // Generate different numbers.
        numbers = new int[ARRAY_SIZE];
        numberSet = new HashSet();
        for (int n = 0; n < ARRAY_SIZE; n++) {
            do {
                number = rand.nextInt(MAX_VALUE);
            } while (numberSet.contains(new Integer(number)));

            numbers[n] = number;
            numberSet.add(new Integer(number));
        }
        Arrays.sort(numbers);

        // Call methods of BitSet.
        for (int i = 0; i < ITERATIONS; i++) {

            bitSet = new BitSet(MAX_VALUE);

            bitSet.set(numbers[0]);
            for (int n = 1; n < ARRAY_SIZE; n++) {
                bitSet.set(numbers[n]);

                if (!bitSet.get(numbers[n - 1])) {
                    errorCounter++;
                }

                if (bitSet.nextSetBit(numbers[n - 1] + 1) != numbers[n]) {
                    errorCounter++;
                }
            }
        }

//        System.out.println(unused1);
        System.out.println(unused2);
        System.out.println("errorCounter = " + errorCounter);
    }
}


---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Use option -server or use jdk1.5.