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

Throttled slave usage step

XMLWordPrintable

      Would be useful to have a step which lets you throttle how many ExecutorStepExecution instances from this flow run (or job?) are permitted to run concurrently, even if there are enough free executors in the system. For example:

      def branches = [:];
      for (int i = 0; i < 100; i++) {
        branches["part${i}"] = {
          node {
            if (i % 5 == 0) {
              runSomethingQuiteSlow();
            } else {
              runSomethingQuick();
            }
          }
        };
      }
      throttleNodes(10) {
          parallel branches;
      }
      

      This would ensure that at most ten slaves are running stuff for your job at any given time. This is better than just creating ten branches, because if a slave finishes one of the quick branches it can proceed to pick up and run another branch while some other slaves remain busy with slow branches.

      The step need do nothing more than register a QueueTaskDispatcher active during its body which counts running Queue.Task instances associated with this Run (or Job) and rejects attempts to schedule more than a specified limit.

            jglick Jesse Glick
            jglick Jesse Glick
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: