We encounterd that a simple empty loop of 150 items takes 10 seconds te complete. A loop of 1000 iterations take up 1 minute. We don't see excessive CPU / memory usage on the Jenkins server / slave. The loop is very simple (nothing is executed inside the loop):

      for (i=0;i<1000;i++) {      

      }
           

          [JENKINS-48911] Empty for loop inside pipeline quite slow

          Huib-Jan Kwakernaak created issue -
          Huib-Jan Kwakernaak made changes -
          Description Original: We encounterd that a simple empty loop of 150 items takes 10 seconds te complete. A loop of 1000 iterations take up 1 minute. We don't see excessive CPU / memory usage on the Jenkins server / slave. The loop is very simple (nothing is executes inside the loop):

          for (i=0;i<1000;i++) \{      

          }
               
          New: We encounterd that a simple empty loop of 150 items takes 10 seconds te complete. A loop of 1000 iterations take up 1 minute. We don't see excessive CPU / memory usage on the Jenkins server / slave. The loop is very simple (nothing is executed inside the loop):

          for (i=0;i<1000;i++) \{      

          }
                
          Andrew Bayer made changes -
          Component/s New: workflow-cps-plugin [ 21713 ]
          Component/s Original: pipeline-utility-steps-plugin [ 21135 ]
          Andrew Bayer made changes -
          Assignee Original: rsandell [ rsandell ]

          Oleg Nenashev added a comment -

          It is an expected behavior IMO. If you ant to speed up execution, move the logic to a NonCPS method so that there is no context saving overhead

          Oleg Nenashev added a comment - It is an expected behavior IMO. If you ant to speed up execution, move the logic to a NonCPS method so that there is no context saving overhead
          Sam Van Oort made changes -
          Priority Original: Critical [ 2 ] New: Minor [ 4 ]

          Sam Van Oort added a comment -

          I'll second what Oleg said: this is not intended to be performant out-of-box as a general-purpose programming language.  There's a lot of overhead for the CPS object manipulation. 

          Using NonCPS will make it considerably faster. 

          One planned enhancement in the future that will help some is to make Script Security checks use a more efficient algorithm for security-checking signatures. 

          Sam Van Oort added a comment - I'll second what Oleg said: this is not intended to be performant out-of-box as a general-purpose programming language.  There's a lot of overhead for the CPS object manipulation.  Using NonCPS will make it considerably faster.  One planned enhancement in the future that will help some  is to make Script Security checks use a more efficient algorithm for security-checking signatures. 
          Andrew Bayer made changes -
          Labels Original: pipeline New: pipeline triaged-2018-11
          Andrew Bayer made changes -
          Labels Original: pipeline triaged-2018-11 New: complex-cps-code pipeline triaged-2018-11

            Unassigned Unassigned
            hkw Huib-Jan Kwakernaak
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: