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

Minimize round trips for slave class loading

    Details

    • Similar Issues:

      Description

      Currently each attempt to load a class in a remote JVM makes a round-trip request to the master, which over a laggy network can make class loading quite slow, thus adding considerable overhead to the first build on a new slave.

      Two possible solutions have been put forward.

      Optimistic prefetch

      The idea: when sending a class file to be loaded, scan its bytecode for other statically linked classes which have not yet been loaded, and send those along as well. In the common case that a network of classes is loaded around the same time, this would avoid some round trips.

      Details

      The first part is for one side to keep track of what classes the other side has already loaded (into which class loader), which is basically memorizing the response from IClassLoader.fetch2.

      The second part is to add Collection<ClassFile> IClassLoader.fetch3 that works like fetch2, except it will also parse the class, figure out some of the referenced classes that are not yet loaded by the other side, then send them along.

      Those prefetched class files would need to be remembered by RemoteClassLoader so that when those are actually requested it can load a class in the right classloader without calling back RemoteClassLoader.proxy. (Assuming there are no side effects, it could also eagerly call RemoteClassLoader.loadClassFile on the prefetched classes.)

      The remoting layer supports talking to an earlier version of the remoting layer. We do this by a bitmask in Capability, so this needs one more bit defined there. There is no point in tracking the classes the other side has loaded if the other side will never call fetch3.

      Bulk transfer

      Send entire JAR files at a time, rather than individual classes; can wind up transferring more than is needed, but the reduction in latency is probably worth it. Since arbitrary class loader graphs might be in use, not just a flat classpath, some custom code needs to be run remotely which will implement the class loader delegation model without hitting the network for each class.

      Details

      An API sketch:

      class Channel {
        void setClassLoaderTrafficCop(TrafficCop cop);
      }
      interface TrafficCop {
        /** do I know/control/own this classloader? */
        boolean controls(ClassLoader cl);
        Set<JarFile> getJarFilesOf(ClassLoader cl);
        RemotePartOfTrafficCop getRemotePart();
      }
      class JarFile {
        String checksum();
        InputStream data();
      }
      /** runs in remote agent */
      interface RemotePartOfTrafficCop implements Serializable {
        /** given a class/resource and an originating loader, what is the defining loader? */
        RemoteClassLoader trafficControl(RemoteClassLoader origin, String resourceName);
      }
      

        Attachments

          Issue Links

            Activity

            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Kohsuke Kawaguchi
            Path:
            src/main/java/hudson/remoting/ResourceImageDirect.java
            http://jenkins-ci.org/commit/remoting/781ccaec2e26797bc8fa9e6c982a031988d381e0
            Log:
            JENKINS-18405

            This fixes the 'Unknown url shema' error in the FindBugs plugin.

            Before JENKINS-15120, we used to faithfully recreate the expected
            resource path in a temporary resource file. For some reasons, we lost
            that. This change brings it back by recreting the directory structure.

            Note that this change doesn't address
            "java.lang.IncompatibleClassChangeError: Implementing class" error
            reported also in JENKINS-18405. That is still under investigation.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Kohsuke Kawaguchi Path: src/main/java/hudson/remoting/ResourceImageDirect.java http://jenkins-ci.org/commit/remoting/781ccaec2e26797bc8fa9e6c982a031988d381e0 Log: JENKINS-18405 This fixes the 'Unknown url shema' error in the FindBugs plugin. Before JENKINS-15120 , we used to faithfully recreate the expected resource path in a temporary resource file. For some reasons, we lost that. This change brings it back by recreting the directory structure. Note that this change doesn't address "java.lang.IncompatibleClassChangeError: Implementing class" error reported also in JENKINS-18405 . That is still under investigation.
            Hide
            yyuu Yuu Yamashita added a comment -

            This also affects plugins written in JRuby. I created the issue of ruby plugins as JENKINS-18528

            Show
            yyuu Yuu Yamashita added a comment - This also affects plugins written in JRuby. I created the issue of ruby plugins as JENKINS-18528
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Nicolas De Loof
            Path:
            src/main/resources/hudson/plugins/ec2/EC2Computer/configure.jelly
            http://jenkins-ci.org/commit/ec2-plugin/995b20442314a3edb615caf803123e77c7c2c9fb
            Log:
            due to JENKINS-15120 relative path isn't supported anymore by st:include

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Nicolas De Loof Path: src/main/resources/hudson/plugins/ec2/EC2Computer/configure.jelly http://jenkins-ci.org/commit/ec2-plugin/995b20442314a3edb615caf803123e77c7c2c9fb Log: due to JENKINS-15120 relative path isn't supported anymore by st:include
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Francis Upton
            Path:
            src/main/resources/hudson/plugins/ec2/EC2Computer/configure.jelly
            http://jenkins-ci.org/commit/ec2-plugin/8d5be49e298d130fd4f16db9d5b28a9272825cbe
            Log:
            Merge pull request #62 from ndeloof/master

            due to JENKINS-15120 relative path isn't supported anymore by st:include

            Compare: https://github.com/jenkinsci/ec2-plugin/compare/6a374e309c22...8d5be49e298d

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Francis Upton Path: src/main/resources/hudson/plugins/ec2/EC2Computer/configure.jelly http://jenkins-ci.org/commit/ec2-plugin/8d5be49e298d130fd4f16db9d5b28a9272825cbe Log: Merge pull request #62 from ndeloof/master due to JENKINS-15120 relative path isn't supported anymore by st:include Compare: https://github.com/jenkinsci/ec2-plugin/compare/6a374e309c22...8d5be49e298d
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Kohsuke Kawaguchi
            Path:
            src/main/java/hudson/maven/Maven3Builder.java
            http://jenkins-ci.org/commit/maven-plugin/97b452ecc95a5546c471198126834f770a63a249
            Log:
            [FIXED JENKINS-15120]

            • integrated the newer release of remoting
            • jar caching won't work with class file directory, so plugin
              WEB-INF/classes are now exploded as WEB-INF/lib/classes.jar
              (This should also solve the problem of slow plugin extraction in the
              presene of Anti-virus software on Windows.)
            • because the structure of the exploded jar file has changed, I changed
              the up-to-date check timestamp file name to force re-extraction in
              existing installations.

            Originally-Committed-As: f7330d7a158eff6705706b1f812993a9b918c351

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Kohsuke Kawaguchi Path: src/main/java/hudson/maven/Maven3Builder.java http://jenkins-ci.org/commit/maven-plugin/97b452ecc95a5546c471198126834f770a63a249 Log: [FIXED JENKINS-15120] integrated the newer release of remoting jar caching won't work with class file directory, so plugin WEB-INF/classes are now exploded as WEB-INF/lib/classes.jar (This should also solve the problem of slow plugin extraction in the presene of Anti-virus software on Windows.) because the structure of the exploded jar file has changed, I changed the up-to-date check timestamp file name to force re-extraction in existing installations. Originally-Committed-As: f7330d7a158eff6705706b1f812993a9b918c351

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: