Closed timja closed 11 years ago
Can add a dependency from remoting on ASM via http://kohsuke.org/2012/03/03/potd-package-renamed-asm/ if needed for prefetch.
Code changed in jenkins
User: Jesse Glick
Path:
src/main/java/hudson/remoting/Channel.java
http://jenkins-ci.org/commit/remoting/2b1ec8ab152805f01b4063dabc4dcdef64421fed
Log:
JENKINS-15120 Kohsuke’s explanation of why preloadJar does not really help.
https://github.com/jenkinsci/mock-slave-plugin useful for testing impact on performance more controllably than simply connecting to some node in the cloud.
remoting #37248f1 also suggests using
sudo tc qdisc add dev lo root netem delay 100ms
to simulate a laggy network.
Using mock-slave with 10ms latency and building a multimodule Maven project in current trunk I get
Loading Type | Time (s) | Count |
---|---|---|
Classes | 223.8 | 2993 |
Resources | 2.7 | 23 |
With prefetch-JENKINS-15120 from Jenkins core checked out (which pulls in a branch of the same name from remoting), this was
Loading Type | Time (s) | Count |
---|---|---|
Classes | 165.5 | 3361 (prefetch cache: 1651) |
Resources | 2.3 | 26 |
though timing is not exactly comparable since the branch currently enables rather verbose logging which slows down the connection.
Retesting with svn up for both builds (originally the first used co), and with verbose logging turned off in the branch. Trunk builds takes 6:02 min (of which the Maven build itself was 1:26):
Loading Type | Time (s) | Count |
---|---|---|
Classes | 243.2 | 3320 |
Resources | 2.6 | 26 |
I tried to run the branch build again but this time it failed with a java.lang.OutOfMemoryError: PermGen space (on the master) which is disconcerting; did the branch introduce some kind of class loader leak?
I retried it, this time succeeding in 4:10 (Maven build 1:06):
Loading Type | Time (s) | Count |
---|---|---|
Classes | 141.0 | 3323 (prefetch cache: 1633) |
Resources | 2.2 | 26 |
So that is a 31% reduction in build time, which I would say is pretty good.
BTW using https://svn.codehaus.org/mojo/trunk/mojo/nbm-maven as the test project, more or less arbitrarily. Intentionally using a native Maven project since that puts far more load on the remoting layer than a freestyle project.
Code changed in jenkins
User: Kohsuke Kawaguchi
Path:
changelog.html
core/src/main/java/hudson/ClassicPluginStrategy.java
maven-plugin/src/main/java/hudson/maven/Maven3Builder.java
pom.xml
http://jenkins-ci.org/commit/jenkins/f7330d7a158eff6705706b1f812993a9b918c351
Log:
[FIXED JENKINS-15120]
Compare: https://github.com/jenkinsci/jenkins/compare/b1f5d28f90ca...f7330d7a158e
Integrated in jenkins_main_trunk #2582
[FIXED JENKINS-15120] (Revision f7330d7a158eff6705706b1f812993a9b918c351)
Result = UNSTABLE
kohsuke : f7330d7a158eff6705706b1f812993a9b918c351
Files :
Code changed in jenkins
User: Kohsuke Kawaguchi
Path:
src/main/java/org/jenkinsci/maven/plugins/hpi/AbstractHpiMojo.java
src/main/java/org/jenkinsci/maven/plugins/hpi/HpiMojo.java
http://jenkins-ci.org/commit/maven-hpi-plugin/603535119122e820751607812bb7d0bd3b8c3556
Log:
Modified to produce a jar file instead of WEB-INF/classes
Because of the prefetching change in remoting (see JENKINS-15120), it
is desirable now to produce class files in a jar file, not in a classes
directory, so that slaves can prefetch them and cache them efficiently.
Compare: https://github.com/jenkinsci/maven-hpi-plugin/compare/4d27f2880fa5...603535119122
Would this work affect freestyle projects using ant / nant / batch builds?
Would this work affect freestyle projects using ant / nant / batch builds?
Some, though not as much as for Maven projects. Depends on the plugins in use during the build, particularly how large their transitive dependencies are.
Seems that this new feature breaks class loading of the findbugs plug-in, see JENKINS-18405 and JENKINS-18394 for details...
Maybe also the cause of JENKINS-18401
Reopening this issue since it breaks class loading of findbugs plug-in and maven jobs. I can reproduce that issue on my machine, is there anything I can add in my plug-in to prevent these incompatible class exceptions?
Process wise, let's leave this bug closed. Instead, if you come across bugs that appear to be related, please link them.
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.
yyuu:
This also affects plugins written in JRuby. I created the issue of ruby plugins as JENKINS-18528
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
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
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]
Originally-Committed-As: f7330d7a158eff6705706b1f812993a9b918c351
[Originally related to: JENKINS-18394]
[Originally related to: JENKINS-18401]
[Originally related to: JENKINS-18405]
[Originally related to: JENKINS-18533]
[Originally related to: JENKINS-16261]
[Originally related to: JENKINS-18459]
[Originally related to: JENKINS-18836]
[Originally related to: JENKINS-18525]
[Originally related to: JENKINS-18528]
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 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:
Originally reported by jglick, imported from: Minimize round trips for slave class loading