From: Jérôme Benoit Date: Tue, 6 Jun 2023 20:42:06 +0000 (+0200) Subject: fix: ensure the least busy strategy only relies on task runtime X-Git-Tag: v2.5.4~12 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=272d4d8fda8b9607fde68d57ec5b145639f94514;p=poolifier.git fix: ensure the least busy strategy only relies on task runtime Signed-off-by: Jérôme Benoit --- diff --git a/CHANGELOG.md b/CHANGELOG.md index dc94cb94..cb62e716 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Compute statistics at the worker level only if needed. +### Fixed + +- Make the `LEAST_BUSY` strategy only relies on task runtime. + ## [2.5.3] - 2023-06-04 ### Changed diff --git a/src/pools/selection-strategies/least-busy-worker-choice-strategy.ts b/src/pools/selection-strategies/least-busy-worker-choice-strategy.ts index 16b2988b..67332c70 100644 --- a/src/pools/selection-strategies/least-busy-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/least-busy-worker-choice-strategy.ts @@ -54,10 +54,10 @@ export class LeastBusyWorkerChoiceStrategy< /** @inheritDoc */ public choose (): number { - const freeWorkerNodeKey = this.findFreeWorkerNodeKey() - if (freeWorkerNodeKey !== -1) { - return freeWorkerNodeKey - } + // const freeWorkerNodeKey = this.findFreeWorkerNodeKey() + // if (freeWorkerNodeKey !== -1) { + // return freeWorkerNodeKey + // } let minRunTime = Infinity let leastBusyWorkerNodeKey!: number for (const [workerNodeKey, workerNode] of this.pool.workerNodes.entries()) { diff --git a/tests/pools/selection-strategies/selection-strategies.test.js b/tests/pools/selection-strategies/selection-strategies.test.js index eedee427..cf6f1601 100644 --- a/tests/pools/selection-strategies/selection-strategies.test.js +++ b/tests/pools/selection-strategies/selection-strategies.test.js @@ -460,9 +460,9 @@ describe('Selection strategies test suite', () => { error: 0, elu: undefined }) - expect(workerNode.tasksUsage.ran).toBeGreaterThan(0) + expect(workerNode.tasksUsage.ran).toBeGreaterThanOrEqual(0) expect(workerNode.tasksUsage.ran).toBeLessThanOrEqual(max * maxMultiplier) - expect(workerNode.tasksUsage.runTime).toBeGreaterThan(0) + expect(workerNode.tasksUsage.runTime).toBeGreaterThanOrEqual(0) } // We need to clean up the resources after our test await pool.destroy()