X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fselection-strategies%2Fweighted-round-robin-worker-choice-strategy.ts;h=df45feb3829a4972962d1f51aeeb1e7bcfbc1d7d;hb=ef680bb86320e17178912f48db6cad9bcc4cb2e2;hp=5d8bbe2f1e4466bdfa12b0167d79ee53fc94e065;hpb=97f4fd90399b9e17f30d6b64308599c6c4b72008;p=poolifier.git 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 5d8bbe2f..df45feb3 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 @@ -28,7 +28,10 @@ export class WeightedRoundRobinWorkerChoiceStrategy< public readonly requiredStatistics: RequiredStatistics = { runTime: true, avgRunTime: true, - medRunTime: false + medRunTime: false, + waitTime: false, + avgWaitTime: false, + medWaitTime: false } /** @@ -50,7 +53,7 @@ export class WeightedRoundRobinWorkerChoiceStrategy< opts: WorkerChoiceStrategyOptions = DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS ) { super(pool, opts) - this.checkOptions(this.opts) + this.setRequiredStatistics(this.opts) this.defaultWorkerWeight = this.computeDefaultWorkerWeight() } @@ -75,7 +78,7 @@ export class WeightedRoundRobinWorkerChoiceStrategy< if (workerVirtualTaskRunTime < workerWeight) { this.workerVirtualTaskRunTime = workerVirtualTaskRunTime + - this.getWorkerVirtualTaskRunTime(chosenWorkerNodeKey) + this.getWorkerTaskRunTime(chosenWorkerNodeKey) } else { this.currentWorkerNodeId = this.currentWorkerNodeId === this.pool.workerNodes.length - 1 @@ -99,12 +102,6 @@ export class WeightedRoundRobinWorkerChoiceStrategy< return true } - private getWorkerVirtualTaskRunTime (workerNodeKey: number): number { - return this.requiredStatistics.medRunTime - ? this.pool.workerNodes[workerNodeKey].tasksUsage.medRunTime - : this.pool.workerNodes[workerNodeKey].tasksUsage.avgRunTime - } - private computeDefaultWorkerWeight (): number { let cpusCycleTimeWeight = 0 for (const cpu of cpus()) {