Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-21579

Very slow resource loading from UberClassLoader

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Creating a template using a Groovy transformer (in this case actually a folder template inside a parent folder, with two job templates created inside it) was remarkably slow:

      "Handling POST /job/.../createItem : http-8089-6" Id=5527 Group=main RUNNABLE
      	at java.util.zip.ZipFile.getEntry(Native Method)
      	at java.util.zip.ZipFile.getEntry(Unknown Source)
      	-  locked java.util.jar.JarFile@1951d8d7
      	at java.util.jar.JarFile.getEntry(Unknown Source)
      	at java.util.jar.JarFile.getJarEntry(Unknown Source)
      	at org.apache.catalina.loader.WebappClassLoader.findResources(WebappClassLoader.java:1315)
      	-  locked [Ljava.util.jar.JarFile;@7b9a0ac
      	at java.lang.ClassLoader.getResources(Unknown Source)
      	at java.lang.ClassLoader.getResources(Unknown Source)
      	at java.lang.ClassLoader.getResources(Unknown Source)
      	at org.apache.tools.ant.AntClassLoader.findResources(AntClassLoader.java:957)
      	at org.apache.tools.ant.AntClassLoader.findResources(AntClassLoader.java:935)
      	at sun.reflect.GeneratedMethodAccessor24.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      	at java.lang.reflect.Method.invoke(Unknown Source)
      	at jenkins.ClassLoaderReflectionToolkit.findResources(ClassLoaderReflectionToolkit.java:60)
      	at hudson.ClassicPluginStrategy$DependencyClassLoader.findResources(ClassicPluginStrategy.java:594)
      	at java.lang.ClassLoader.getResources(Unknown Source)
      	at org.apache.tools.ant.AntClassLoader.findResources(AntClassLoader.java:957)
      	at org.apache.tools.ant.AntClassLoader.findResources(AntClassLoader.java:935)
      	at sun.reflect.GeneratedMethodAccessor24.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      	at java.lang.reflect.Method.invoke(Unknown Source)
      	at jenkins.ClassLoaderReflectionToolkit.findResources(ClassLoaderReflectionToolkit.java:60)
      	at hudson.ClassicPluginStrategy$DependencyClassLoader.findResources(ClassicPluginStrategy.java:594)
      	at java.lang.ClassLoader.getResources(Unknown Source)
      	at org.apache.tools.ant.AntClassLoader.findResources(AntClassLoader.java:957)
      	at org.apache.tools.ant.AntClassLoader.findResources(AntClassLoader.java:935)
      	at sun.reflect.GeneratedMethodAccessor24.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      	at java.lang.reflect.Method.invoke(Unknown Source)
      	at jenkins.ClassLoaderReflectionToolkit.findResources(ClassLoaderReflectionToolkit.java:60)
      	at hudson.ClassicPluginStrategy$DependencyClassLoader.findResources(ClassicPluginStrategy.java:594)
      	at java.lang.ClassLoader.getResources(Unknown Source)
      	at org.apache.tools.ant.AntClassLoader.findResources(AntClassLoader.java:957)
      	at org.apache.tools.ant.AntClassLoader.findResources(AntClassLoader.java:935)
      	at sun.reflect.GeneratedMethodAccessor24.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      	at java.lang.reflect.Method.invoke(Unknown Source)
      	at jenkins.ClassLoaderReflectionToolkit.findResources(ClassLoaderReflectionToolkit.java:60)
      	at hudson.ClassicPluginStrategy$DependencyClassLoader.findResources(ClassicPluginStrategy.java:594)
      	at java.lang.ClassLoader.getResources(Unknown Source)
      	at org.apache.tools.ant.AntClassLoader.findResources(AntClassLoader.java:957)
      	at org.apache.tools.ant.AntClassLoader.findResources(AntClassLoader.java:935)
      	at sun.reflect.GeneratedMethodAccessor24.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      	at java.lang.reflect.Method.invoke(Unknown Source)
      	at jenkins.ClassLoaderReflectionToolkit.findResources(ClassLoaderReflectionToolkit.java:60)
      	at hudson.ClassicPluginStrategy$DependencyClassLoader.findResources(ClassicPluginStrategy.java:594)
      	at java.lang.ClassLoader.getResources(Unknown Source)
      	at org.apache.tools.ant.AntClassLoader.findResources(AntClassLoader.java:957)
      	at hudson.PluginFirstClassLoader.findResources(PluginFirstClassLoader.java:79)
      	at org.apache.tools.ant.AntClassLoader.findResources(AntClassLoader.java:935)
      	at hudson.PluginFirstClassLoader.findResources(PluginFirstClassLoader.java:87)
      	at sun.reflect.GeneratedMethodAccessor24.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      	at java.lang.reflect.Method.invoke(Unknown Source)
      	at jenkins.ClassLoaderReflectionToolkit.findResources(ClassLoaderReflectionToolkit.java:60)
      	at hudson.PluginManager$UberClassLoader.findResources(PluginManager.java:1016)
      	at java.lang.ClassLoader.getResources(Unknown Source)
      	at java.lang.ClassLoader.getResources(Unknown Source)
      	at org.codehaus.groovy.transform.ASTTransformationVisitor.doAddGlobalTransforms(ASTTransformationVisitor.java:194)
      	at org.codehaus.groovy.transform.ASTTransformationVisitor.addGlobalTransforms(ASTTransformationVisitor.java:187)
      	at org.codehaus.groovy.transform.ASTTransformationVisitor.addPhaseOperations(ASTTransformationVisitor.java:150)
      	at org.codehaus.groovy.control.CompilationUnit.<init>(CompilationUnit.java:186)
      	at org.codehaus.groovy.control.CompilationUnit.<init>(CompilationUnit.java:118)
      	at groovy.lang.GroovyClassLoader.createCompilationUnit(GroovyClassLoader.java:476)
      	at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:290)
      	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:281)
      	-  locked java.util.HashMap@70971d3
      	at groovy.lang.GroovyShell.parseClass(GroovyShell.java:731)
      	at groovy.lang.GroovyShell.parse(GroovyShell.java:743)
      	at groovy.lang.GroovyShell.parse(GroovyShell.java:770)
      	at com.cloudbees.hudson.plugins.modeling.impl.SimpleTemplateEngine.parseScript(SimpleTemplateEngine.java:134)
      	at com.cloudbees.hudson.plugins.modeling.impl.SimpleTemplateEngine.createTemplate(SimpleTemplateEngine.java:122)
      	at com.cloudbees.hudson.plugins.modeling.impl.SimpleTemplateEngine.createTemplate(SimpleTemplateEngine.java:116)
      	at groovy.text.TemplateEngine.createTemplate(TemplateEngine.java:38)
      	at com.cloudbees.hudson.plugins.modeling.transformer.GroovyTemplateModelTransformer.compile(GroovyTemplateModelTransformer.java:83)
      	at com.cloudbees.hudson.plugins.modeling.transformer.GroovyTemplateModelTransformer.compileTemplate(GroovyTemplateModelTransformer.java:75)
      	at com.cloudbees.hudson.plugins.modeling.transformer.GroovyTemplateModelTransformer.transform(GroovyTemplateModelTransformer.java:97)
      	at com.cloudbees.hudson.plugins.modeling.impl.entity.EntityInstance.produce(EntityInstance.java:149)
      	at com.cloudbees.hudson.plugins.modeling.impl.entity.EntityInstance.produce(EntityInstance.java:121)
      	at com.cloudbees.hudson.plugins.modeling.impl.jobTemplate.JobTemplateDescriptor.newInstance(JobTemplateDescriptor.java:47)
      	at hudson.model.ItemGroupMixIn.createProject(ItemGroupMixIn.java:259)
      	-  locked com.cloudbees.hudson.plugins.folder.Folder$MixInImpl@37ee014f
      	at com.cloudbees.hudson.plugins.folder.Folder.createProject(Folder.java:666)
      	at com.cloudbees.hudson.plugins.folder.Folder.createProject(Folder.java:662)
      	at com.cloudbees.hudson.plugins.modeling.impl.folder.activities.CreateItemActivity.perform(CreateItemActivity.java:42)
      	at com.cloudbees.hudson.plugins.modeling.impl.folder.FolderTemplateDescriptor.newInstance(FolderTemplateDescriptor.java:54)
      	at com.cloudbees.hudson.plugins.modeling.impl.folder.FolderTemplateDescriptor.newInstance(FolderTemplateDescriptor.java:22)
      	at hudson.model.ItemGroupMixIn.createProject(ItemGroupMixIn.java:259)
      	-  locked com.cloudbees.hudson.plugins.folder.Folder$MixInImpl@22c07d34
      	at hudson.model.ItemGroupMixIn.createTopLevelItem(ItemGroupMixIn.java:175)
      	-  locked com.cloudbees.hudson.plugins.folder.Folder$MixInImpl@22c07d34
      	at com.cloudbees.hudson.plugins.folder.Folder.doCreateItem(Folder.java:597)
      	at com.cloudbees.hudson.plugins.folder.Folder.doCreateItem(Folder.java:122)
      

      UberClassLoader.findResources calls findResources on each plugin, which would be fine, except apparently some of these calls involve deep recursions into plugin dependencies, and probably a lot of overlapping calls to findResources in the root web application. I am guessing this all turns out to be vastly slower than just checking each plugin ZIP file, plus the parent, once.

        Attachments

          Issue Links

            Activity

            Hide
            jglick Jesse Glick added a comment -

            What about calling super(parent) from AntClassLoader improves matters? Was the problem that most resource loads are from core? If so, does this still correctly handle plugins that request parent-first loading?

            Show
            jglick Jesse Glick added a comment - What about calling super(parent) from AntClassLoader improves matters? Was the problem that most resource loads are from core? If so, does this still correctly handle plugins that request parent-first loading?
            Hide
            jglick Jesse Glick added a comment -

            JENKINS-22310 has the discussion.

            Show
            jglick Jesse Glick added a comment - JENKINS-22310 has the discussion.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Kohsuke Kawaguchi
            Path:
            core/src/main/java/hudson/ClassicPluginStrategy.java
            core/src/main/java/jenkins/util/AntClassLoader.java
            http://jenkins-ci.org/commit/jenkins/705f5eb8e737d1e0770f509edb5edb3d50f60cdc
            Log:
            JENKINS-21579 Copied as-is from Ant 1.8.3 to apply patches

            (cherry picked from commit 69773dc9f785b12f033ba268fb4e4107fc3e7f46)

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Kohsuke Kawaguchi Path: core/src/main/java/hudson/ClassicPluginStrategy.java core/src/main/java/jenkins/util/AntClassLoader.java http://jenkins-ci.org/commit/jenkins/705f5eb8e737d1e0770f509edb5edb3d50f60cdc Log: JENKINS-21579 Copied as-is from Ant 1.8.3 to apply patches (cherry picked from commit 69773dc9f785b12f033ba268fb4e4107fc3e7f46)
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Kohsuke Kawaguchi
            Path:
            core/src/main/java/jenkins/util/AntClassLoader.java
            http://jenkins-ci.org/commit/jenkins/fd9f273f3645fc670e1283bbed7967f789475c86
            Log:
            [FIXED JENKINS-21579] UberClassLoader.findResources() improvements

            This is just a locally patched version, so not meant to be used outside
            core.

            Cherry-picked-from: 9a2882dd704bece9b7ca51a52347dad15d79f843

            Compare: https://github.com/jenkinsci/jenkins/compare/f01a7c2c0ef3...fd9f273f3645

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Kohsuke Kawaguchi Path: core/src/main/java/jenkins/util/AntClassLoader.java http://jenkins-ci.org/commit/jenkins/fd9f273f3645fc670e1283bbed7967f789475c86 Log: [FIXED JENKINS-21579] UberClassLoader.findResources() improvements This is just a locally patched version, so not meant to be used outside core. Cherry-picked-from: 9a2882dd704bece9b7ca51a52347dad15d79f843 Compare: https://github.com/jenkinsci/jenkins/compare/f01a7c2c0ef3...fd9f273f3645
            Hide
            marcomiller Marco Miller added a comment - - edited

            fd9f273f3645fc670e1283bbed7967f789475c86
            and
            705f5eb8e737d1e0770f509edb5edb3d50f60cdc
            are the 2 commits by KK fixing this issue.
            -Which commits I back-ported to 1.554.1 (current 'stable’ branch).
            I did so after this successful testing of ours:

            • jenkinsci /jenkins unit tests, for regression (passing ones kept passing);
            • jenkinsci /acceptance-test-harness, incl. both parent- and plugin-1st class-loading plugins (failures looked unrelated);
            • Ericsson-internal CLI ‘stress' tests, which used to reproduce JENKINS-22310; incl. parent/plugin-1st plugins, too;
            • brief manual testing through quick clicking-around, exercising some parent+plugin-1st (plugins) class-loading.
            Show
            marcomiller Marco Miller added a comment - - edited fd9f273f3645fc670e1283bbed7967f789475c86 and 705f5eb8e737d1e0770f509edb5edb3d50f60cdc are the 2 commits by KK fixing this issue. -Which commits I back-ported to 1.554.1 (current 'stable’ branch). I did so after this successful testing of ours: jenkinsci /jenkins unit tests, for regression (passing ones kept passing); jenkinsci /acceptance-test-harness, incl. both parent- and plugin-1st class-loading plugins (failures looked unrelated); Ericsson-internal CLI ‘stress' tests, which used to reproduce JENKINS-22310 ; incl. parent/plugin-1st plugins, too; brief manual testing through quick clicking-around, exercising some parent+plugin-1st (plugins) class-loading.

              People

              • Assignee:
                kohsuke Kohsuke Kawaguchi
                Reporter:
                jglick Jesse Glick
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: