From: Jérôme Benoit Date: Tue, 13 Aug 2024 19:20:45 +0000 (+0200) Subject: feat: reenable tasks stealing under back pressure by default X-Git-Tag: v4.2.0~1 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=f09b195471d82466f32dfbc3c3751202d4ea2f9a;p=poolifier.git feat: reenable tasks stealing under back pressure by default Signed-off-by: Jérôme Benoit --- diff --git a/docs/api.md b/docs/api.md index 580dfd2b..113d4c12 100644 --- a/docs/api.md +++ b/docs/api.md @@ -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. diff --git a/src/pools/pool.ts b/src/pools/pool.ts index 42478ef3..416d6961 100644 --- a/src/pools/pool.ts +++ b/src/pools/pool.ts @@ -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 /** diff --git a/src/pools/utils.ts b/src/pools/utils.ts index aefce74a..7b3c21fa 100644 --- a/src/pools/utils.ts +++ b/src/pools/utils.ts @@ -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, } diff --git a/tests/pools/abstract-pool.test.mjs b/tests/pools/abstract-pool.test.mjs index 375d9653..04c87246 100644 --- a/tests/pools/abstract-pool.test.mjs +++ b/tests/pools/abstract-pool.test.mjs @@ -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, }) diff --git a/tests/pools/utils.test.mjs b/tests/pools/utils.test.mjs index e79294a2..b2265b03 100644 --- a/tests/pools/utils.test.mjs +++ b/tests/pools/utils.test.mjs @@ -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, })