From 553ad720b4ca65b39e5026fa37f07c5e04aa11b8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 14 Oct 2022 23:50:25 +0200 Subject: [PATCH] WRR strategy: cleanups MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../weighted-round-robin-worker-choice-strategy.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts b/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts index 2b9cfc745..380331321 100644 --- a/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts @@ -77,19 +77,18 @@ export class WeightedRoundRobinWorkerChoiceStrategy< const workerTaskWeight = this.workersTaskRunTime.get(chosenWorker)?.weight ?? this.defaultWorkerWeight - if ( - (this.workersTaskRunTime.get(chosenWorker)?.runTime ?? 0) < - workerTaskWeight - ) { + const workerTaskRunTime = + this.workersTaskRunTime.get(chosenWorker)?.runTime ?? 0 + if (workerTaskRunTime < workerTaskWeight) { this.setWorkerTaskRunTime( chosenWorker, workerTaskWeight, - (this.workersTaskRunTime.get(chosenWorker)?.runTime ?? 0) + + workerTaskRunTime + (this.getWorkerVirtualTaskRunTime(chosenWorker) ?? 0) ) } else { this.currentWorkerIndex = - this.pool.workers.length - 1 === this.currentWorkerIndex + this.currentWorkerIndex === this.pool.workers.length - 1 ? 0 : this.currentWorkerIndex + 1 chosenWorker = this.pool.workers[this.currentWorkerIndex] -- 2.43.0