refactor: set tasksFinishedTimeout default to 2000ms
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 18 Dec 2023 16:39:40 +0000 (17:39 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 18 Dec 2023 16:39:40 +0000 (17:39 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
docs/api.md
src/pools/utils.ts
tests/pools/abstract-pool.test.mjs
tests/pools/utils.test.mjs

index 968d6ab5c31e2bcdaaaf82845f24981ac54f8122..65d96e57171a11e8a813d0b9a100b3e2aacfb8c3 100644 (file)
@@ -138,7 +138,7 @@ An object with these properties:
   - `tasksStealingOnBackPressure` (optional) - Tasks stealing enablement under back pressure.
   - `tasksFinishedTimeout` (optional) - Queued tasks finished timeout in milliseconds at worker termination.
 
-  Default: `{ size: (pool maximum size)^2, concurrency: 1, taskStealing: true, tasksStealingOnBackPressure: true, tasksFinishedTimeout: 1000 }`
+  Default: `{ size: (pool maximum size)^2, concurrency: 1, taskStealing: true, tasksStealingOnBackPressure: true, 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 a6a52f0c663d246fcd4d2d5a1b560801eaa00921..3b98fbdc942834d661cd8320deefee9708033566 100644 (file)
@@ -29,7 +29,7 @@ export const getDefaultTasksQueueOptions = (
     concurrency: 1,
     taskStealing: true,
     tasksStealingOnBackPressure: true,
-    tasksFinishedTimeout: 1000
+    tasksFinishedTimeout: 2000
   }
 }
 
index cc4b0f387993f1a414a8b380dfc69ea54700b670..1b80aa4cdeb92efd76ed0c5f4e56e7357342c8a0 100644 (file)
@@ -265,7 +265,7 @@ describe('Abstract pool test suite', () => {
         size: Math.pow(numberOfWorkers, 2),
         taskStealing: true,
         tasksStealingOnBackPressure: true,
-        tasksFinishedTimeout: 1000
+        tasksFinishedTimeout: 2000
       },
       workerChoiceStrategy: WorkerChoiceStrategies.LEAST_USED,
       workerChoiceStrategyOptions: {
@@ -656,7 +656,7 @@ describe('Abstract pool test suite', () => {
       size: Math.pow(numberOfWorkers, 2),
       taskStealing: true,
       tasksStealingOnBackPressure: true,
-      tasksFinishedTimeout: 1000
+      tasksFinishedTimeout: 2000
     })
     pool.enableTasksQueue(true, { concurrency: 2 })
     expect(pool.opts.enableTasksQueue).toBe(true)
@@ -665,7 +665,7 @@ describe('Abstract pool test suite', () => {
       size: Math.pow(numberOfWorkers, 2),
       taskStealing: true,
       tasksStealingOnBackPressure: true,
-      tasksFinishedTimeout: 1000
+      tasksFinishedTimeout: 2000
     })
     pool.enableTasksQueue(false)
     expect(pool.opts.enableTasksQueue).toBe(false)
@@ -684,7 +684,7 @@ describe('Abstract pool test suite', () => {
       size: Math.pow(numberOfWorkers, 2),
       taskStealing: true,
       tasksStealingOnBackPressure: true,
-      tasksFinishedTimeout: 1000
+      tasksFinishedTimeout: 2000
     })
     for (const workerNode of pool.workerNodes) {
       expect(workerNode.tasksQueueBackPressureSize).toBe(
@@ -696,14 +696,14 @@ describe('Abstract pool test suite', () => {
       size: 2,
       taskStealing: false,
       tasksStealingOnBackPressure: false,
-      tasksFinishedTimeout: 2000
+      tasksFinishedTimeout: 3000
     })
     expect(pool.opts.tasksQueueOptions).toStrictEqual({
       concurrency: 2,
       size: 2,
       taskStealing: false,
       tasksStealingOnBackPressure: false,
-      tasksFinishedTimeout: 2000
+      tasksFinishedTimeout: 3000
     })
     for (const workerNode of pool.workerNodes) {
       expect(workerNode.tasksQueueBackPressureSize).toBe(
@@ -720,7 +720,7 @@ describe('Abstract pool test suite', () => {
       size: Math.pow(numberOfWorkers, 2),
       taskStealing: true,
       tasksStealingOnBackPressure: true,
-      tasksFinishedTimeout: 1000
+      tasksFinishedTimeout: 2000
     })
     for (const workerNode of pool.workerNodes) {
       expect(workerNode.tasksQueueBackPressureSize).toBe(
index 8c0a2b6ccf2f0502b915f985512a1624b1c730e0..adff47d9ba9781687a9fb89daa31dea7841fa8ca 100644 (file)
@@ -20,7 +20,7 @@ describe('Pool utils test suite', () => {
       size: Math.pow(poolMaxSize, 2),
       taskStealing: true,
       tasksStealingOnBackPressure: true,
-      tasksFinishedTimeout: 1000
+      tasksFinishedTimeout: 2000
     })
   })