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

c2 has bad performance with static methods

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2
    • Resolution: Cannot Reproduce
    • Affects Version/s: 1.3.1
    • Fix Version/s: None
    • Component/s: hotspot
    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_7

      Description

      Below is a small test case in which c2 is not optimizing correctly; its performance is orders of magnitude worse than c1. The bug only manifests itself when static and local methods are involved; in the test program below, running with any argument calls static methods of another class which triggers the bug.

      The JVM in use is
      java version "1.3.1"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
      Java HotSpot(TM) Server VM (build 1.3.1-b24, mixed mode)

      Here's the output of a run where the code behaves normally (numbers are in ms):

      %java -server Test
      calls to static method took 44
      repeating test
      calls to static method took 29

      Inserting a call to a local method produces this. Notice that once the
      static method are called (in the second loop), the performance goes way
      down (even for later local calls).

      %java -server Test 1
      calls to local method took 73
      calls to static method took 4366
      repeating test
      calls to local method took 8015
      calls to static method took 4695

      Here's the same run with c1:

      %java Test 1
      calls to local method took 643
      calls to static method took 1265
      repeating test
      calls to local method took 697
      calls to static method took 1251

      This code is very similar to what the Oracle Thin JDBC drivers do, with the result that appservers (or anything else) that use those drivers with -server have poor performance. This hampers our internal scaling of ECperf and will have a significant impact on customers using the Oracle Thin JDBC drivers.

      Here's the sample code:

      class TestOther {

          public static void yyy() {
          }
      }

      public class Test {

          boolean xxx() {
              return true;
          }

          boolean x;

          public static void main(String[] args) {
              new Test().run(args);
          }

          public void run(String[] args) {
              long now, then;
              boolean doLocal =false;
              if (args.length > 0)
                  doLocal = true;

              if (doLocal) {
                  then = System.currentTimeMillis();
                  for (int i = 0; i < 10000000; i++) {
                      x = xxx();
                  }
                  now = System.currentTimeMillis();
                  System.out.println("calls to local method took " + (now - then));
              }
              then = System.currentTimeMillis();
              for (int i = 0; i < 10000000; i++) {
                  TestOther.yyy();
              }
              now = System.currentTimeMillis();
              System.out.println("calls to static method took " + (now - then));

              System.out.println("repeating test");

              if (doLocal) {
                  then = System.currentTimeMillis();
                  for (int i = 0; i < 10000000; i++) {
                      x = xxx();
                  }
                  now = System.currentTimeMillis();
                  System.out.println("calls to local method took " + (now - then));
              }

              then = System.currentTimeMillis();
              for (int i = 0; i < 10000000; i++) {
                  TestOther.yyy();
              }
              now = System.currentTimeMillis();
              System.out.println("calls to static method took " + (now - then));
          }
      }

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              cclicksunw Clifford Click (Inactive)
              Reporter:
              soaks Scott Oaks
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: