From 7b0d35b850279213bac8a207d2fbe8b5ba064baf Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 11 Oct 2022 10:57:48 +0200 Subject: [PATCH] WRR strategy: round the default weight computation 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 | 8 ++------ 1 file changed, 2 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 e05b6fae..ed869091 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 @@ -87,11 +87,7 @@ export class WeightedRoundRobinWorkerChoiceStrategy< } else { this.setWorkerTaskRunTime(currentWorker, workerTaskWeight, 0) } - if ( - workerVirtualTaskRunTime < - (this.workersTaskRunTime.get(currentWorker)?.weight ?? - this.defaultWorkerWeight) - ) { + if (workerVirtualTaskRunTime < workerTaskWeight) { this.previousWorkerIndex = this.currentWorkerIndex } else { this.previousWorkerIndex = this.currentWorkerIndex @@ -136,6 +132,6 @@ export class WeightedRoundRobinWorkerChoiceStrategy< const cpuCycleTime = 1 / (cpu.speed / Math.pow(10, numberOfDigit)) cpusCycleTimeWeight += cpuCycleTime * Math.pow(10, numberOfDigit) } - return cpusCycleTimeWeight / cpus().length + return Math.round(cpusCycleTimeWeight / cpus().length) } } -- 2.34.1