From: Jérôme Benoit Date: Mon, 19 Aug 2024 12:38:22 +0000 (+0200) Subject: refactor: display back pressured worker nodes in pool info X-Git-Tag: v4.2.3~2 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=8c7a518dde490c0d370dff2e47ee86062d715dad;p=poolifier.git refactor: display back pressured worker nodes in pool info Signed-off-by: Jérôme Benoit --- diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index a65cbbbc..cd55b7ff 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -311,16 +311,6 @@ export abstract class AbstractPool< utilization: round(this.utilization), }), workerNodes: this.workerNodes.length, - ...(this.opts.enableTasksQueue === true && { - stealingWorkerNodes: this.workerNodes.reduce( - (accumulator, workerNode) => - workerNode.info.continuousStealing || - workerNode.info.backPressureStealing - ? accumulator + 1 - : accumulator, - 0 - ), - }), idleWorkerNodes: this.workerNodes.reduce( (accumulator, _, workerNodeKey) => this.isWorkerNodeIdle(workerNodeKey) ? accumulator + 1 : accumulator, @@ -331,6 +321,23 @@ export abstract class AbstractPool< this.isWorkerNodeBusy(workerNodeKey) ? accumulator + 1 : accumulator, 0 ), + ...(this.opts.enableTasksQueue === true && { + stealingWorkerNodes: this.workerNodes.reduce( + (accumulator, workerNode) => + workerNode.info.continuousStealing || + workerNode.info.backPressureStealing + ? accumulator + 1 + : accumulator, + 0 + ), + }), + ...(this.opts.enableTasksQueue === true && { + backPressureWorkerNodes: this.workerNodes.reduce( + (accumulator, workerNode) => + workerNode.info.backPressure ? accumulator + 1 : accumulator, + 0 + ), + }), executedTasks: this.workerNodes.reduce( (accumulator, workerNode) => accumulator + workerNode.usage.tasks.executed, diff --git a/src/pools/pool.ts b/src/pools/pool.ts index 27d897b2..b6c343bb 100644 --- a/src/pools/pool.ts +++ b/src/pools/pool.ts @@ -88,12 +88,14 @@ export interface PoolInfo { readonly utilization?: number /** Pool total worker nodes. */ readonly workerNodes: number - /** Pool tasks stealing worker nodes. */ - readonly stealingWorkerNodes?: number /** Pool idle worker nodes. */ readonly idleWorkerNodes: number /** Pool busy worker nodes. */ readonly busyWorkerNodes: number + /** Pool tasks stealing worker nodes. */ + readonly stealingWorkerNodes?: number + /** Pool tasks back pressure worker nodes. */ + readonly backPressureWorkerNodes?: number readonly executedTasks: number readonly executingTasks: number readonly queuedTasks?: number diff --git a/tests/pools/abstract-pool.test.mjs b/tests/pools/abstract-pool.test.mjs index 5b4f0246..ed4543dd 100644 --- a/tests/pools/abstract-pool.test.mjs +++ b/tests/pools/abstract-pool.test.mjs @@ -1263,9 +1263,10 @@ describe('Abstract pool test suite', () => { minSize: expect.any(Number), maxSize: expect.any(Number), workerNodes: expect.any(Number), - stealingWorkerNodes: expect.any(Number), idleWorkerNodes: expect.any(Number), busyWorkerNodes: expect.any(Number), + stealingWorkerNodes: expect.any(Number), + backPressureWorkerNodes: expect.any(Number), executedTasks: expect.any(Number), executingTasks: expect.any(Number), maxQueuedTasks: expect.any(Number),