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

Job execution time includes waiting time

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Component/s: pipeline
    • Labels:
      None
    • Environment:
    • Similar Issues:

      Description

      The issue occours if you have a "Multibranch Pipeline" job that takes some time such as:

      pipeline {
          agent any
          
          stages {
               stage('only'){
                  steps {
                      checkout scm
                      sh 'sleep 300'
                  }
              }
          }
      }

          
      This gets automatically detected by the pipeline and executed. This can also be kicked off manually by going into the job and clicking the run button beside the branch (e.g. 'master'). If this button is pushed twice in succession (or two branches are committed at the same time) two instances of the job will run. If there is a single build executor that these jobs can run on (I have only seen this when the executor is separate from the "master" node), the first will start running. The second will do some pipeline action to identify what needs to be run, but then wait in the queue for the first job to complete. Once the first job has completed the second job will run to completion. For the above job, the first job will show as taking the appropriate five minutes. However, the second job will show as taking ten minutes....it is including the time it was waiting for an executor! If this is done with many jobs, the time will include all the time that each job had to wait in the queue. When looking at the historical builds, it will look like it took ten minutes to execute even though it was five of waiting and five of executing. This will also affect the projected build time for the next job run.

      This also shows "10 minutes building on an executor" if the metrics plugin is installed.

      The solution to this is to not include the time spent waiting for an executor in the build time recorded. I believe the matrix jobs had a similar issue that was fixed in Issue #8112.

        Attachments

          Activity

          teeks99 Thomas Kent created issue -
          ddaehler Daniel Daehler made changes -
          Field Original Value New Value
          Issue Type Improvement [ 4 ] Bug [ 1 ]
          tom_gl Thomas de Grenier de Latour made changes -
          Description The issue occours if you have a "Multibranch Pipeline" job that takes some time such as:


          {code:java}
          pipeline {
              agent any
              
              stages {
                  stage('only'){
                      steps {
                          checkout scm
                          sh 'sleep 300'
                      }
                  }
              }
          }{code}

              
          This gets automatically detected by the pipeline and executed. This can also be kicked off manually by going into the job and clicking the run button beside the branch (e.g. 'master'). If this button is pushed twice in succession (or two branches are committed at the same time) two instances of the job will run. If there is a single build executor that these jobs can run on (I have only seen this when the executor is separate from the "master" node), the first will start running. The second will do some pipeline action to identify what needs to be run, but then wait in the queue for the first job to complete. Once the first job has completed the second job will run to completion. For the above job, the first job will show as taking the appropriate five minutes. However, the second job will show as taking ten minutes....it is including the time it was waiting for an executor! If this is done with many jobs, the time will include all the time that each job had to wait in the queue. When looking at the historical builds, it will look like it took ten minutes to execute even though it was five of waiting and five of executing. This will also affect the projected build time for the next job run.

          This also shows "10 minutes building on an executor" if the metrics plugin is installed.

          The solution to this is to not include the time spent waiting for an executor in the build time recorded. I believe the matrix jobs had a similar issue that was fixed in Issue #8112.
          The issue occours if you have a "Multibranch Pipeline" job that takes some time such as:
          {code:java}
          pipeline {
              agent any
              
              stages {
                   stage('only'){
                      steps {
                          checkout scm
                          sh 'sleep 300'
                      }
                  }
              }
          }{code}
              
           This gets automatically detected by the pipeline and executed. This can also be kicked off manually by going into the job and clicking the run button beside the branch (e.g. 'master'). If this button is pushed twice in succession (or two branches are committed at the same time) two instances of the job will run. If there is a single build executor that these jobs can run on (I have only seen this when the executor is separate from the "master" node), the first will start running. The second will do some pipeline action to identify what needs to be run, but then wait in the queue for the first job to complete. Once the first job has completed the second job will run to completion. For the above job, the first job will show as taking the appropriate five minutes. However, the second job will show as taking ten minutes....it is including the time it was waiting for an executor! If this is done with many jobs, the time will include all the time that each job had to wait in the queue. When looking at the historical builds, it will look like it took ten minutes to execute even though it was five of waiting and five of executing. This will also affect the projected build time for the next job run.

          This also shows "10 minutes building on an executor" if the metrics plugin is installed.

          The solution to this is to not include the time spent waiting for an executor in the build time recorded. I believe the matrix jobs had a similar issue that was fixed in Issue #8112.

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            teeks99 Thomas Kent
            Votes:
            41 Vote for this issue
            Watchers:
            45 Start watching this issue

              Dates

              Created:
              Updated: