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

Significant performance degradation after step over during debugging

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • None
    • core-svc
    • None

      A significant performance degradation was observed in Java 11/ Java 17 if step over is used while debugging and a similar behaviour is observed in Java 21 and the dev tree. The effect of the step over appears to be to force all subsequent debugging to run in interpreter-only mode. The difference between continuing a program without performing the step over and continuing after performing the step over can be an increase in execution time of many orders of magnitude.

      The problem manifests with Eclipse and Java 11 / Java 17 / Java 21 / dev head, but its reproducible also with jdb and Java 11 / Java 17 / Java 21 / dev head.

      Version-Release number of selected component (if applicable):

      OpenJDK 11.0.10
      OpenJDK 17.0.8
      OpenJDK 21.0.1
      OpenJKD Head

      How reproducible:

      The problem can be reproduced using a simple test program run under jdb. Debug the following snippet:

      public class StepOver {
        public static void main(String[] args) throws Exception {
          System.out.println(); // set a breakpoint here, and step over
          System.out.println(); // press Resume when suspended here
          double[] ySeries = new double[100_000];
          for (int i = 0; i < ySeries.length; i++)
            { ySeries[i] = Math.sin(i / 20) * Math.pow(10, -21); }

          long startTime = System.currentTimeMillis();
          for (int i = 0; i < ySeries.length; i++)
            { String.valueOf(ySeries[i]); }

          System.out.println("elapsed time: " + (System.currentTimeMillis() - startTime));
        }
      }

      Steps to Reproduce:
      1. Compile
      /usr/lib/jvm/java-21/bin/javac StepOver.java

      2. Debug the following snippet with jdb
      /usr/lib/jvm/java-21/bin/jdb StepOver

      3. Set a breakpoint at StepOver:3
      stop at StepOver:3

      4. Run the snippet
      run StepOver

      5. Step over the breakpoint:
      step over

      6. Continue execution:
      cont

      Actual results:

      The snippet takes 1.5 seconds to finish on Java 21 / dev head and around 9 seconds to finish on Java 17.

      Expected results:

      The snippet should finish in roughly the same time as it takes if the step over is omitted i.e. ~50 msecs on Java21 / dev head and ~150 msecs on Java 17.

      Additional info:

      The bug was introduced into jdk11/jdk17 with this commit: https://github.com/openjdk/jdk11u/commit/dbb9eb5b9c3ddcbcfaae8ac4ca21760c9c99a15c

      which fixed JDK-8187289.

      Specifically, commenting out the following line in the above patch (at line 523 in the patched jdk11 file) "fixes" the problem

            // has_frame_pops |= ets->has_frame_pops();

      The effect of the patch is that the interpreter only mode is entered after step over and is never left. Whereas before this patch (or after the patch if the |= operation is commented out), the interpreter only mode is left after the step over handling is done.

            Unassigned Unassigned
            adinn Andrew Dinn
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: