Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

[JENKINS-30055] Handle a large number of steps in quick succession #213

Merged
merged 25 commits into from Jan 11, 2016

Conversation

jglick
Copy link
Member

@jglick jglick commented Sep 25, 2015

JENKINS-30055

Performance is still not great (about a minute to run on my laptop); mostly it just seems to be waiting in disk I/O to write lots of little log files, which is unavoidable so long as we maintain separate logs per step (JENKINS-30896).

@reviewbybees

…must receive events immediately, and unregister itself.
…g build.xml.

   java.lang.Thread.State: RUNNABLE
	at java.io.UnixFileSystem.delete0(Native Method)
	at java.io.UnixFileSystem.delete(UnixFileSystem.java:265)
	at java.io.File.delete(File.java:1041)
	at hudson.Util.deleteFile(Util.java:221)
	at hudson.util.AtomicFileWriter.commit(AtomicFileWriter.java:113)
	at hudson.XmlFile.write(XmlFile.java:179)
	at hudson.model.Run.save(Run.java:1898)
	- locked <0x0000000707031450> (a org.jenkinsci.plugins.workflow.job.WorkflowRun)
	at org.jenkinsci.plugins.workflow.job.WorkflowRun$GraphL.onNewHead(WorkflowRun.java:664)
	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.notifyListeners(CpsFlowExecution.java:790)
@ghost
Copy link

ghost commented Sep 25, 2015

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.

… resaving build.xml."

Did not have the intended effect, because there is typically just one listener, and the problem is notifyListeners being called many times.
This reverts commit a399362.
FlowNode.equals is based on id, so a static cache will be incorrect.
…wRun.save can be called from various threads.

The mutations are all guarded by WorkflowRun.completed, so we just need to allow serialization to see a snapshot.
(There was already a race condition in the case of abrupt shutdown, but at worst these should result in duplicated log text.)
@jglick jglick closed this Sep 27, 2015
@jglick jglick reopened this Sep 27, 2015
p.setDefinition(new CpsFlowDefinition("for (int i = 0; i < 10000; i++) {echo \"iteration #${i}\"}", true));
WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
r.assertLogContains("iteration #9876", b);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem, as I remember it, only became visible after a restart. In that case, shouldn't the test try reloading the persisted form of the Run (WorkflowRun.onLoad etc)?

@jglick
Copy link
Member Author

jglick commented Sep 28, 2015

The problem, as I remember it, only became visible after a restart. In that case, shouldn't the test try reloading the persisted form of the Run (WorkflowRun.onLoad etc)?

Indeed I just noticed this aspect of your JENKINS-30055. Perhaps not related to JENKINS-30651 after all. Looking into it.

@jtnord
Copy link
Member

jtnord commented Sep 29, 2015

🐝 on wip as my comment is addressed.

@jglick
Copy link
Member Author

jglick commented Nov 24, 2015

SimpleXStreamFlowNodeStorage.FlowNodeConverter.unmarshal leads to StackOverflowErrors due to its craziness.

@jglick
Copy link
Member Author

jglick commented Jan 6, 2016

Currently InputStepRestartTest.oldFlow is failing:

"Running CpsFlowExecution[Owner[p/2015-11-17_20-22-49:p #1]]":
SUREFIRE-859:   waiting to lock monitor 0x00007fa470009598 (object 0x00000007a0c5a440, a org.jenkinsci.plugins.workflow.job.WorkflowRun),
  which is held by "Handling POST /jenkins/job/p/1/input/D13c3f7baed576768b11a714ef4d90e2/submit from 127.0.0.1 : Jetty Thread Pool"
"Handling POST /jenkins/job/p/1/input/D13c3f7baed576768b11a714ef4d90e2/submit from 127.0.0.1 : Jetty Thread Pool":
SUREFIRE-859:   waiting to lock monitor 0x00007fa47c030018 (object 0x00000007a0c5caf8, a org.jenkinsci.plugins.workflow.cps.CpsFlowExecution),
  which is held by "Running CpsFlowExecution[Owner[p/2015-11-17_20-22-49:p #1]]"
"Running CpsFlowExecution[Owner[p/2015-11-17_20-22-49:p #1]]":
    at hudson.model.Run.save(Run.java:1897)
    - waiting to lock <0x00000007a0c5a440> (a org.jenkinsci.plugins.workflow.job.WorkflowRun)
    at hudson.BulkChange.commit(BulkChange.java:112)
    at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.notifyListeners(CpsFlowExecution.java:827)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.notifyNewHead(CpsThreadGroup.java:323)
    at org.jenkinsci.plugins.workflow.cps.FlowHead.setNewHead(FlowHead.java:119)
    at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.onProgramEnd(CpsFlowExecution.java:789)
    - locked <0x00000007a0c5caf8> (a org.jenkinsci.plugins.workflow.cps.CpsFlowExecution)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:297)
    at …
"Handling POST /jenkins/job/p/1/input/D13c3f7baed576768b11a714ef4d90e2/submit from 127.0.0.1 : Jetty Thread Pool":
    at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution$ConverterImpl.marshal(CpsFlowExecution.java:892)
    - waiting to lock <0x00000007a0c5caf8> (a org.jenkinsci.plugins.workflow.cps.CpsFlowExecution)
    at hudson.util.XStream2$AssociatedConverterImpl.marshal(XStream2.java:358)
    at …
    at hudson.XmlFile.write(XmlFile.java:178)
    at hudson.model.Run.save(Run.java:1898)
    - locked <0x00000007a0c5a440> (a org.jenkinsci.plugins.workflow.job.WorkflowRun)
    at org.jenkinsci.plugins.workflow.support.steps.input.InputStepExecution.postSettlement(InputStepExecution.java:223)
    at org.jenkinsci.plugins.workflow.support.steps.input.InputStepExecution.proceed(InputStepExecution.java:163)
    at org.jenkinsci.plugins.workflow.support.steps.input.InputStepExecution.doProceed(InputStepExecution.java:142)
    at org.jenkinsci.plugins.workflow.support.steps.input.InputStepExecution.doSubmit(InputStepExecution.java:126)
    at …

@@ -391,24 +394,48 @@ private void copyLogs() {
}
}

// CacheBuilder would be more convenient, but apparently does not support null values. Memoizer does not support weak keys.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use Optional but seems like overkill.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What blocks from using a FillerObject instead of null?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hence my comment about Optional.

@jglick jglick closed this Jan 8, 2016
@jglick jglick reopened this Jan 8, 2016
public abstract void addListener(GraphListener listener);

public /*abstract*/ void removeListener(GraphListener listener) {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs Javadoc and "TODO: make abstract" for the next backward-incompatible version

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no planned incompatible version.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

backward-what? There is no such word in Jenkins vocabulary 😺

@amuniz
Copy link
Member

amuniz commented Jan 11, 2016

🐝

@oleg-nenashev
Copy link
Member

LGTM 🐝

jglick added a commit that referenced this pull request Jan 11, 2016
[JENKINS-30055] Handle a large number of steps in quick succession
@jglick jglick merged commit 0fdf534 into jenkinsci:master Jan 11, 2016
@jglick jglick deleted the many-steps-JENKINS-30055 branch January 11, 2016 18:35
jglick added a commit to jglick/jenkins that referenced this pull request Jan 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
5 participants