The Source for Java Technology Collaboration
User: Password:
Register | Login help    

Search

Online Books:
java.net on MarkMail:


JDK7 do escape analysis by default

Posted by forax on October 6, 2009 at 1:56 PM PDT

During the JVM Summit, I was doing some tests for my presentation with the latest jdk7 binaries when I've seen some *BIG* performance improvement between jdk7 b71 and jdk7 b72.
A quick look to the summary of changes, hum, Escape Analysis is now enabled by default.
On my tests, I got a 3x improvement, Wow !

With a quick micro-benchmark, it's even better, as always :)

  class DoubleSlot {
    final int value1;
    final int value2;
    
    public DoubleSlot(int value1, int value2) {
      this.value1 = value1;
      this.value2 = value2;
    }
  }
  
  static int slotValue(DoubleSlot slot) {
    return slot.value1 + slot.value2;
  }
  
  static int sum(int[] values) {
    int sum = 0;
    int length = values.length;
    for(int i=1; i<length; i++) {
      DoubleSlot slot = new DoubleSlot(values[i-1], values[i]);
      sum += slotValue(slot);
    }
    return sum;
  }

  static void test(int[] values) {
    long start = System.nanoTime();
    int value = sum(values);
    long end = System.nanoTime();
    System.out.println("time "+(end-start)+" "+value);
  }
  
  public static void main(String[] args) {
    int[] values = new int[1000000];
    for(int i=0; i

With Escape Analysis, the allocation of DoubleSlot is not done anymore.

  $ /usr/jdk/jdk1.7.0b71/bin/java -server EscapeAnalysisTest
  time 8889261
  $ /usr/jdk/jdk1.7.0b73/bin/java -server EscapeAnalysisTest
  time 1408140

I love this kind of optimisation, you don't change your program, just use a newer VM, and got a 3x improvement :)
cheers,
Rémi

Related Topics >> Blogs      Open JDK      Performance      Virtual Machine      
Comments
Comments are listed in date ascending order (oldest first)

Will also become available in JDK6

Hi, Escape analysis and compressed references have been enabled by default in HS17 (HotSpot version) and this will eventually be available in JDK6 too (JDK6u18 early access includes HS16, so probably sometime next year). Best, Ismael

... will eventually be available in JDK6 too

To my understanding, Escape analysis with respect to scalar replaceable object allocations from the heap is available since build 1.6.0_14 http://java.sun.com/javase/6/webnotes/6u14.html

Yes, but not by default.

Yes, but not by default.

Does/will EA get applied by

Does/will EA get applied by the C1 compiler? (I've just started using the C1-only 'embedded' SE Sun HotSpot JRE!) Rgds Damon

EA is not done by C1

Hi Damon,
Escape analysis is a C2 feature only. Will it be included in C1 ? I don't know.
Rémi

Great start, but

I hope http://bugs.sun.com/view_bug.do?bug_id=6853701 gets fixed soon. Then my benchmark will improve too ;-)