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

C1 does not inline sun.misc.Unsafe operations

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 1.4.0
    • 1.4.0
    • hotspot
    • beta
    • generic
    • generic

      Running the following program prints:

          % /usr/local/java/jdk1.4/linux-i386/bin/java -client InlineBug
          heap 1146
          direct 3366
          % /usr/local/java/jdk1.4/linux-i386/bin/java -server InlineBug
          heap 694
          direct 687
          %

      (This is on Linux, using build 50; I get similar numbers on Solaris.) These
      numbers, plus the profile shown below, suggest that C1 is not yet inlining the
      sun.misc.Unsafe intrinsics. Doing so is critical to the performance of the
      java.nio subsystem.

      ---- InlineBug.java

      import java.nio.*;


      public class InlineBug {

          static int time(String name, ByteBuffer bb) {
      int n = bb.capacity();
      bb.limit(bb.capacity());
      int a = 0;
      long start = System.currentTimeMillis();
      for (int i = 0; i < 4096; i++) {
      bb.rewind();
      for (int j = 0; j < n; j++)
      a += bb.get(j);
      }
      System.out.println(name + " " + (System.currentTimeMillis() - start));
      return a;
          }

          public static void main(String[] args) {
      int n = 4096;
      String key = "hd";
      if (args.length == 1)
      key = args[0];
      int a = 0;
      if (key.indexOf('h') >= 0)
      a += time("heap", ByteBuffer.allocate(n));
      if (key.indexOf('d') >= 0)
      a += time("direct", ByteBuffer.allocateDirect(n));
      System.exit(a);
          }

      }

      ---- -Xprof output

      % /usr/local/java/jdk1.4/linux-i386/bin/java -client -showversion -Xprof InlineBug d
      java version "1.4.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b50)
      Java HotSpot(TM) Client VM (build 1.4beta-B50, mixed mode)

      direct 5000

      Flat profile of 5.27 secs (87 total ticks): main

        Interpreted + native Method
        1.1% 0 + 1 java.lang.String.intern
        1.1% 1 + 0 java.lang.StringCoding$StringEncoder.<init>
        1.1% 0 + 1 java.nio.ByteBuffer.allocateDirect
        1.1% 0 + 1 java.lang.StringBuffer.expandCapacity
        4.6% 1 + 3 Total interpreted

           Compiled + native Method
       21.8% 19 + 0 java.nio.DirectByteBuffer.get
       12.6% 11 + 0 InlineBug.time
        4.6% 4 + 0 java.nio.Buffer.checkIndex
       39.1% 34 + 0 Total compiled

               Stub + native Method
       44.8% 15 + 24 sun.misc.Unsafe.getByte
       44.8% 15 + 24 Total stub

        Thread-local ticks:
       11.5% 10 Unknown: thread_state


      Global summary of 5.27 seconds:
      100.0% 87 Received ticks
       11.5% 10 Unknown code
      %

      -- mr@eng 2001/2/4

            mgharahgsunw Mohammad Gharahgouzloo (Inactive)
            mr Mark Reinhold
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: