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

Performance bottleneck in sun.misc.UrlClassPath.getLoader()

XMLWordPrintable

    • ladybird
    • generic, x86
    • generic, windows_98, windows_nt

        sPath.getLoader(URLClassPath.java:203)
                at sun.misc.URLClassPath.getResource(URLClassPath.java:131)
                at java.net.URLClassLoader.findResource(URLClassLoader.java:342)
                at java.lang.ClassLoader.getResource(ClassLoader.java:680)
                at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:838)
                at java.beans.Beans$1.run(Beans.java:162)
                at java.security.AccessController.doPrivileged(Native Method)
                at java.beans.Beans.instantiate(Beans.java:157)
                at java.beans.Beans.instantiate(Beans.java:55)
                at UrlClassPathPerformance.run(UrlClassPathPerformance.java:21)

        "Thread-0" prio=5 tid=0x820560 nid=0x1f6 waiting on monitor
        [0xe83f000..0xe83fdf0]
                at sun.misc.URLClassPath.getLoader(URLClassPath.java:203)
                at sun.misc.URLClassPath.getResource(URLClassPath.java:131)
                at java.net.URLClassLoader.findResource(URLClassLoader.java:342)
                at java.lang.ClassLoader.getResource(ClassLoader.java:680)
                at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:838)
                at java.beans.Beans$1.run(Beans.java:162)
                at java.security.AccessController.doPrivileged(Native Method)
                at java.beans.Beans.instantiate(Beans.java:157)
                at java.beans.Beans.instantiate(Beans.java:55)
                at UrlClassPathPerformance.run(UrlClassPathPerformance.java:21)

        "Signal Dispatcher" daemon prio=10 tid=0x815970 nid=0x16e waiting on monitor
        [0..0]

        "Finalizer" daemon prio=9 tid=0x814780 nid=0x174 waiting on monitor
        [0xe53f000..0xe53fdf0]
                at java.lang.Object.wait(Native Method)
                at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:112)
                at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:127)
                at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:174)

        "Reference Handler" daemon prio=10 tid=0x814330 nid=0x191 waiting on monitor
        [0xe43f000..0
                at java.lang.Object.wait(Native Method)
                at java.lang.Object.wait(Object.java:424)
                at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:114)

        "VM Thread" prio=5 tid=0x8138e0 nid=0x13c runnable

        "VM Periodic Task Thread" prio=10 tid=0x815d40 nid=0x172 waiting on monitor



        Conclusion
        -----------

        There is a very serious performance bottleneck in UrlClassPath. This
        is a critical bug for us because we would like to be able to control
        the security policies of the system.
        (Review ID: 102536)
        ======================================================================


        Name: skT45625 Date: 04/25/2000


        java version "1.2.2"
        HotSpot VM (1.0.1, mixed mode, build g)


        This is a performance problem which we have seen in live installations
        of our product(ATG Dynamo Application Server). We whittled this down
        to a very simple example.

        1. Create a simple program which instantiates beans from many threads

        The main class
        ---------------

        import java.io.*;
        import java.beans.Beans;

        /**
         * This class shows that the performance of sun.misc.UrlClassPath is
         * unacceptable.
         * <p>
         * Run the main method with a security policy specified where the security
         * policy grants all permissions. Then get a stack dump of the VM. You will
        find
         * that the threads are most commonly found to be waiting on a monitor
         * in the sun.misc.UrlClassPath.getLoader(int) method.
         *
         */
        public class UrlClassPathPerformance
         extends Thread
        {
          public void run()
          {
            while (true) {
              try{
        Object bean = Beans.instantiate(ClassLoader.getSystemClassLoader(),
        "MyBean");
        System.out.println("got bean: " + bean);
              }
              catch (IOException e) {
        System.out.println("failure to get bean: " + e);
              }
              catch (ClassNotFoundException ce) {
        System.out.println("class not found: " + ce);
              }
              
              try {
        Thread.sleep((long)(10 * Math.random()));
              }
              catch (InterruptedException e) { }
            }
          }

          public static void main(String[] pArgs)
          {
            System.setSecurityManager(new SecurityManager());
            System.out.println("classloader = " + ClassLoader.getSystemClassLoader());
            for (int i=0; i < 20; i++)
              new UrlClassPathPerformance().start();
          }
        }

        The Bean class
        --------------

        public class MyBean
        {
        }



        2. Run the program with a policy file which grants all permissions

        The policy file
        ----------------
        grant {
        permission java.security.AllPermission;
        };

        The commands used
        -----------------
        set CLASSPATH=.;%CLASSPATH%

        java -Djava.security.policy=java.policy UrlClassPathPerformance


        3. Notice that this program is very slow - take a stack dump

        The stack dump
        --------------
        "Thread-20" prio=5 tid=0x823100 nid=0x1a0 waiting on monitor [0..0x12fd90]

        "Thread-19" prio=5 tid=0x822e10 nid=0x19a waiting on monitor
        [0xfb3f000..0xfb3fdf0]
                at sun.misc.URLClassPath.getLoader(URLClassPath.java:203)
                at sun.misc.URLClassPath.getResource(URLClassPath.java:131)
                at java.net.URLClassLoader.findResource(URLClassLoader.java:342)
                at java.lang.ClassLoader.getResource(ClassLoader.java:680)
                at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:838)
                at java.beans.Beans$1.run(Beans.java:162)
                at java.security.AccessController.doPrivileged(Native Method)
                at java.beans.Beans.instantiate(Beans.java:157)
                at java.beans.Beans.instantiate(Beans.java:55)
                at UrlClassPathPerformance.run(UrlClassPathPerformance.java:21)

        "Thread-18" prio=5 tid=0x822c50 nid=0x11e waiting on monitor
        [0xfa3f000..0xfa3fdf0]
                at sun.misc.URLClassPath.getLoader(URLClassPath.java:203)
                at sun.misc.URLClassPath.getResource(URLClassPath.java:131)
                at java.net.URLClassLoader.findResource(URLClassLoader.java:342)
                at java.lang.ClassLoader.getResource(ClassLoader.java:680)
                at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:838)
                at java.beans.Beans$1.run(Beans.java:162)
                at java.security.AccessController.doPrivileged(Native Method)
                at java.beans.Beans.instantiate(Beans.java:157)
                at java.beans.Beans.instantiate(Beans.java:55)
                at UrlClassPathPerformance.run(UrlClassPathPerformance.java:21)

        "Thread-17" prio=5 tid=0x822a90 nid=0x1fa waiting on monitor
        [0xf93f000..0xf93fdf0]
                at sun.misc.URLClassPath.getLoader(URLClassPath.java:203)
                at sun.misc.URLClassPath.getResource(URLClassPath.java:131)
                at java.net.URLClassLoader.findResource(URLClassLoader.java:342)
                at java.lang.ClassLoader.getResource(ClassLoader.java:680)
                at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:838)
                at java.beans.Beans$1.run(Beans.java:162)
                at java.security.AccessController.doPrivileged(Native Method)
                at java.beans.Beans.instantiate(Beans.java:157)
                at java.beans.Beans.instantiate(Beans.java:55)
                at UrlClassPathPerformance.run(UrlClassPathPerformance.java:21)

        "Thread-16" prio=5 tid=0x8228d0 nid=0x217 waiting on monitor
        [0xf83f000..0xf83fdf0]
                at java.lang.Thread.sleep(Native Method)
                at UrlClassPathPerformance.run(UrlClassPathPerformance.java:33)

        "Thread-15" prio=5 tid=0x822710 nid=0x196 waiting on monitor
        [0xf73f000..0xf73fdf0]
                at sun.misc.URLClassPath.getLoader(URLClassPath.java:203)
                at sun.misc.URLClassPath.getResource(URLClassPath.java:131)
                at java.net.URLClassLoader.findResource(URLClassLoader.java:342)
                at java.lang.ClassLoader.getResource(ClassLoader.java:680)
                at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:838)
                at java.beans.Beans$1.run(Beans.java:162)
                at java.security.AccessController.doPrivileged(Native Method)
                at java.beans.Beans.instantiate(Beans.java:157)
                at java.beans.Beans.instantiate(Beans.java:55)
                at UrlClassPathPerformance.run(UrlClassPathPerformance.java:21)

        "Thread-14" prio=5 tid=0x822550 nid=0x1cc waiting on monitor
        [0xf63f000..0xf63fdf0]
                at sun.misc.URLClassPath.getLoader(URLClassPath.java:203)
                at sun.misc.URLClassPath.getResource(URLClassPath.java:131)
                at java.net.URLClassLoader.findResource(URLClassLoader.java:342)
                at java.lang.ClassLoader.getResource(ClassLoader.java:680)
                at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:838)
                at java.beans.Beans$1.run(Beans.java:162)
                at java.security.AccessController.doPrivileged(Native Method)
                at java.beans.Beans.instantiate(Beans.java:157)
                at java.beans.Beans.instantiate(Beans.java:55)
                at UrlClassPathPerformance.run(UrlClassPathPerformance.java:21)

        "Thread-13" prio=5 tid=0x822390 nid=0x78 waiting on monitor
        [0xf53f000..0xf53fdf0]
                at sun.misc.URLClassPath.getLoader(URLClassPath.java:203)
                at sun.misc.URLClassPath.getResource(URLClassPath.java:131)
                at java.net.URLClassLoader.findResource(URLClassLoader.java:342)
                at java.lang.ClassLoader.getResource(ClassLoader.java:680)
                at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:838)
                at java.beans.Beans$1.run(Beans.java:162)
                at java.security.AccessController.doPrivileged(Native Method)
                at java.beans.Beans.instantiate(Beans.java:157)
                at java.beans.Beans.instantiate(Beans.java:55)
                at UrlClassPathPerformance.run(UrlClassPathPerformance.java:21)

        "Thread-12" prio=5 tid=0x8221d0 nid=0x128 waiting on monitor
        [0xf43f000..0xf43fdf0]
                at sun.misc.URLClassPath.getLoader(URLClassPath.java:203)
                at sun.misc.URLClassPath.getResource(URLClassPath.java:131)
                at java.net.URLClassLoader.findResource(URLClassLoader.java:342)
                at java.lang.ClassLoader.getResource(ClassLoader.java:680)
                at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:838)
                at java.beans.Beans$1.run(Beans.java:162)
                at java.security.AccessController.doPrivileged(Native Method)
                at java.beans.Beans.instantiate(Beans.java:157)
                at java.beans.Beans.instantiate(Beans.java:55)
                at UrlClassPathPerformance.run(UrlClassPathPerformance.java:21)

        "Thread-11" prio=5 tid=0x821f00 nid=0x185 waiting on monitor
        [0xf33f000..0xf33fdf0]
                at sun.misc.URLClassPath.getLoader(URLClassPath.java:203)
                at sun.misc.URLClassPath.getResource(URLClassPath.java:131)
                at java.net.URLClassLoader.findResource(URLClassLoader.java:342)
                at java.lang.ClassLoader.getResource(ClassLoader.java:680)
                at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:838)
                at java.beans.Beans$1.run(Beans.java:162)
                at java.security.AccessController.doPrivileged(Native Method)
                at java.beans.Beans.instantiate(Beans.java:157)
                at java.beans.Beans.instantiate(Beans.java:55)
                at UrlClassPathPerformance.run(UrlClassPathPerformance.java:21)

        "Thread-10" prio=5 tid=0x821d40 nid=0x127 waiting on monitor
        [0xf23f000..0xf23fdf0]
                at sun.misc.URLClassPath.getLoader(URLClassPath.java:203)
                at sun.misc.URLClassPath.getResource(URLClassPath.java:131)
                at java.net.URLClassLoader.findResource(URLClassLoader.java:342)
                at java.lang.ClassLoader.getResource(ClassLoader.java:680)
                at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:838)
                at java.beans.Beans$1.run(Beans.java:162)
                at java.security.AccessController.doPrivileged(Native Method)
                at java.beans.Beans.instantiate(Beans.java:157)
                at java.beans.Beans.instantiate(Beans.java:55)
                at UrlClassPathPerformance.run(UrlClassPathPerformance.java:21)

        "Thread-9" prio=5 tid=0x821b80 nid=0x17c runnable [0xf13f000..0xf13fdf0]
                at sun.misc.URLClassPath.getLoader(URLClassPath.java:203)
                at sun.misc.URLClassPath.getResource(URLClassPath.java:131)
                at java.net.URLClassLoader.findResource(URLClassLoader.java:342)
                at java.lang.ClassLoader.getResource(ClassLoader.java:680)
                at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:838)
                at java.beans.Beans$1.run(Beans.java:162)
                at java.security.AccessController.doPrivileged(Native Method)
                at java.beans.Beans.instantiate(Beans.java:157)
                at java.beans.Beans.instantiate(Beans.java:55)
                at UrlClassPathPerformance.run(UrlClassPathPerformance.java:21)

        "Thread-8" prio=5 tid=0x8219c0 nid=0x198 waiting on monitor
        [0xf03f000..0xf03fdf0]
                at sun.misc.URLClassPath.getLoader(URLClassPath.java:203)
                at sun.misc.URLClassPath.getResource(URLClassPath.java:131)
                at java.net.URLClassLoader.findResource(URLClassLoader.java:342)
                at java.lang.ClassLoader.getResource(ClassLoader.java:680)
                at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:838)
                at java.beans.Beans$1.run(Beans.java:162)
                at java.security.AccessController.doPrivileged(Native Method)
                at java.beans.Beans.instantiate(Beans.java:157)
                at java.beans.Beans.instantiate(Beans.java:55)
                at UrlClassPathPerformance.run(UrlClassPathPerformance.java:21)

        "Thread-7" prio=5 tid=0x821800 nid=0x11c runnable [0xef3f000..0xef3fdf0]
                at sun.misc.URLClassPath.getLoader(URLClassPath.java:203)
                at sun.misc.URLClassPath.getResource(URLClassPath.java:131)
                at java.net.URLClassLoader.findResource(URLClassLoader.java:342)
                at java.lang.ClassLoader.getResource(ClassLoader.java:680)
                at java.lang.ClassLoader.getResource(ClassLoader.java:675)
                at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:838)
                at java.beans.Beans$1.run(Beans.java:162)
                at java.security.AccessController.doPrivileged(Native Method)
                at java.beans.Beans.instantiate(Beans.java:157)
                at java.beans.Beans.instantiate(Beans.java:55)
                at UrlClassPathPerformance.run(UrlClassPathPerformance.java:21)

        "Thread-6" prio=5 tid=0x821640 nid=0x21c waiting on monitor
        [0xee3f000..0xee3fdf0]
                at sun.misc.URLClassPath.getLoader(URLClassPath.java:203)
                at sun.misc.URLClassPath.getResource(URLClassPath.java:131)
                at java.net.URLClassLoader.findResource(URLClassLoader.java:342)
                at java.lang.ClassLoader.getResource(ClassLoader.java:680)
                at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:838)
                at java.beans.Beans$1.run(Beans.java:162)
                at java.security.AccessController.doPrivileged(Native Method)
                at java.beans.Beans.instantiate(Beans.java:157)
                at java.beans.Beans.instantiate(Beans.java:55)
                at UrlClassPathPerformance.run(UrlClassPathPerformance.java:21)

        "Thread-5" prio=5 tid=0x821480 nid=0x13d runnable [0xed3f000..0xed3fdf0]
                at sun.misc.URLClassPath.getLoader(URLClassPath.java:203)
                at sun.misc.URLClassPath.getResource(URLClassPath.java:131)
                at java.net.URLClassLoader.findResource(URLClassLoader.java:342)
                at java.lang.ClassLoader.getResource(ClassLoader.java:680)
                at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:838)
                at java.beans.Beans$1.run(Beans.java:162)
                at java.security.AccessController.doPrivileged(Native Method)
                at java.beans.Beans.instantiate(Beans.java:157)
                at java.beans.Beans.instantiate(Beans.java:55)
                at UrlClassPathPerformance.run(UrlClassPathPerformance.java:21)

        "Thread-4" prio=5 tid=0x8212c0 nid=0x43 waiting on monitor
        [0xec3f000..0xec3fdf0]
                at sun.misc.URLClassPath.getLoader(URLClassPath.java:203)
                at sun.misc.URLClassPath.getResource(URLClassPath.java:131)
                at java.net.URLClassLoader.findResource(URLClassLoader.java:342)
                at java.lang.ClassLoader.getResource(ClassLoader.java:680)
                at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:838)
                at java.beans.Beans$1.run(Beans.java:162)
                at java.security.AccessController.doPrivileged(Native Method)
                at java.beans.Beans.instantiate(Beans.java:157)
                at java.beans.Beans.instantiate(Beans.java:55)
                at UrlClassPathPerformance.run(UrlClassPathPerformance.java:21)

        "Thread-3" prio=5 tid=0x821100 nid=0x141 waiting on monitor
        [0xeb3f000..0xeb3fdf0]
                at sun.misc.URLClassPath.getLoader(URLClassPath.java:203)
                at sun.misc.URLClassPath.getResource(URLClassPath.java:131)
                at java.net.URLClassLoader.findResource(URLClassLoader.java:342)
                at java.lang.ClassLoader.getResource(ClassLoader.java:680)
                at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:838)
                at java.beans.Beans$1.run(Beans.java:162)
                at java.security.AccessController.doPrivileged(Native Method)
                at java.beans.Beans.instantiate(Beans.java:157)
                at java.beans.Beans.instantiate(Beans.java:55)
                at UrlClassPathPerformance.run(UrlClassPathPerformance.java:21)

        "Thread-2" prio=5 tid=0x820920 nid=0x1dc waiting on monitor
        [0xea3f000..0xea3fdf0]
                at sun.misc.URLClassPath.getLoader(URLClassPath.java:203)
                at sun.misc.URLClassPath.getResource(URLClassPath.java:131)
                at java.net.URLClassLoader.findResource(URLClassLoader.java:342)
                at java.lang.ClassLoader.getResource(ClassLoader.java:680)
                at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:838)
                at java.beans.Beans$1.run(Beans.java:162)
                at java.security.AccessController.doPrivileged(Native Method)
                at java.beans.Beans.instantiate(Beans.java:157)
                at java.beans.Beans.instantiate(Beans.java:55)
                at UrlClassPathPerformance.run(UrlClassPathPerformance.java:21)

        "Thread-1" prio=5 tid=0x820760 nid=0x1c8 waiting on monitor
        [0xe93f000..0xe93fdf0]
                at sun.misc.URLClas

              alanb Alan Bateman
              skondamasunw Suresh Kondamareddy (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: