3 Replies Latest reply on Jul 24, 2008 8:50 AM by Adrian Brock

    VFS Performance

    Adrian Brock Master

      Besides the AOP usage, the other major thing I'm seeing
      using hprof for sampling is the VFS usage by the classloader.
      I'll show some typical stacktraces:

      Not much we can do about the biggest one,
      since this is the JDK parsing the bytecode.

      The only way to reduce this, is the reduce the number of classes loaded.

       java.lang.ClassLoader.defineClass1(ClassLoader.java:Unknown line)
       java.lang.ClassLoader.defineClass(ClassLoader.java:620)
       org.jboss.classloader.spi.base.BaseClassLoader.access$200(BaseClassLoader.java:62)
       org.jboss.classloader.spi.base.BaseClassLoader$2.run(BaseClassLoader.java:504)
       org.jboss.classloader.spi.base.BaseClassLoader$2.run(BaseClassLoader.java:464)
       java.security.AccessController.doPrivileged(AccessController.java:Unknown line)
       org.jboss.classloader.spi.base.BaseClassLoader.loadClassLocally(BaseClassLoader.java:462)
       org.jboss.classloader.spi.base.BaseClassLoader.loadClassLocally(BaseClassLoader.java:439)
       org.jboss.classloader.spi.base.BaseDelegateLoader.loadClass(BaseDelegateLoader.java:134)
       org.jboss.classloader.spi.filter.FilteredDelegateLoader.loadClass(FilteredDelegateLoader.java:131)
      


      Reading byte code from zip files
       java.util.zip.Inflater.inflateBytes(Inflater.java:Unknown line)
       java.util.zip.Inflater.inflate(Inflater.java:215)
       java.util.zip.InflaterInputStream.read(InflaterInputStream.java:128)
       java.io.FilterInputStream.read(FilterInputStream.java:90)
       org.jboss.virtual.plugins.context.zip.ZipEntryInputStream.read(ZipEntryInputStream.java:112)
       org.jboss.classloader.plugins.ClassLoaderUtils.loadByteCode(ClassLoaderUtils.java:150)
       org.jboss.classloader.spi.base.BaseClassLoader$2.run(BaseClassLoader.java:475)
       org.jboss.classloader.spi.base.BaseClassLoader$2.run(BaseClassLoader.java:464)
       java.security.AccessController.doPrivileged(AccessController.java:Unknown line)
       org.jboss.classloader.spi.base.BaseClassLoader.loadClassLocally(BaseClassLoader.java:462)
      


      This looks inefficient, it is listing a parent directory when we do getChild

       java.io.UnixFileSystem.checkAccess(UnixFileSystem.java:Unknown line)
       java.io.File.canRead(File.java:660)
       org.jboss.virtual.plugins.context.file.FileHandler.getChildren(FileHandler.java:161)
       org.jboss.virtual.plugins.context.file.FileSystemContext.createVirtualFileHandler(FileSystemContext.java:337)
       org.jboss.virtual.plugins.context.file.FileSystemContext.createVirtualFileHandler(FileSystemContext.java:256)
       org.jboss.virtual.plugins.context.file.FileHandler.createChildHandler(FileHandler.java:224)
       org.jboss.virtual.plugins.context.AbstractVirtualFileHandler.structuredFindChild(AbstractVirtualFileHandler.java:509)
       org.jboss.virtual.plugins.context.file.FileHandler.getChild(FileHandler.java:233)
       org.jboss.virtual.VirtualFile.getChild(VirtualFile.java:427)
       org.jboss.classloading.spi.vfs.policy.VFSClassLoaderPolicy.findVirtualFileInfo(VFSClassLoaderPolicy.java:488)
      


      Modified checking

       java.io.UnixFileSystem.getLastModifiedTime(UnixFileSystem.java:Unknown line)
       java.io.File.lastModified(File.java:795)
       org.jboss.virtual.plugins.context.zip.ZipFileWrapper.getLastModified(ZipFileWrapper.java:140)
       org.jboss.virtual.plugins.context.zip.ZipEntryContext.getLastModified(ZipEntryContext.java:682)
       org.jboss.virtual.plugins.context.zip.ZipEntryHandler.getLastModified(ZipEntryHandler.java:92)
       org.jboss.virtual.plugins.context.DelegatingHandler.getLastModified(DelegatingHandler.java:107)
       org.jboss.virtual.plugins.context.AbstractVirtualFileHandler.hasBeenModified(AbstractVirtualFileHandler.java:181)
       org.jboss.virtual.plugins.context.file.FileHandler.getChildren(FileHandler.java:183)
       org.jboss.virtual.plugins.context.file.FileSystemContext.createVirtualFileHandler(FileSystemContext.java:337)
       org.jboss.virtual.plugins.context.file.FileSystemContext.createVirtualFileHandler(FileSystemContext.java:256)
      


      I keep seeing this, not checked if it is a real inefficiency

       org.jboss.virtual.plugins.context.AbstractVirtualFileHandler.getLocalPathName(AbstractVirtualFileHandler.java:230)
       org.jboss.virtual.plugins.context.zip.ZipEntryContext.isLeaf(ZipEntryContext.java:751)
       org.jboss.virtual.plugins.context.zip.ZipEntryHandler.isLeaf(ZipEntryHandler.java:110)
       org.jboss.virtual.plugins.context.AbstractVirtualFileHandler.structuredFindChild(AbstractVirtualFileHandler.java:502)
       org.jboss.virtual.plugins.context.zip.ZipEntryHandler.getChild(ZipEntryHandler.java:139)
       org.jboss.virtual.plugins.context.DelegatingHandler.getChild(DelegatingHandler.java:93)
       org.jboss.virtual.VirtualFile.getChild(VirtualFile.java:427)
       org.jboss.classloading.spi.vfs.policy.VFSClassLoaderPolicy.findVirtualFileInfo(VFSClassLoaderPolicy.java:488)
       org.jboss.classloading.spi.vfs.policy.VFSClassLoaderPolicy.findChild(VFSClassLoaderPolicy.java:452)
       org.jboss.classloading.spi.vfs.policy.VFSClassLoaderPolicy.getResource(VFSClassLoaderPolicy.java:385)
      


      Similarly this

       java.util.concurrent.ConcurrentHashMap$Segment.get(ConcurrentHashMap.java:334)
       java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:731)
       org.jboss.virtual.plugins.context.zip.ZipEntryContext.getRoot(ZipEntryContext.java:606)
       org.jboss.virtual.plugins.context.AbstractVirtualFileHandler.getLocalPathName(AbstractVirtualFileHandler.java:230)
       org.jboss.virtual.plugins.context.zip.ZipEntryContext.isLeaf(ZipEntryContext.java:751)
       org.jboss.virtual.plugins.context.zip.ZipEntryHandler.isLeaf(ZipEntryHandler.java:110)
       org.jboss.virtual.plugins.context.AbstractVirtualFileHandler.structuredFindChild(AbstractVirtualFileHandler.java:502)
       org.jboss.virtual.plugins.context.zip.ZipEntryHandler.getChild(ZipEntryHandler.java:139)
       org.jboss.virtual.plugins.context.DelegatingHandler.getChild(DelegatingHandler.java:93)
       org.jboss.virtual.VirtualFile.getChild(VirtualFile.java:427)
      


      I'm still seeing the PathTokenizer showing up

       org.jboss.virtual.plugins.vfs.helpers.PathTokenizer.getTokens(PathTokenizer.java:97)
       org.jboss.virtual.plugins.context.AbstractVirtualFileHandler.structuredFindChild(AbstractVirtualFileHandler.java:475)
       org.jboss.virtual.plugins.context.zip.ZipEntryHandler.getChild(ZipEntryHandler.java:139)
       org.jboss.virtual.plugins.context.DelegatingHandler.getChild(DelegatingHandler.java:93)
       org.jboss.virtual.VirtualFile.getChild(VirtualFile.java:427)
       org.jboss.classloading.spi.vfs.policy.VFSClassLoaderPolicy.findVirtualFileInfo(VFSClassLoaderPolicy.java:488)
       org.jboss.classloading.spi.vfs.policy.VFSClassLoaderPolicy.findChild(VFSClassLoaderPolicy.java:452)
       org.jboss.classloading.spi.vfs.policy.VFSClassLoaderPolicy.getResource(VFSClassLoaderPolicy.java:385)
       org.jboss.classloader.spi.base.BaseClassLoader$3.run(BaseClassLoader.java:567)
       org.jboss.classloader.spi.base.BaseClassLoader$3.run(BaseClassLoader.java:564)
      


        • 1. Re: VFS Performance
          Adrian Brock Master

          NOTE: Obviously, these calls will take time since they're doing I/O.
          I'm seeing similar things in the JDK calls, e.g.

           java.util.zip.ZipFile.getEntry(ZipFile.java:Unknown line)
           java.util.zip.ZipFile.getEntry(ZipFile.java:252)
           java.util.jar.JarFile.getEntry(JarFile.java:204)
           java.util.jar.JarFile.getJarEntry(JarFile.java:187)
           sun.misc.URLClassPath$JarLoader.getResource(URLClassPath.java:674)
           sun.misc.URLClassPath.getResource(URLClassPath.java:161)
           java.net.URLClassLoader$1.run(URLClassLoader.java:192)
           java.security.AccessController.doPrivileged(AccessController.java:Unknown line)
           java.net.URLClassLoader.findClass(URLClassLoader.java:188)
           java.lang.ClassLoader.loadClass(ClassLoader.java:306)
          



          • 2. Re: VFS Performance
            Adrian Brock Master

             

            "adrian@jboss.org" wrote:

            Reading byte code from zip files
             java.util.zip.Inflater.inflateBytes(Inflater.java:Unknown line)
             java.util.zip.Inflater.inflate(Inflater.java:215)
             java.util.zip.InflaterInputStream.read(InflaterInputStream.java:128)
             java.io.FilterInputStream.read(FilterInputStream.java:90)
             org.jboss.virtual.plugins.context.zip.ZipEntryInputStream.read(ZipEntryInputStream.java:112)
             org.jboss.classloader.plugins.ClassLoaderUtils.loadByteCode(ClassLoaderUtils.java:150)
             org.jboss.classloader.spi.base.BaseClassLoader$2.run(BaseClassLoader.java:475)
             org.jboss.classloader.spi.base.BaseClassLoader$2.run(BaseClassLoader.java:464)
             java.security.AccessController.doPrivileged(AccessController.java:Unknown line)
             org.jboss.classloader.spi.base.BaseClassLoader.loadClassLocally(BaseClassLoader.java:462)
            



            This one might improve if we wrap the VFS stream in a BufferedInputStream
            in ClassLoaderUtils?


            • 3. Re: VFS Performance
              Adrian Brock Master

               

              "adrian@jboss.org" wrote:
              "adrian@jboss.org" wrote:

              Reading byte code from zip files
               java.util.zip.Inflater.inflateBytes(Inflater.java:Unknown line)
               java.util.zip.Inflater.inflate(Inflater.java:215)
               java.util.zip.InflaterInputStream.read(InflaterInputStream.java:128)
               java.io.FilterInputStream.read(FilterInputStream.java:90)
               org.jboss.virtual.plugins.context.zip.ZipEntryInputStream.read(ZipEntryInputStream.java:112)
               org.jboss.classloader.plugins.ClassLoaderUtils.loadByteCode(ClassLoaderUtils.java:150)
               org.jboss.classloader.spi.base.BaseClassLoader$2.run(BaseClassLoader.java:475)
               org.jboss.classloader.spi.base.BaseClassLoader$2.run(BaseClassLoader.java:464)
               java.security.AccessController.doPrivileged(AccessController.java:Unknown line)
               org.jboss.classloader.spi.base.BaseClassLoader.loadClassLocally(BaseClassLoader.java:462)
              



              This one might improve if we wrap the VFS stream in a BufferedInputStream
              in ClassLoaderUtils?


              Although ClassLoaderUtils is already using a 1K buffer, so its probably
              not relevant introducing more buffering.
              However BufferedInputStream uses an 8K buffer by default, so maybe
              we can increase the buffer size to see if it helps.