JDK-8055984 : type inference exponential compilation performance
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2014-08-25
  • Updated: 2019-06-10
  • Resolved: 2016-05-26
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
9Fixed
Related Reports
Blocks :  
Blocks :  
Relates :  
Relates :  
Relates :  
Description
20 lines source takes an HOUR to compile:

class C<U> {
    U fu;
    C() {}
    C(C<U> other) { this.fu = other.fu; }
    C(U fu)       { this.fu = fu; }

    static <U> C<U> m(C<U> src) { return new C<U>(src); }

    public static void main(String argv[]) {
        /* type inference is expected here: */       
        C<String> c2 = m(new C<>(m(new C<>() )) );
        C<String> c3 = m(new C<>(m(new C<>(m(new C<>() )) )) );
        C<String> c4 = m(new C<>(m(new C<>(m(new C<>(m(new C<>() )) )) )) ); // Javac(1.04), ECJ(.71s)
        C<String> c5 = m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>() )) )) )) )) ); // Javac(2.02s), ECJ(1.17s)
        C<String> c6 = m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>() )) )) )) )) )) ); // Javac(4.84s)  ECJ(1.67s)
        C<String> c7 = m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>() )) )) )) )) )) )) ); // Javac(14.99s)  ECJ(10.82s)
        C<String> c8 = m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>() )) )) )) )) )) )) )) ); // Javac(79.62s)  ECJ(134.64s)
        C<String> c9 = m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>() )) )) )) )) )) )) )) )) ); // Javac(437s) ECJ(1305s) 
        C<String> c10 = m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>()))))))))))))))))))); // 3600
    }
}

Each lines show how long it takes to compile it in seconds.
Time is about the same for original jdk8.0 and latest jdk8u20 and jdk9.


Comments
Fixed by JDK-8046685
26-05-2016

jdk9b84 (linix-x64) takes about 2 sec to pass each of the four tests (on scaaa744) - great results! % time sh $JCK/tests/lang/INFR/infr066/infr06603m022/infr06603m022.ksh -- passed 4.367u 1.087s 0:02.23 243.9% 0+0k 0+272io 0pf+0w % time sh $JCK/tests/lang/INFR/infr066/infr06603m131/infr06603m131.ksh Note: infr06603m131.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. -- passed 5.530u 1.038s 0:02.34 280.3% 0+0k 0+272io 0pf+0w % time sh $JCK/tests/lang/INFR/infr066/infr06603m232/infr06603m232.ksh -- passed 4.900u 1.149s 0:02.34 258.1% 0+0k 0+272io 0pf+0w % time sh $JCK/tests/lang/INFR/infr066/infr06603m03/infr06603m03.ksh -- passed 5.630u 1.125s 0:02.02 334.1% 0+0k 0+272io 0pf+0w
29-11-2015

You might want to keep an eye on when JDK-8046685 becomes available in the next promoted build - this should take care of your remaining issues.
13-11-2015

A significant improvement is observed with jdk9b84. Three JCK tests now pass with default time limit (10min): infr06603m022 1.4 sec infr06603m131 1 min 50 sec infr06603m232 2 min 34 sec infr06603m03 - 32 min 30 sec For comparison jdk9b80 took 1h25min to finish the first testcase infr06603m022. It's 3000x speedup.
05-10-2015

The issue is still reproduced with latest JDK9 promoted build b81. If the issue is fixed, please indicate build#. "Cannot reproduce" doesn't apply in such case.
15-09-2015

A test for this has been added as part of the changeset for JDK-8078093.
15-09-2015

Four JCK tests fail the precompilation step because it takes too much time to execute them: lang/INFR/infr066/infr06603m022/infr06603m022_rt.html lang/INFR/infr066/infr06603m03/infr06603m03_rt.html lang/INFR/infr066/infr06603m131/infr06603m131_rt.html lang/INFR/infr066/infr06603m232/infr06603m232_rt.html
15-09-2014

This may be considered as too much requiring JCK tests. Filed JCK-7303646. No reason to raise the priority just because of that.
15-09-2014