From b808b62580605e507857b67330a7f5baced7810c Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 21 Nov 2023 20:43:45 +0100 Subject: [PATCH] fix: partially revert "fix: sort round weights descending in IWRR" MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- CHANGELOG.md | 1 - docs/worker-choice-strategies.md | 2 +- .../interleaved-weighted-round-robin-worker-choice-strategy.ts | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e17cee6..60a03ae2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Ensure pool statuses are checked at initialization, `start()` or `destroy()`. -- Sort IWRR worker choice strategy round weights in descending order. ## [3.0.5] - 2023-10-27 diff --git a/docs/worker-choice-strategies.md b/docs/worker-choice-strategies.md index f7380dd6..36d6cf70 100644 --- a/docs/worker-choice-strategies.md +++ b/docs/worker-choice-strategies.md @@ -24,7 +24,7 @@ The worker weights are maximum tasks execution time. Once the worker has reached ### Interleaved weighted round robin (experimental) -The worker weights are maximum tasks execution time. The rounds are the deduplicated worker weights in descending order. +The worker weights are maximum tasks execution time. The rounds are the deduplicated worker weights in ascending order. During a round, if the worker weight is superior or equal to the current round weight and its tasks execution time is inferior to the current round weight, the task is assigned to the worker. Once all workers weight have been tested, the next round starts. The default worker weights is the same for each and computed given the CPU cores speed and theirs numbers. So the default 'rounds' consists of a unique worker weight. diff --git a/src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts b/src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts index 9c863b56..eee39ec8 100644 --- a/src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts @@ -170,7 +170,7 @@ export class InterleavedWeightedRoundRobinWorkerChoiceStrategy< ...new Set( Object.values(this.opts.weights) .slice() - .sort((a, b) => b - a) + .sort((a, b) => a - b) ) ] } -- 2.34.1