Improve and speed up plugin resource loading

XMLWordPrintable

    • Type: Suggestion
    • Resolution: Fixed
    • 2.5.6, 2.6.0
    • Component/s: None
    • None

      A response template goes through several stages of decoration, using the #applyDecorator macro specifying a template name. This goes through the sitemesh decorator logic and eventually ends up in the class loading implementation to find the decoration template. Confluence implements the plugin classloaders to scan through the plugins to find the actual resource that satisfies this name.

      This involves scanning each plugin jar for the required template resource. If there are a lot of plugins, this can take quite some time.

      The three main problems with this implementation are:

      1. During the scan, the individual plugin class loaders (JarClassLoader) is synchronized, meaning all other plugin resource or class loading is executed sequentially
      2. The result is not cached, or recorded in any way, meaning this will happen multiple times on every request
      3. The surrounding DynamicPluginResourceLoader that velocity uses to bridge to the DefaultPluginManager, is synchronized as well, meaning all plugin resource loading that originates from velocity is executed sequentially

      A typical stack trace showing this behavior:

      "http-127.0.0.1-48080-Processor3" daemon prio=5 tid=0x011248e8 nid=0x23 runnable [0xb7e7c000..0xb7e7fc28]
        - locked <0xb91ac448> (a java.util.zip.Inflater)
        ...
        at java.util.jar.JarInputStream.getNextEntry(JarInputStream.java:114)
        at com.atlassian.plugin.loaders.classloading.JarClassLoader$InnerJar.scanForPrefixes(JarClassLoader.java:53)
        ...
        at com.atlassian.plugin.loaders.classloading.JarClassLoader.getFile(JarClassLoader.java:190)
        - locked <0xc18644e0> (a com.atlassian.plugin.loaders.classloading.JarClassLoader)
        at com.atlassian.plugin.loaders.classloading.PluginsClassLoader.findResource(PluginsClassLoader.java:79)
        at com.atlassian.plugin.loaders.classloading.PluginsClassLoader.getResource(PluginsClassLoader.java:149)
        at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:995)
        at com.atlassian.plugin.impl.DynamicPlugin.getResourceAsStream(DynamicPlugin.java:33)
        at com.atlassian.plugin.DefaultPluginManager.getDynamicResourceAsStream(DefaultPluginManager.java:676)
        ...  
        at com.atlassian.confluence.setup.velocity.DynamicPluginResourceLoader.getResourceStream(DynamicPluginResourceLoader.java:23)
        - locked <0xbd47f420> (a com.atlassian.confluence.setup.velocity.DynamicPluginResourceLoader)
        at org.apache.velocity.Template.process(Template.java:136)
        at org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:466)
        ...  
        at com.atlassian.confluence.setup.sitemesh.ConfluenceSpaceDecoratorMapper.getDecorator(ConfluenceSpaceDecoratorMapper.java:57)
        ...
      

        1. DynamicPluginResourceLoader.class
          2 kB
        2. DynamicPluginResourceLoader.java
          1 kB
        3. stacks.txt
          40 kB

            Assignee:
            Unassigned
            Reporter:
            m@ (Inactive)
            Votes:
            3 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: