3 All notable changes to this project will be documented in this file.
5 The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6 and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
12 - Disable publication on GitHub packages registry on release until authentication issue is fixed.
16 - Add `startWorkers` to pool options to whether start the minimum number of workers at pool creation or not.
17 - Add `taskStealing` and `tasksStealingOnPressure` to tasks queue options to whether enable task stealing or not and whether enable tasks stealing on back pressure or not.
18 - Continuous internal benchmarking: https://poolifier.github.io/benchmark-results/dev/bench.
20 ## [2.6.44] - 2023-09-08
24 - Use a dedicated PAT to publish on GitHub packages registry.
28 - Publish on GitHub packages registry on release.
32 - Switch from rome to biome: [PR #1128](https://github.com/poolifier/poolifier/pull/1128).
34 ## [2.6.43] - 2023-09-08
38 - Publish on GitHub packages registry on release.
42 - Switch from rome to biome: [PR #1128](https://github.com/poolifier/poolifier/pull/1128).
44 ## [2.6.42] - 2023-09-06
48 - Optimize hot code paths implementation: avoid unnecessary branching, add and use optimized helpers (min, max), use reduce() array helper, ...
50 ## [2.6.41] - 2023-09-03
54 - Optimize worker choice strategies implementation.
56 ## [2.6.40] - 2023-09-01
60 - Do not pre-choose in WRR worker choice strategy to avoid bias.
61 - Avoid array out of bound in worker choice strategies after worker node removal.
63 ## [2.6.39] - 2023-08-30
67 - Fix race condition in worker choice strategies at worker node info querying while not yet initialized.
69 ## [2.6.38] - 2023-08-30
73 - Bundle typescript types declaration into one file.
77 - Improve interleaved weighted round robin worker choice strategy implementation.
79 ## [2.6.37] - 2023-08-28
83 - Ensure unused worker usage statistics are deleted at runtime.
87 - Rename worker choice strategy options `choiceRetries` to `retries`.
88 - Avoid unnecessary branching in worker choice strategies.
90 ## [2.6.36] - 2023-08-27
94 - Fix pool `execute()` arguments check.
98 - Make continuous tasks stealing algorithm less aggressive.
99 - Fine tune tasks stealing algorithm under back pressure.
101 ## [2.6.35] - 2023-08-25
105 - Don't account worker usage statistics for tasks that have failed.
106 - Fix pool information runtime and wait time median computation.
110 - Update simple moving average implementation to use a circular buffer.
111 - Update simple moving median implementation to use a circular buffer.
112 - Account for stolen tasks in worker usage statistics and pool information.
116 - Continuous tasks stealing algorithm.
118 ## [2.6.34] - 2023-08-24
122 - Avoid cascading tasks stealing under back pressure.
126 - Add fastpath to queued tasks rescheduling.
128 ## [2.6.33] - 2023-08-24
132 - Fix queued tasks rescheduling.
136 - Rename tasks queue options `queueMaxSize` to `size`.
140 - Task stealing scheduling algorithm if tasks queueing is enabled.
142 ## [2.6.32] - 2023-08-23
146 - Ensure no task can be executed when the pool is destroyed.
150 - Add `queueMaxSize` option to tasks queue options.
151 - Add O(1) deque implementation implemented with doubly linked list and use it for tasks queueing.
152 - Add tasks stealing algorithm when a worker node queue is back pressured if tasks queueing is enabled.
154 ## [2.6.31] - 2023-08-20
158 - Fix worker choice strategy retries mechanism in some edge cases.
162 - Make orthogonal worker choice strategies tasks distribution and created dynamic worker usage.
163 - Remove the experimental status of the `LEAST_ELU` worker choice strategy.
165 ## [2.6.30] - 2023-08-19
169 - Ensure pool event `backPressure` is emitted.
170 - Ensure pool event `full` is emitted only once.
171 - Ensure worker node cannot be instantiated without proper arguments.
173 ## [2.6.29] - 2023-08-18
177 - Fix race condition between ready and task functions worker message handling at startup.
178 - Fix duplicate task function worker usage statistics computation per task function.
179 - Update task function worker usage statistics if and only if there's at least two different task functions.
180 - Fix race condition at task function worker usage executing task computation leading to negative value.
184 - Add back pressure detection on the worker node queue. Event `backPressure` is emitted when all worker node queues are full (worker node queue size >= poolMaxSize^2).
185 - Use back pressure detection in worker choice strategies.
186 - Add worker choice strategies retries mechanism if no worker is eligible.
188 ## [2.6.28] - 2023-08-16
192 - Ensure pool workers are properly initialized.
196 - HTTP server pool examples: express-cluster, express-hybrid.
200 - Remove now useless branching in worker hot code path.
202 ## [2.6.27] - 2023-08-15
206 - Add `KillHandler` type definition to exported types.
210 - Add `destroy` event to pool API.
212 ## [2.6.26] - 2023-08-15
216 - Add kill handler to worker options allowing to execute custom code when worker is killed.
217 - Add `listTaskFunctions()` method to pool API.
218 - SMTP client pool example: nodemailer.
220 ## [2.6.25] - 2023-08-13
224 - HTTP server pool examples: fastify-cluster, fastify-hybrid.
225 - WebSocket server pool examples: ws-cluster, ws-hybrid.
227 ## [2.6.24] - 2023-08-12
231 - Add array of transferable objects to the `execute()` method arguments.
232 - WebSocket server pool examples: ws-worker_threads.
234 ## [2.6.23] - 2023-08-11
238 - Fix pool busyness semantic when tasks queueing is enabled: the pool is busy when the number of executing tasks on each worker has reached the maximum tasks concurrency per worker.
242 - HTTP client pool examples: fetch, node-fetch and axios with multiple task functions.
243 - HTTP server pool examples: express-worker_threads, fastify-worker_threads.
245 ## [2.6.22] - 2023-08-10
249 - Add missing `types` field to package.json `exports`.
253 - Structure markdown documentation (PR #811).
255 ## [2.6.21] - 2023-08-03
259 - Improve code documentation.
260 - Code refactoring and cleanup for better maintainability and readability.
262 ## [2.6.20] - 2023-07-21
266 - Fix queued tasks redistribution on error task execution starvation.
267 - Ensure tasks queueing per worker condition is untangled from the pool busyness semantic.
271 - Drastically reduce lookups by worker in the worker nodes.
273 ## [2.6.19] - 2023-07-20
277 - Dedicated internal communication channel for worker_threads pools.
279 ## [2.6.18] - 2023-07-19
283 - Code refactoring and cleanup for better maintainability and readability. Bundle size is a bit smaller.
285 ## [2.6.17] - 2023-07-16
289 - Add `listTaskFunctions()` method to worker API.
291 ## [2.6.16] - 2023-07-12
295 - Fix pool startup detection.
296 - Fix worker task functions handling.
298 ## [2.6.15] - 2023-07-11
302 - Take into account worker node readiness in worker choice strategies.
304 ## [2.6.14] - 2023-07-10
308 - Fix task function statistics tracking.
310 ## [2.6.13] - 2023-07-10
314 - Add per task function statistics tracking.
315 - Add public methods to manipulate the worker task functions at runtime.
317 ## [2.6.12] - 2023-07-09
321 - Workaround import issue with `node:os` module in node 16.x.x.
323 ## [2.6.11] - 2023-07-09
327 - Fix pool readiness semantic.
329 ## [2.6.10] - 2023-07-08
333 - Ensure workers are not recreated on error at pool startup.
337 - Add `ready` and `strategy` fields to pool information.
338 - Add pool event `ready` to notify when the number of workers created in the pool has reached the maximum size expected and are ready.
339 - Add dynamic pool sizing checks.
341 ## [2.6.9] - 2023-07-07
345 - Recreate the right worker type on uncaught exception.
349 - Add minimum and maximum to internal measurement statistics.
350 - Add `runTime` and `waitTime` to pool information.
351 - Check worker inactive time only on dynamic worker.
353 ## [2.6.8] - 2023-07-03
357 - Brown paper bag release to fix version handling in pool information.
359 ## [2.6.7] - 2023-07-03
363 - Ensure worker queued tasks at error are reassigned to other pool workers.
367 - Add pool `utilization` ratio to pool information.
368 - Add `version` to pool information.
369 - Add worker information to worker nodes.
371 ## [2.6.6] - 2023-07-01
375 - Add safe helper `availableParallelism()` to help sizing the pool.
379 - Ensure message handler is only registered in worker.
381 ## [2.6.5] - 2023-06-27
385 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
389 - Artificial version bump to 2.6.5 to workaround publication issue.
390 - Ensure cluster pool `destroy()` gracefully shutdowns worker's server.
391 - Ensure pool event is emitted before task error promise rejection.
392 - Fix queued tasks count computation.
396 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
398 ## [2.6.4] - 2023-06-27
402 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
406 - Ensure cluster pool `destroy()` gracefully shutdowns worker's server.
407 - Ensure pool event is emitted before task error promise rejection.
408 - Fix queued tasks count computation.
412 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
414 ## [2.6.3] - 2023-06-19
418 - Ensure no tasks are queued when trying to soft kill a dynamic worker.
419 - Update strategies internals after statistics computation.
423 - Optimize O(1) queue implementation.
425 ## [2.6.2] - 2023-06-12
429 - Fix new worker use after creation in dynamic pool given the current worker choice strategy.
431 ## [2.6.1] - 2023-06-10
435 - Add worker choice strategy documentation: [README.md](./docs/worker-choice-strategies.md).
439 - Fix average statistics computation: ensure failed tasks are not accounted.
441 ## [2.6.0] - 2023-06-09
445 - Add `LEAST_ELU` worker choice strategy (experimental).
446 - Add tasks ELU instead of runtime support to `FAIR_SHARE` worker choice strategy.
450 - Refactor pool worker node usage internals.
451 - Breaking change: refactor worker choice strategy statistics requirements: the syntax of the worker choice strategy options has changed.
452 - Breaking change: pool information `info` property object fields have been renamed.
456 - Fix wait time accounting.
457 - Ensure worker choice strategy `LEAST_BUSY` accounts also tasks wait time.
458 - Ensure worker choice strategy `LEAST_USED` accounts also queued tasks.
460 ## [2.5.4] - 2023-06-07
464 - Add Event Loop Utilization (ELU) statistics to worker tasks usage.
468 - Compute statistics at the worker level only if needed.
469 - Add `worker_threads` options to thread pool options.
473 - Make the `LEAST_BUSY` strategy only relies on task runtime.
475 ## [2.5.3] - 2023-06-04
479 - Refine pool information content.
480 - Limit pool internals public exposure.
482 ## [2.5.2] - 2023-06-02
486 - Add `taskError` pool event for task execution error.
487 - Add pool information `info` property to pool.
488 - Emit pool information on `busy` and `full` pool events.
490 ## [2.5.1] - 2023-06-01
494 - Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
495 - Add `error` pool event for uncaught worker error.
497 ## [2.5.0] - 2023-05-31
501 - Switch pool event emitter to `EventEmitterAsyncResource`.
502 - Add tasks wait time accounting in per worker tasks usage.
503 - Add interleaved weighted round robin `INTERLEAVED_WEIGHTED_ROUND_ROBIN` worker choice strategy (experimental).
507 - Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
509 ## [2.4.14] - 2023-05-09
513 - Ensure no undefined task runtime can land in the tasks history.
514 - Fix median computation implementation once again.
518 - Unit tests for median and queue implementations.
520 ## [2.4.13] - 2023-05-08
524 - Fix worker choice strategy options validation.
525 - Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
527 ## [2.4.12] - 2023-05-06
531 - Support multiple task functions per worker.
532 - Add custom worker weights support to worker choice strategies options.
536 - Use O(1) queue implementation for tasks queueing.
540 - Fix median computation implementation.
541 - Fix fair share worker choice strategy internals update.
543 ## [2.4.11] - 2023-04-23
547 - Optimize free worker finding in worker choice strategies.
549 ## [2.4.10] - 2023-04-15
553 - Fix typescript type definition for task function: ensure the input data is optional.
554 - Fix typescript type definition for pool execute(): ensure the input data is optional.
556 ## [2.4.9] - 2023-04-15
560 - Add tasks queue enablement runtime setter to pool.
561 - Add tasks queue options runtime setter to pool.
562 - Add worker choice strategy options runtime setter to pool.
566 - Remove the tasks queuing experimental status.
570 - Fix task function type definition and validation.
571 - Fix worker choice strategy options handling.
573 ## [2.4.8] - 2023-04-12
577 - Fix message between main worker and worker type definition for tasks.
578 - Fix code documentation.
580 ## [2.4.7] - 2023-04-11
584 - Add worker tasks queue options to pool options.
588 - Fix missing documentation.
590 ## [2.4.6] - 2023-04-10
594 - Ensure one task at a time is executed per worker with tasks queueing enabled.
595 - Properly count worker executing tasks with tasks queueing enabled.
597 ## [2.4.5] - 2023-04-09
601 - Use monotonic high resolution timer for worker tasks runtime.
602 - Add worker tasks median runtime to statistics.
603 - Add worker tasks queue (experimental).
605 ## [2.4.4] - 2023-04-07
609 - Add `PoolEvents` enumeration and `PoolEvent` type.
613 - Destroy worker only on alive check.
615 ## [2.4.3] - 2023-04-07
619 - Fix typedoc generation with inheritance.
621 ## [2.4.2] - 2023-04-06
625 - Add `full` event to dynamic pool.
626 - Keep worker choice strategy in memory for conditional reuse.
630 - Fix possible negative worker key at worker removal in worker choice strategies.
632 ## [2.4.1] - 2023-04-05
636 - Optimize worker choice strategy for dynamic pool.
640 - Ensure dynamic pool does not alter worker choice strategy expected behavior.
642 ## [2.4.0] - 2023-04-04
646 - Add `LESS_BUSY` worker choice strategy.
650 - Optimize worker storage in pool.
651 - Optimize worker alive status check.
652 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
653 - Optimize `LESS_USED` worker choice strategy.
654 - Update benchmark versus external threads pools.
655 - Optimize tasks usage statistics requirements for worker choice strategy.
659 - Ensure trimmable characters are checked at pool initialization.
660 - Fix message id integer overflow.
661 - Fix pool worker removal in worker choice strategy internals.
662 - Fix package publication with pnpm.
664 ## [2.4.0-3] - 2023-04-04
668 - Add `LESS_BUSY` worker choice strategy.
672 - Optimize worker storage in pool.
673 - Optimize worker alive status check.
674 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
675 - Optimize `LESS_USED` worker choice strategy.
676 - Update benchmark versus external threads pools.
680 - Ensure trimmable characters are checked at pool initialization.
681 - Fix message id integer overflow.
682 - Fix pool worker removal in worker choice strategy internals.
683 - Fix package publication with pnpm.
685 ## [2.4.0-2] - 2023-04-03
689 - Add `LESS_BUSY` worker choice strategy.
693 - Optimize worker storage in pool.
694 - Optimize worker alive status check.
695 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
696 - Optimize `LESS_USED` worker choice strategy.
700 - Ensure trimmable characters are checked at pool initialization.
701 - Fix message id integer overflow.
702 - Fix pool worker removal in worker choice strategy internals.
703 - Fix package publication with pnpm.
705 ## [2.4.0-1] - 2023-04-03
709 - Add `LESS_BUSY` worker choice strategy.
713 - Optimize worker storage in pool.
714 - Optimize worker alive status check.
715 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
716 - Optimize `LESS_USED` worker choice strategy.
720 - Ensure trimmable characters are checked at pool initialization.
721 - Fix message id integer overflow.
722 - Fix pool worker removal in worker choice strategy internals.
724 ## [2.4.0-0] - 2023-04-03
728 - Add `LESS_BUSY` worker choice strategy.
732 - Optimize worker storage in pool.
733 - Optimize worker alive status check.
734 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
735 - Optimize `LESS_USED` worker choice strategy.
739 - Ensure trimmable characters are checked at pool initialization.
740 - Fix message id integer overflow.
741 - Fix pool worker removal in worker choice strategy internals.
743 ## [2.3.10] - 2023-03-18
747 - Fix package.json `exports` syntax for ESM and CommonJS.
751 - Permit SemVer pre-release publication.
753 ## [2.3.10-2] - 2023-03-18
757 - Fix package.json `exports` syntax for ESM and CommonJS.
759 ## [2.3.10-1] - 2023-03-18
763 - Permit SemVer pre-release publication.
765 ## [2.3.10-0] - 2023-03-18
769 - Fix package.json `exports` syntax for ESM and CommonJS.
771 ## [2.3.9] - 2023-03-18
775 - Introduce ESM module support along with CommonJS one.
779 - Fix brown paper bag bug referencing the same object literal.
781 ## [2.3.8] - 2023-03-18
785 - Switch internal benchmarking code to benny.
786 - Switch to TypeScript 5.x.x.
787 - Switch rollup bundler plugins to core ones.
788 - Switch to TSDoc syntax.
789 - Enforce conventional commits.
793 - Fix random integer generator.
794 - Fix worker choice strategy pool type identification at initialization.
796 ## [2.3.7] - 2022-10-23
800 - Switch to open collective FOSS project funding platform.
801 - Switch to ts-standard linter configuration on TypeScript code.
805 - Fixed missing async on pool execute method.
806 - Fixed typing in TypeScript example.
807 - Fixed types in unit tests.
809 ## [2.3.6] - 2022-10-22
813 - Cleanup pool attributes and methods.
814 - Refine error types thrown.
818 - Fix continuous integration build on windows.
819 - Fix code coverage reporting by using c8 instead of nyc.
821 ## [2.3.5] - 2022-10-21
825 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
826 - Optimize tasks usage lookup implementation.
830 - Fix missed pool event emitter type export.
831 - Fix typedoc documentation generation.
833 ## [2.3.4] - 2022-10-17
837 - Fully automate release process with release-it.
841 - Optimize fair share task scheduling algorithm implementation.
842 - Update benchmark versus external pools results with latest version.
844 ## [2.3.3] - 2022-10-15
848 - Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
850 ## [2.3.2] - 2022-10-14
854 - Optimize fair share worker selection strategy implementation.
858 - Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
860 ## [2.3.1] - 2022-10-13
864 - Pool worker choice strategies:
865 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
866 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
868 ## [2.2.2] - 2022-10-09
872 - Fixed `README.md` file.
874 ## [2.2.1] - 2022-10-08
878 - Dynamic worker choice strategy change at runtime.
880 ## [2.2.0] - 2022-01-05
884 - Support only Node.js version 16.x.x for cluster pool: upstream cluster API have changed on that version.
886 ## [2.1.0] - 2021-08-29
890 - Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
894 - `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
895 - `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
896 - `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
897 - `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
899 ## [2.0.2] - 2021-05-12
903 - Fix `busy` event emission on fixed pool type
905 ## [2.0.1] - 2021-03-16
909 - Check if pool options are properly set.
910 - `busy` event is emitted on all pool types.
912 ## [2.0.0] - 2021-03-01
916 - Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
920 - `FullPool` event is now renamed to `busy`.
921 - `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
922 _Find more details on our JSDoc._
924 - `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
926 - We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
928 ### Pool options types declaration merge
930 `FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
932 #### New `export` strategy
936 const DynamicThreadPool = require('poolifier/lib/dynamic')
938 const { DynamicThreadPool } = require('poolifier/lib/dynamic')
941 But you should always prefer just using
944 const { DynamicThreadPool } = require('poolifier')
947 #### New type definitions for input data and response
949 For cluster worker and worker-thread pools, you can now only send and receive structured-cloneable data.
950 _This is not a limitation by poolifier but Node.js._
952 #### Public property replacements
954 `numWorkers` property is now `numberOfWorkers`
956 #### Internal (protected) properties and methods renaming
958 These properties are not intended for end users
960 - `id` => `nextMessageId`
962 These methods are not intended for end users
964 - `_chooseWorker` => `chooseWorker`
965 - `_newWorker` => `createWorker`
966 - `_execute` => `internalExecute`
967 - `_chooseWorker` => `chooseWorker`
968 - `_checkAlive` => `checkAlive`
970 - `_runAsync` => `runAsync`
972 ## [1.1.0] - 2020-05-21
976 - ThreadWorker support async functions as option
977 - Various external library patches
979 ## [1.0.0] - 2020-01-24
983 - FixedThreadPool implementation
984 - DynamicThreadPool implementation
985 - WorkerThread implementation to improve developer experience