JDK-8078093 : Severe compiler performance regression Java 7 to 8 for nested method invocations
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8u40,9
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: linux
  • CPU: x86_64
  • Submitted: 2015-03-06
  • Updated: 2022-01-31
  • Resolved: 2015-09-15
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 9
9 b83Fixed
Related Reports
Blocks :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
          FULL PRODUCT VERSION :
~/apps/jdk1.7.0_51/bin/java -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)

~/apps/jdk1.8.0_40/bin/java -version
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b25)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Linux se-185 3.2.0-4-amd64 #1 SMP Debian 3.2.65-1+deb7u2 x86_64 GNU/Linux

A DESCRIPTION OF THE PROBLEM :
See Test1.java as an example that shows the problem. It is very much stripped down from the original code, to showcase the problem.

The JDK 7 compiler compiles this very fast. JDK 8 compilers seem to perform exponentially more work, and compilation time blows up. This to me is a severe performance regression, making it practically impossible to perform runtime in-memory code compilation.

For 12 nested 'x' calls, as in Test1.java, this is the performance:

$ time ~/apps/jdk1.7.0_51/bin/javac Test1.java

real    0m0.380s
user    0m0.616s
sys     0m0.024s

$ time ~/apps/jdk1.8.0_40/bin/javac Test1.java

real    0m34.500s
user    0m39.698s
sys     0m0.172s

Changing the 12 nested 'x' calls to more nested 'x' calls leads me to conclude that an exponential amount of work is performed. Maybe multiple variants are tried for each call?

It should be noted that the Eclipse Luna JDT Java 8 compiler has no issues with this code, and compiles it very fast.

I looked, but could not find an existing bug report for this performance degradation. I did previously report a similar, but different performance issue, currently under review with Review ID: JI-9019327. That problem was related to nested calls with multiple overloads. This problem is for nested calls with only one overload, so the number of overloads is not relevant for this issue, therefore making this a different issue.



REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.util.LinkedHashMap;
import java.util.Map;

@SuppressWarnings("javadoc")
public class Test1 {
    public static void main(String[] args) {
        Map<Integer, String> a = x(x(x(x(x(x(x(x(x(x(x(x(
                                    new LinkedHashMap<Integer, String>(),
                                    1, "a"),  2, "b"),  3, "c"),  4, "d"),
                                    5, "e"),  6, "f"),  7, "g"),  8, "h"),
                                    9, "i"), 10, "j"), 11, "k"), 12, "l");
        System.out.println(a);
    }

    @SuppressWarnings("unused")
    public static <K, V> Map<K, V> x(Map<K, V> m, K k, V v) {
        // Replaced actual code by dummy implementation.
        return null;
    }
}

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


Comments
URL: http://hg.openjdk.java.net/jdk9/jdk9/langtools/rev/286fc9270404 User: lana Date: 2015-09-23 23:04:12 +0000
23-09-2015

URL: http://hg.openjdk.java.net/jdk9/dev/langtools/rev/286fc9270404 User: mcimadamore Date: 2015-09-15 12:44:15 +0000
15-09-2015

Solving this is the goal of the Tiered Attribution JEP: http://openjdk.java.net/jeps/215
20-04-2015

1) Run the attached test cases (Test1.java) 2) Tested this on Linux-X64 and could reproduce the issue. *************************************************************************************************************************************** Test.java (7u51): (7u80) (8u45) (9ea b60) real 3m13.858s real 3m10.197s real 4m47.370s real 4m7.173s user 0m1.139s user 0m1.186s user 1.15.624s user 1m20.539s sys 0m0.081s sys 0m0.082s sys 0m0.362s sys 0m0.462s *************************************************************************************************************************************** Result: There is a performance degradation from JDK 7 to 8, and 9 (7u51, 7u80, 8u40, 9 ea b57).
17-04-2015