From 568d0075825104b5a5ccc38dea2beeb55b55f3d0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 18 Dec 2023 17:39:40 +0100 Subject: [PATCH] refactor: set tasksFinishedTimeout default to 2000ms MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- docs/api.md | 2 +- src/pools/utils.ts | 2 +- tests/pools/abstract-pool.test.mjs | 14 +++++++------- tests/pools/utils.test.mjs | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/api.md b/docs/api.md index 968d6ab5..65d96e57 100644 --- a/docs/api.md +++ b/docs/api.md @@ -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. diff --git a/src/pools/utils.ts b/src/pools/utils.ts index a6a52f0c..3b98fbdc 100644 --- a/src/pools/utils.ts +++ b/src/pools/utils.ts @@ -29,7 +29,7 @@ export const getDefaultTasksQueueOptions = ( concurrency: 1, taskStealing: true, tasksStealingOnBackPressure: true, - tasksFinishedTimeout: 1000 + tasksFinishedTimeout: 2000 } } diff --git a/tests/pools/abstract-pool.test.mjs b/tests/pools/abstract-pool.test.mjs index cc4b0f38..1b80aa4c 100644 --- a/tests/pools/abstract-pool.test.mjs +++ b/tests/pools/abstract-pool.test.mjs @@ -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( diff --git a/tests/pools/utils.test.mjs b/tests/pools/utils.test.mjs index 8c0a2b6c..adff47d9 100644 --- a/tests/pools/utils.test.mjs +++ b/tests/pools/utils.test.mjs @@ -20,7 +20,7 @@ describe('Pool utils test suite', () => { size: Math.pow(poolMaxSize, 2), taskStealing: true, tasksStealingOnBackPressure: true, - tasksFinishedTimeout: 1000 + tasksFinishedTimeout: 2000 }) }) -- 2.34.1