X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fselection-strategies%2Fleast-elu-worker-choice-strategy.ts;h=41ebf7fb4c5a47d241410aa28cf52d9c4ae44d23;hb=cdb517b318cd4f26b4895988ae8444d50945ddde;hp=be3c4f5e2918ccd4bc9395bf0ab19fb72cfd19f0;hpb=ef3f48f74a74b6254e66478ee52b49afefd23373;p=poolifier.git diff --git a/src/pools/selection-strategies/least-elu-worker-choice-strategy.ts b/src/pools/selection-strategies/least-elu-worker-choice-strategy.ts index be3c4f5e..41ebf7fb 100644 --- a/src/pools/selection-strategies/least-elu-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/least-elu-worker-choice-strategy.ts @@ -54,19 +54,15 @@ export class LeastEluWorkerChoiceStrategy< /** @inheritDoc */ public choose (): number { - // const freeWorkerNodeKey = this.findFreeWorkerNodeKey() - // if (freeWorkerNodeKey !== -1) { - // return freeWorkerNodeKey - // } - let minTasksElu = Infinity + let minWorkerElu = Infinity let leastEluWorkerNodeKey!: number for (const [workerNodeKey, workerNode] of this.pool.workerNodes.entries()) { - const tasksUsage = workerNode.tasksUsage - const tasksElu = tasksUsage.elu?.utilization ?? 0 - if (tasksElu === 0) { + const workerUsage = workerNode.workerUsage + const workerElu = workerUsage.elu?.utilization ?? 0 + if (workerElu === 0) { return workerNodeKey - } else if (tasksElu < minTasksElu) { - minTasksElu = tasksElu + } else if (workerElu < minWorkerElu) { + minWorkerElu = workerElu leastEluWorkerNodeKey = workerNodeKey } }