-import { cpus } from 'node:os'
import {
DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS,
- getDefaultInternalWorkerChoiceStrategyOptions
+ buildInternalWorkerChoiceStrategyOptions
} from '../../utils'
import type { IPool } from '../pool'
import type { IWorker } from '../worker'
protected readonly pool: IPool<Worker, Data, Response>,
protected opts: InternalWorkerChoiceStrategyOptions
) {
- this.setOptions(this.opts)
+ this.opts = buildInternalWorkerChoiceStrategyOptions(
+ this.pool.info.maxSize,
+ this.opts
+ )
+ this.setTaskStatisticsRequirements(this.opts)
this.choose = this.choose.bind(this)
}
/** @inheritDoc */
public setOptions (opts: InternalWorkerChoiceStrategyOptions): void {
- this.opts = {
- ...getDefaultInternalWorkerChoiceStrategyOptions(this.pool.info.maxSize),
- ...opts
- }
+ this.opts = buildInternalWorkerChoiceStrategyOptions(
+ this.pool.info.maxSize,
+ opts
+ )
this.setTaskStatisticsRequirements(this.opts)
}
protected setPreviousWorkerNodeKey (workerNodeKey: number | undefined): void {
this.previousWorkerNodeKey = workerNodeKey ?? this.previousWorkerNodeKey
}
-
- protected computeDefaultWorkerWeight (): number {
- let cpusCycleTimeWeight = 0
- for (const cpu of cpus()) {
- // CPU estimated cycle time
- const numberOfDigits = cpu.speed.toString().length - 1
- const cpuCycleTime = 1 / (cpu.speed / Math.pow(10, numberOfDigits))
- cpusCycleTimeWeight += cpuCycleTime * Math.pow(10, numberOfDigits)
- }
- return Math.round(cpusCycleTimeWeight / cpus().length)
- }
}