refactor: display back pressured worker nodes in pool info
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 19 Aug 2024 12:38:22 +0000 (14:38 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 19 Aug 2024 12:38:22 +0000 (14:38 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
src/pools/abstract-pool.ts
src/pools/pool.ts
tests/pools/abstract-pool.test.mjs

index a65cbbbcb091524da151d9ed2148b02640de09d0..cd55b7ff0b7096ba4d2ea5db872e4c44940809a5 100644 (file)
@@ -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,
index 27d897b2807f15f9a9e21bc9064e11e2a0803112..b6c343bbde782d8de6a67792c573209741c3b14d 100644 (file)
@@ -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
index 5b4f0246e9d234f59b44156317987fdd4bd010fc..ed4543dd4141bed999367e24c8b36b21c39748d5 100644 (file)
@@ -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),