perf: remove unneeded branching in worker choice strategies
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 15 May 2024 13:44:55 +0000 (15:44 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 15 May 2024 13:44:55 +0000 (15:44 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
src/pools/selection-strategies/fair-share-worker-choice-strategy.ts
src/pools/selection-strategies/least-busy-worker-choice-strategy.ts
src/pools/selection-strategies/least-elu-worker-choice-strategy.ts
src/pools/selection-strategies/least-used-worker-choice-strategy.ts

index 2f2686e9bb0f5f6a6c18aa5ce51c913e9d3af7c5..357b770a1f3eec275e87e8d7702ed42a8fd26bbd 100644 (file)
@@ -81,9 +81,6 @@ export class FairShareWorkerChoiceStrategy<
   }
 
   private fairShareNextWorkerNodeKey (): number | undefined {
-    if (this.pool.workerNodes.length === 0) {
-      return undefined
-    }
     return this.pool.workerNodes.reduce(
       (minWorkerNodeKey, workerNode, workerNodeKey, workerNodes) => {
         if (workerNode.strategyData?.virtualTaskEndTimestamp == null) {
index a9fe3d1c3f0eb779ea47d6907cbb8aed464e46d9..b07a9d1cafe223b642c8dd337cb986d4ea918272 100644 (file)
@@ -69,9 +69,6 @@ export class LeastBusyWorkerChoiceStrategy<
   }
 
   private leastBusyNextWorkerNodeKey (): number | undefined {
-    if (this.pool.workerNodes.length === 0) {
-      return undefined
-    }
     return this.pool.workerNodes.reduce(
       (minWorkerNodeKey, workerNode, workerNodeKey, workerNodes) => {
         return this.isWorkerNodeReady(workerNodeKey) &&
index 9cb28bacfc2bcbcc91605c6a4914d46fd21f7da0..6eaaacfbd4545d82c52c22eadc160ee286a8011a 100644 (file)
@@ -65,9 +65,6 @@ export class LeastEluWorkerChoiceStrategy<
   }
 
   private leastEluNextWorkerNodeKey (): number | undefined {
-    if (this.pool.workerNodes.length === 0) {
-      return undefined
-    }
     return this.pool.workerNodes.reduce(
       (minWorkerNodeKey, workerNode, workerNodeKey, workerNodes) => {
         return this.isWorkerNodeReady(workerNodeKey) &&
index cd93d752d7f5009154dc796ee1d1c824b81075af..601b72beba7e2ece8dc70319e682067c43fe70e0 100644 (file)
@@ -51,9 +51,6 @@ export class LeastUsedWorkerChoiceStrategy<
   }
 
   private leastUsedNextWorkerNodeKey (): number | undefined {
-    if (this.pool.workerNodes.length === 0) {
-      return undefined
-    }
     return this.pool.workerNodes.reduce(
       (minWorkerNodeKey, workerNode, workerNodeKey, workerNodes) => {
         return this.isWorkerNodeReady(workerNodeKey) &&