Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8055984

type inference exponential compilation performance

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 9
    • None
    • tools
    • 8
    • generic
    • generic

      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.

            vromero Vicente Arturo Romero Zaldivar
            larbouzo Leonid Arbuzov
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: