JDK-6433580 : performance regression due to poor block placement
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 6
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2006-06-02
  • Updated: 2010-04-02
  • Resolved: 2006-06-28
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6 b90Fixed
Related Reports
Relates :  
Description
As reported in a forum, the microbenchmark below slips markedly in performance from 5.0 to 6.0, using the server compiler.  

The slip most noticeable in x86 architectures, but can be observed to a lesser degree on sparc.

class eclipsetest {
  static final byte[] byteBuf = new byte[10000];
  static final char[] buf = new char[10000];

  public static void main( String[] args ) throws Exception {
    for ( int i = 0; i < 1000; i++ ) {
      redo_work(1000, 100, 100);
    }
    System.out.println("Warmup done.");

    for ( int x = 0; x < 4; x++ ) {
      long start = System.currentTimeMillis();

      redo_work(1000, 100, 100000);

      long end = System.currentTimeMillis();
      System.out.println( "total time: " + (end - start) );
    }
  }

  public static int redo_work(int byteIndex, int offset, int redo) {
    for ( int i = 0; i < redo; i++ ) {
      work(byteIndex, offset);
    }
    return 0;
  }

  public static int work(int byteIndex, int offset) {
    if ( (byteIndex - offset) < 0 )
      throw new RuntimeException();

    for ( ; byteIndex < byteBuf.length; byteIndex++ ) {
      if ( byteBuf[byteIndex] < 6 ) {
	if ( byteBuf[byteIndex] == 5 ) {
	  buf[byteIndex - offset] = '\n';
	}
      }
      buf[byteIndex - offset] = (char)byteBuf[byteIndex];
    }

    return 0;
  }
}

Comments
SUGGESTED FIX See PRT webrev: http://analemma.sfbay.sun.com/net/prt-archiver.sfbay/data/archived_workspaces/main/c2_baseline/2006/20060621111251.rasbold.c2_baseline/workspace/webrevs/webrev-2006.06.21/index.html
21-06-2006

EVALUATION In certain situations, RemoveEmpty() needs to choose one of two successors to be the fallthrough block after a conditional branch. Currently in 6.0, it uses the expected block frequency to favor one successor over the other. A more appropriate metric would be to use the branch probability of the conditional branch.
02-06-2006