New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FIXED JENKINS-34722] Performance improvement to not load all jobs #100
Conversation
The property improves performance for obtaining downstream projects by allowing users to reduce the number of runs to load when searching for the correct upstream project.
This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation. |
The unit test I wrote fails with the following:
however when I run the unit test in debug mode I get the following:
which it looks like it loads the same job twice, and loads all of the builds. Interestingly the test passes when I use the debugger and fails without it. |
import hudson.model.AbstractBuild; | ||
import hudson.model.AbstractProject; | ||
import hudson.model.Cause; | ||
import hudson.model.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW we typically discourage star imports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact Checkstyle is failing the build in this case.
It passes for me if I do diff --git a/src/test/java/au/com/centrumsystems/hudson/plugin/util/BuildUtilTest.java b/src/test/java/au/com/centrumsystems/hudson/plugin/util/BuildUtilTest.java
index 6869bb5..ba7177d 100644
--- a/src/test/java/au/com/centrumsystems/hudson/plugin/util/BuildUtilTest.java
+++ b/src/test/java/au/com/centrumsystems/hudson/plugin/util/BuildUtilTest.java
@@ -53,7 +53,7 @@ public class BuildUtilTest extends HudsonTestCase {
@Test
public void testGetDownstreamBuildWithLimit() throws Exception {
int max_upstream_depth = 3;
- int total_proj2_builds = 5;
+ int total_proj2_builds = 10;
System.setProperty(BuildUtil.class.getCanonicalName() + ".MAX_DOWNSTREAM_DEPTH", String.valueOf(max_upstream_depth));
final FreeStyleProject proj1 = createFreeStyleProject();
@@ -75,7 +75,7 @@ public class BuildUtilTest extends HudsonTestCase {
assertEquals("Proj2 does not have the correct number of builds.", total_proj2_builds + 1, proj2.getNextBuildNumber());
RunLoadCounter.prepare(proj2);
- assertFalse(RunLoadCounter.assertMaxLoads(proj2, max_upstream_depth - 1, new Callable<Boolean>() {
+ assertFalse(RunLoadCounter.assertMaxLoads(proj2, max_upstream_depth + 2, new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return BuildUtil.getDownstreamBuild(proj2, freeStyleBuild) != null; s/5/10/ to make sure we are not too close to the end of the builds anyway; and s/-1/+2/ to give us a little extra room for fencepost conditions. |
Thanks @jglick for the help fixing the unit test. It now passes on my local machine. |
Still complaining about CheckStyle, sigh.
|
public static Action getAllBuildParametersAction(// | ||
final AbstractBuild<?, ?> upstreamBuild, final AbstractProject<?, ?> downstreamProject) { // | ||
public static Action getAllBuildParametersAction(final AbstractBuild<?, ?> upstreamBuild, | ||
final AbstractProject<?, ?> downstreamProject) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was not part of my initial commit, but checkstyle gave me a warning about this being over 140 characters.
@jglick fixed checkstyle issues. |
🐝 |
👍 thanks @christ66 ! |
@dalvizu 👍 for cutting a new release with this PR. |
Can I get a quick review on #101 before a release? |
Fixed in 1.5.3.1 |
@dalvizu Why |
1.5.3.1 and 1.5.3 are the same - I botched the 1.5.3 release as the build requires jdk8 to build now or there is some javadoc error which I wasn't aware of. This isn't the beginning of a different versioning scheme or anything, 1.5.4 is the next release :) |
JENKINS-34722
Currently the
BuildUtil.getDownstreamBuild
will iterate through all of the downstream project builds even if the upstream build never executed the downstream job. This PR adds a system property which can limit the number of downstream builds to search. A unit test has also been added to confirm that the limit is properly being reached and does not exceed the max number of builds to search for when looking for downstream builds.@reviewbybees