X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fselection-strategies%2Ffair-share-worker-choice-strategy.ts;h=ff9eaf36a93791b2d4e0002c2decd22402e92607;hb=9adcefabee69d0c8a8f580c2512e35d2c54c8219;hp=f6fdc4af462823981ad5e646974548b6acbb2951;hpb=b6b3245344bd453ea91fa3d74acd5145f70d84fd;p=poolifier.git diff --git a/src/pools/selection-strategies/fair-share-worker-choice-strategy.ts b/src/pools/selection-strategies/fair-share-worker-choice-strategy.ts index f6fdc4af..ff9eaf36 100644 --- a/src/pools/selection-strategies/fair-share-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/fair-share-worker-choice-strategy.ts @@ -2,10 +2,11 @@ import { DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS } from '../../utils' import type { IPool } from '../pool' import type { IWorker } from '../worker' import { AbstractWorkerChoiceStrategy } from './abstract-worker-choice-strategy' -import type { - IWorkerChoiceStrategy, - TaskStatistics, - WorkerChoiceStrategyOptions +import { + type IWorkerChoiceStrategy, + Measurements, + type TaskStatisticsRequirements, + type WorkerChoiceStrategyOptions } from './selection-strategies-types' /** @@ -24,14 +25,22 @@ export class FairShareWorkerChoiceStrategy< extends AbstractWorkerChoiceStrategy implements IWorkerChoiceStrategy { /** @inheritDoc */ - public readonly taskStatistics: TaskStatistics = { - runTime: true, - avgRunTime: true, - medRunTime: false, - waitTime: false, - avgWaitTime: false, - medWaitTime: false, - elu: false + public readonly taskStatisticsRequirements: TaskStatisticsRequirements = { + runTime: { + aggregate: true, + average: true, + median: false + }, + waitTime: { + aggregate: false, + average: false, + median: false + }, + elu: { + aggregate: true, + average: true, + median: false + } } /** @@ -45,7 +54,7 @@ export class FairShareWorkerChoiceStrategy< opts: WorkerChoiceStrategyOptions = DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS ) { super(pool, opts) - this.setTaskStatistics(this.opts) + this.setTaskStatisticsRequirements(this.opts) } /** @inheritDoc */ @@ -101,9 +110,11 @@ export class FairShareWorkerChoiceStrategy< workerNodeKey: number, workerVirtualTaskStartTimestamp: number ): number { - return ( - workerVirtualTaskStartTimestamp + this.getWorkerTaskRunTime(workerNodeKey) - ) + const workerTaskRunTime = + this.opts.measurement === Measurements.elu + ? this.getWorkerTaskElu(workerNodeKey) + : this.getWorkerTaskRunTime(workerNodeKey) + return workerVirtualTaskStartTimestamp + workerTaskRunTime } private getWorkerVirtualTaskStartTimestamp (workerNodeKey: number): number {