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

Severe compiler performance regression Java 7 to 8 for nested method invocations

    Details

    • Subcomponent:
    • Resolved In Build:
      b83
    • CPU:
      x86_64
    • OS:
      linux
    • Verification:
      Verified

      Backports

        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 ----------

        1. Test1.java
          0.7 kB
          Pardeep Sharma

          Issue Links

            Activity

            Hide
            pardesha Pardeep Sharma added a comment -
            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).
            Show
            pardesha Pardeep Sharma added a comment - 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).
            Hide
            mcimadamore Maurizio Cimadamore added a comment -
            Solving this is the goal of the Tiered Attribution JEP:
            http://openjdk.java.net/jeps/215
            Show
            mcimadamore Maurizio Cimadamore added a comment - Solving this is the goal of the Tiered Attribution JEP: http://openjdk.java.net/jeps/215
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/dev/langtools/rev/286fc9270404
            User: mcimadamore
            Date: 2015-09-15 12:44:15 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/dev/langtools/rev/286fc9270404 User: mcimadamore Date: 2015-09-15 12:44:15 +0000
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/jdk9/langtools/rev/286fc9270404
            User: lana
            Date: 2015-09-23 23:04:12 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/langtools/rev/286fc9270404 User: lana Date: 2015-09-23 23:04:12 +0000

              People

              • Assignee:
                vromero Vicente Arturo Romero Zaldivar
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: