After using the p4 plugin, and after it finished its task, the p4 plugin keeps opening connection and closing it. Each such action takes 1-2 seconds. So during the rest of the build, there is a delay of 5-20 seconds between the commands.
How to reproduce:
- Go to <jenkins url>/log/ and add a new logger called "p4"
Logger = "org.jenkinsci.plugins.p4" ; Log level = "ALL" - Create a pipeline job with this script:
node() { // library retriever: legacySCM(perforce( // fill your data here. // p4sync // fill your data here. stage('run') { 3.times { sh 'date' } } }
- Build the Job
- Now remove one of the commented lines (library with perforce or p4sync), fill the needed data. You can use the "Pipeline Syntax".
- Build the Job again
- Compare the time that the 'run' stage took:
- in step 3 it took ~350 ms
- in step 5 it took 53 seconds
and this time diff is only for 3 "sh" calls. For longer jobs it increases.
- Pay attention that this time is only for the 3 calls to "sh", and not including the p4 stage.
- Open the log you created at stage 1 (<jenkins url>/log/p4).
You can see there a loop of
P4: opened connection OK
P4: closed connection OK
Each "open" takes 1-2 seconds, and during this time the build can't proceed.
[JENKINS-54222] p4-plugin keeps opening connection during the build. Causing long delays
Status | Original: Open [ 1 ] | New: In Progress [ 3 ] |
The 'p4-plugin' runs extra commands 'p4 reconcile', 'p4 revert', etc... to cleanup and prep the workspace. This was designed to help larger code bases, but does add an overhead. Which mode are you using with 'p4sync' - 'autoClean', 'forceClean', etc...
I have added some additional logging to P4Logging.java, so I can see each command and its compute time. It probably makes sense to add this to aid with debugging.
Unfortunately I can't share the P4 connection across Jenkins as it spawns multiple threads. In addition the plugin requires connections for the master and slave nodes. There are a few extra 'p4 info' and 'p4 login -s' commands that are used to test long running commands; they could be optimised, but with great care.