From: Jérôme Benoit Date: Tue, 11 Oct 2022 08:57:48 +0000 (+0200) Subject: WRR strategy: round the default weight computation X-Git-Tag: v2.3.1~28 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=7b0d35b850279213bac8a207d2fbe8b5ba064baf;p=poolifier.git WRR strategy: round the default weight computation Signed-off-by: Jérôme Benoit --- 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) } }