fix: ensure tasks are distributed equally at less used and less busy
authorJérôme Benoit <jerome.benoit@sap.com>
Mon, 3 Apr 2023 21:38:29 +0000 (23:38 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Mon, 3 Apr 2023 21:38:29 +0000 (23:38 +0200)
strategy startup

Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/pools/selection-strategies/less-busy-worker-choice-strategy.ts
src/pools/selection-strategies/less-used-worker-choice-strategy.ts

index f2e401625ddd3764cd646d5cd931d23415f5f648..e9ba619a9767814acae8c2dd4caec7d07fc0dcd6 100644 (file)
@@ -30,7 +30,7 @@ export class LessBusyWorkerChoiceStrategy<
     let lessBusyWorkerKey!: number
     for (const [index, workerItem] of this.pool.workers.entries()) {
       const workerRunTime = workerItem.tasksUsage.runTime
-      if (!this.isDynamicPool && workerRunTime === 0) {
+      if (workerRunTime === 0) {
         return index
       } else if (workerRunTime < minRunTime) {
         minRunTime = workerRunTime
index 9cae4a54ae336204e4ab00f29b7789c280101682..f653160bdb29ece08cd5f1265012739da3443044 100644 (file)
@@ -25,7 +25,7 @@ export class LessUsedWorkerChoiceStrategy<
     for (const [index, workerItem] of this.pool.workers.entries()) {
       const tasksUsage = workerItem.tasksUsage
       const workerTasks = tasksUsage?.run + tasksUsage?.running
-      if (!this.isDynamicPool && workerTasks === 0) {
+      if (workerTasks === 0) {
         return index
       } else if (workerTasks < minNumberOfTasks) {
         minNumberOfTasks = workerTasks