feat: reenable tasks stealing under back pressure by default
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Tue, 13 Aug 2024 19:20:45 +0000 (21:20 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Tue, 13 Aug 2024 19:20:45 +0000 (21:20 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
docs/api.md
src/pools/pool.ts
src/pools/utils.ts
tests/pools/abstract-pool.test.mjs
tests/pools/utils.test.mjs

index 580dfd2b4cdaf3c8e83dffa3c40892850448b628..113d4c12d4a6ed700dd816d5fcae87da720da670 100644 (file)
@@ -147,7 +147,7 @@ An object with these properties:
   - `tasksStealingRatio` (optional) - The ratio of worker nodes that can steal tasks from another worker node. It must be a number between 0 and 1.
   - `tasksFinishedTimeout` (optional) - Queued tasks finished timeout in milliseconds at worker termination.
 
-  Default: `{ size: (pool maximum size)^2, concurrency: 1, taskStealing: true, tasksStealingOnBackPressure: false, tasksStealingRatio: 0.6, tasksFinishedTimeout: 2000 }`
+  Default: `{ size: (pool maximum size)^2, concurrency: 1, taskStealing: true, tasksStealingOnBackPressure: true, tasksStealingRatio: 0.6, tasksFinishedTimeout: 2000 }`
 
 - `workerOptions` (optional) - An object with the worker options to pass to worker. See [worker_threads](https://nodejs.org/api/worker_threads.html#worker_threads_new_worker_filename_options) for more details.
 
index 42478ef31aaf953dd70dfbdd41d22d845ac20917..416d69616f94f4abd859d27a0efef11818aaaa08 100644 (file)
@@ -156,7 +156,7 @@ export interface TasksQueueOptions {
   readonly taskStealing?: boolean
   /**
    * Whether to enable tasks stealing under back pressure.
-   * @defaultValue false
+   * @defaultValue true
    */
   readonly tasksStealingOnBackPressure?: boolean
   /**
index aefce74a37210c719d1d3e44fb3e6d68c41bbdf5..7b3c21fa01a4902a44c350c7dfd0ced4af6c89ef 100644 (file)
@@ -43,7 +43,7 @@ export const getDefaultTasksQueueOptions = (
     size: Math.pow(poolMaxSize, 2),
     concurrency: 1,
     taskStealing: true,
-    tasksStealingOnBackPressure: false,
+    tasksStealingOnBackPressure: true,
     tasksStealingRatio: 0.6,
     tasksFinishedTimeout: 2000,
   }
index 375d9653e7fed8e260c310479d62e34c52e185a3..04c87246ddd604b0107cb8aae1f1534b14acee0f 100644 (file)
@@ -276,7 +276,7 @@ describe('Abstract pool test suite', () => {
         concurrency: 2,
         size: Math.pow(numberOfWorkers, 2),
         taskStealing: true,
-        tasksStealingOnBackPressure: false,
+        tasksStealingOnBackPressure: true,
         tasksStealingRatio: 0.6,
         tasksFinishedTimeout: 2000,
       },
@@ -623,7 +623,7 @@ describe('Abstract pool test suite', () => {
       concurrency: 1,
       size: Math.pow(numberOfWorkers, 2),
       taskStealing: true,
-      tasksStealingOnBackPressure: false,
+      tasksStealingOnBackPressure: true,
       tasksStealingRatio: 0.6,
       tasksFinishedTimeout: 2000,
     })
@@ -633,7 +633,7 @@ describe('Abstract pool test suite', () => {
       concurrency: 2,
       size: Math.pow(numberOfWorkers, 2),
       taskStealing: true,
-      tasksStealingOnBackPressure: false,
+      tasksStealingOnBackPressure: true,
       tasksStealingRatio: 0.6,
       tasksFinishedTimeout: 2000,
     })
@@ -653,7 +653,7 @@ describe('Abstract pool test suite', () => {
       concurrency: 1,
       size: Math.pow(numberOfWorkers, 2),
       taskStealing: true,
-      tasksStealingOnBackPressure: false,
+      tasksStealingOnBackPressure: true,
       tasksStealingRatio: 0.6,
       tasksFinishedTimeout: 2000,
     })
index e79294a288ebd1a49be845a55646ce689d0bbf3d..b2265b03cb51ce9dab9ef873f3efad05e6c776b3 100644 (file)
@@ -30,7 +30,7 @@ describe('Pool utils test suite', () => {
       concurrency: 1,
       size: Math.pow(poolMaxSize, 2),
       taskStealing: true,
-      tasksStealingOnBackPressure: false,
+      tasksStealingOnBackPressure: true,
       tasksStealingRatio: 0.6,
       tasksFinishedTimeout: 2000,
     })