X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fselection-strategies%2Fleast-elu-worker-choice-strategy.ts;h=938d2072e998eed7ac26deeb225662ad884217b8;hb=b9da9d7e74c720f83482a09d1b883fc83d04f4ed;hp=4cf2b3e43253fb1221652f5265fbc958841ff561;hpb=936fa0fb8e70b2c297938cc9455444486b6daa3e;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 4cf2b3e4..938d2072 100644 --- a/src/pools/selection-strategies/least-elu-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/least-elu-worker-choice-strategy.ts @@ -7,7 +7,6 @@ import type { IWorker } from '../worker' import { AbstractWorkerChoiceStrategy } from './abstract-worker-choice-strategy' import type { IWorkerChoiceStrategy, - StrategyPolicy, TaskStatisticsRequirements, WorkerChoiceStrategyOptions } from './selection-strategies-types' @@ -26,12 +25,6 @@ export class LeastEluWorkerChoiceStrategy< > extends AbstractWorkerChoiceStrategy implements IWorkerChoiceStrategy { - /** @inheritDoc */ - public readonly strategyPolicy: StrategyPolicy = { - dynamicWorkerUsage: false, - dynamicWorkerReady: true - } - /** @inheritDoc */ public readonly taskStatisticsRequirements: TaskStatisticsRequirements = { runTime: DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS, @@ -64,8 +57,7 @@ export class LeastEluWorkerChoiceStrategy< /** @inheritDoc */ public choose (): number | undefined { - const chosenWorkerNodeKey = this.leastEluNextWorkerNodeKey() - this.assignChosenWorkerNodeKey(chosenWorkerNodeKey) + this.nextWorkerNodeKey = this.leastEluNextWorkerNodeKey() return this.nextWorkerNodeKey } @@ -78,15 +70,15 @@ export class LeastEluWorkerChoiceStrategy< let minWorkerElu = Infinity let chosenWorkerNodeKey: number | undefined for (const [workerNodeKey, workerNode] of this.pool.workerNodes.entries()) { + if (!this.isWorkerNodeEligible(workerNodeKey)) { + continue + } const workerUsage = workerNode.usage const workerElu = workerUsage.elu?.active?.aggregate ?? 0 - if (this.isWorkerNodeEligible(workerNodeKey) && workerElu === 0) { + if (workerElu === 0) { chosenWorkerNodeKey = workerNodeKey break - } else if ( - this.isWorkerNodeEligible(workerNodeKey) && - workerElu < minWorkerElu - ) { + } else if (workerElu < minWorkerElu) { minWorkerElu = workerElu chosenWorkerNodeKey = workerNodeKey }