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).
10 ## [2.7.1] - 2023-09-20
14 - Ensure worker message listener used one time are removed after usage.
16 ## [2.7.0] - 2023-09-19
20 - Fix task stealing related tasks queue options handling at runtime.
24 - Rename `listTaskFunctions()` to `listTaskFunctionNames()` in pool and worker API.
28 - Add `hasTaskFunction()`, `addTaskFunction()`, `removeTaskFunction()`, `setDefaultTaskFunction()` methods to pool API: [PR #1148](https://github.com/poolifier/poolifier/pull/1148).
29 - Stricter worker constructor arguments validation.
31 ## [2.6.45] - 2023-09-17
35 - Disable publication on GitHub packages registry on release until authentication issue is fixed.
39 - Add `startWorkers` to pool options to whether start the minimum number of workers at pool creation or not.
40 - Add `start()` method to pool API to start the minimum number of workers.
41 - 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.
42 - Continuous internal benchmarking: https://poolifier.github.io/benchmark-results/dev/bench.
44 ## [2.6.44] - 2023-09-08
48 - Use a dedicated PAT to publish on GitHub packages registry.
52 - Publish on GitHub packages registry on release.
56 - Switch from rome to biome: [PR #1128](https://github.com/poolifier/poolifier/pull/1128).
58 ## [2.6.43] - 2023-09-08
62 - Publish on GitHub packages registry on release.
66 - Switch from rome to biome: [PR #1128](https://github.com/poolifier/poolifier/pull/1128).
68 ## [2.6.42] - 2023-09-06
72 - Optimize hot code paths implementation: avoid unnecessary branching, add and use optimized helpers (min, max), use reduce() array helper, ...
74 ## [2.6.41] - 2023-09-03
78 - Optimize worker choice strategies implementation.
80 ## [2.6.40] - 2023-09-01
84 - Do not pre-choose in WRR worker choice strategy to avoid bias.
85 - Avoid array out of bound in worker choice strategies after worker node removal.
87 ## [2.6.39] - 2023-08-30
91 - Fix race condition in worker choice strategies at worker node info querying while not yet initialized.
93 ## [2.6.38] - 2023-08-30
97 - Bundle typescript types declaration into one file.
101 - Improve interleaved weighted round robin worker choice strategy implementation.
103 ## [2.6.37] - 2023-08-28
107 - Ensure unused worker usage statistics are deleted at runtime.
111 - Rename worker choice strategy options `choiceRetries` to `retries`.
112 - Avoid unnecessary branching in worker choice strategies.
114 ## [2.6.36] - 2023-08-27
118 - Fix pool `execute()` arguments check.
122 - Make continuous tasks stealing algorithm less aggressive.
123 - Fine tune tasks stealing algorithm under back pressure.
125 ## [2.6.35] - 2023-08-25
129 - Don't account worker usage statistics for tasks that have failed.
130 - Fix pool information runtime and wait time median computation.
134 - Update simple moving average implementation to use a circular buffer.
135 - Update simple moving median implementation to use a circular buffer.
136 - Account for stolen tasks in worker usage statistics and pool information.
140 - Continuous tasks stealing algorithm.
142 ## [2.6.34] - 2023-08-24
146 - Avoid cascading tasks stealing under back pressure.
150 - Add fastpath to queued tasks rescheduling.
152 ## [2.6.33] - 2023-08-24
156 - Fix queued tasks rescheduling.
160 - Rename tasks queue options `queueMaxSize` to `size`.
164 - Task stealing scheduling algorithm if tasks queueing is enabled.
166 ## [2.6.32] - 2023-08-23
170 - Ensure no task can be executed when the pool is destroyed.
174 - Add `queueMaxSize` option to tasks queue options.
175 - Add O(1) deque implementation implemented with doubly linked list and use it for tasks queueing.
176 - Add tasks stealing algorithm when a worker node queue is back pressured if tasks queueing is enabled.
178 ## [2.6.31] - 2023-08-20
182 - Fix worker choice strategy retries mechanism in some edge cases.
186 - Make orthogonal worker choice strategies tasks distribution and created dynamic worker usage.
187 - Remove the experimental status of the `LEAST_ELU` worker choice strategy.
189 ## [2.6.30] - 2023-08-19
193 - Ensure pool event `backPressure` is emitted.
194 - Ensure pool event `full` is emitted only once.
195 - Ensure worker node cannot be instantiated without proper arguments.
197 ## [2.6.29] - 2023-08-18
201 - Fix race condition between ready and task functions worker message handling at startup.
202 - Fix duplicate task function worker usage statistics computation per task function.
203 - Update task function worker usage statistics if and only if there's at least two different task functions.
204 - Fix race condition at task function worker usage executing task computation leading to negative value.
208 - 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).
209 - Use back pressure detection in worker choice strategies.
210 - Add worker choice strategies retries mechanism if no worker is eligible.
212 ## [2.6.28] - 2023-08-16
216 - Ensure pool workers are properly initialized.
220 - HTTP server pool examples: express-cluster, express-hybrid.
224 - Remove now useless branching in worker hot code path.
226 ## [2.6.27] - 2023-08-15
230 - Add `KillHandler` type definition to exported types.
234 - Add `destroy` event to pool API.
236 ## [2.6.26] - 2023-08-15
240 - Add kill handler to worker options allowing to execute custom code when worker is killed.
241 - Add `listTaskFunctions()` method to pool API.
242 - SMTP client pool example: nodemailer.
244 ## [2.6.25] - 2023-08-13
248 - HTTP server pool examples: fastify-cluster, fastify-hybrid.
249 - WebSocket server pool examples: ws-cluster, ws-hybrid.
251 ## [2.6.24] - 2023-08-12
255 - Add array of transferable objects to the `execute()` method arguments.
256 - WebSocket server pool examples: ws-worker_threads.
258 ## [2.6.23] - 2023-08-11
262 - 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.
266 - HTTP client pool examples: fetch, node-fetch and axios with multiple task functions.
267 - HTTP server pool examples: express-worker_threads, fastify-worker_threads.
269 ## [2.6.22] - 2023-08-10
273 - Add missing `types` field to package.json `exports`.
277 - Structure markdown documentation (PR #811).
279 ## [2.6.21] - 2023-08-03
283 - Improve code documentation.
284 - Code refactoring and cleanup for better maintainability and readability.
286 ## [2.6.20] - 2023-07-21
290 - Fix queued tasks redistribution on error task execution starvation.
291 - Ensure tasks queueing per worker condition is untangled from the pool busyness semantic.
295 - Drastically reduce lookups by worker in the worker nodes.
297 ## [2.6.19] - 2023-07-20
301 - Dedicated internal communication channel for worker_threads pools.
303 ## [2.6.18] - 2023-07-19
307 - Code refactoring and cleanup for better maintainability and readability. Bundle size is a bit smaller.
309 ## [2.6.17] - 2023-07-16
313 - Add `listTaskFunctions()` method to worker API.
315 ## [2.6.16] - 2023-07-12
319 - Fix pool startup detection.
320 - Fix worker task functions handling.
322 ## [2.6.15] - 2023-07-11
326 - Take into account worker node readiness in worker choice strategies.
328 ## [2.6.14] - 2023-07-10
332 - Fix task function statistics tracking.
334 ## [2.6.13] - 2023-07-10
338 - Add per task function statistics tracking.
339 - Add public methods to manipulate the worker task functions at runtime.
341 ## [2.6.12] - 2023-07-09
345 - Workaround import issue with `node:os` module in node 16.x.x.
347 ## [2.6.11] - 2023-07-09
351 - Fix pool readiness semantic.
353 ## [2.6.10] - 2023-07-08
357 - Ensure workers are not recreated on error at pool startup.
361 - Add `ready` and `strategy` fields to pool information.
362 - Add pool event `ready` to notify when the number of workers created in the pool has reached the maximum size expected and are ready.
363 - Add dynamic pool sizing checks.
365 ## [2.6.9] - 2023-07-07
369 - Recreate the right worker type on uncaught exception.
373 - Add minimum and maximum to internal measurement statistics.
374 - Add `runTime` and `waitTime` to pool information.
375 - Check worker inactive time only on dynamic worker.
377 ## [2.6.8] - 2023-07-03
381 - Brown paper bag release to fix version handling in pool information.
383 ## [2.6.7] - 2023-07-03
387 - Ensure worker queued tasks at error are reassigned to other pool workers.
391 - Add pool `utilization` ratio to pool information.
392 - Add `version` to pool information.
393 - Add worker information to worker nodes.
395 ## [2.6.6] - 2023-07-01
399 - Add safe helper `availableParallelism()` to help sizing the pool.
403 - Ensure message handler is only registered in worker.
405 ## [2.6.5] - 2023-06-27
409 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
413 - Artificial version bump to 2.6.5 to workaround publication issue.
414 - Ensure cluster pool `destroy()` gracefully shutdowns worker's server.
415 - Ensure pool event is emitted before task error promise rejection.
416 - Fix queued tasks count computation.
420 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
422 ## [2.6.4] - 2023-06-27
426 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
430 - Ensure cluster pool `destroy()` gracefully shutdowns worker's server.
431 - Ensure pool event is emitted before task error promise rejection.
432 - Fix queued tasks count computation.
436 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
438 ## [2.6.3] - 2023-06-19
442 - Ensure no tasks are queued when trying to soft kill a dynamic worker.
443 - Update strategies internals after statistics computation.
447 - Optimize O(1) queue implementation.
449 ## [2.6.2] - 2023-06-12
453 - Fix new worker use after creation in dynamic pool given the current worker choice strategy.
455 ## [2.6.1] - 2023-06-10
459 - Add worker choice strategy documentation: [README.md](./docs/worker-choice-strategies.md).
463 - Fix average statistics computation: ensure failed tasks are not accounted.
465 ## [2.6.0] - 2023-06-09
469 - Add `LEAST_ELU` worker choice strategy (experimental).
470 - Add tasks ELU instead of runtime support to `FAIR_SHARE` worker choice strategy.
474 - Refactor pool worker node usage internals.
475 - Breaking change: refactor worker choice strategy statistics requirements: the syntax of the worker choice strategy options has changed.
476 - Breaking change: pool information `info` property object fields have been renamed.
480 - Fix wait time accounting.
481 - Ensure worker choice strategy `LEAST_BUSY` accounts also tasks wait time.
482 - Ensure worker choice strategy `LEAST_USED` accounts also queued tasks.
484 ## [2.5.4] - 2023-06-07
488 - Add Event Loop Utilization (ELU) statistics to worker tasks usage.
492 - Compute statistics at the worker level only if needed.
493 - Add `worker_threads` options to thread pool options.
497 - Make the `LEAST_BUSY` strategy only relies on task runtime.
499 ## [2.5.3] - 2023-06-04
503 - Refine pool information content.
504 - Limit pool internals public exposure.
506 ## [2.5.2] - 2023-06-02
510 - Add `taskError` pool event for task execution error.
511 - Add pool information `info` property to pool.
512 - Emit pool information on `busy` and `full` pool events.
514 ## [2.5.1] - 2023-06-01
518 - Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
519 - Add `error` pool event for uncaught worker error.
521 ## [2.5.0] - 2023-05-31
525 - Switch pool event emitter to `EventEmitterAsyncResource`.
526 - Add tasks wait time accounting in per worker tasks usage.
527 - Add interleaved weighted round robin `INTERLEAVED_WEIGHTED_ROUND_ROBIN` worker choice strategy (experimental).
531 - Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
533 ## [2.4.14] - 2023-05-09
537 - Ensure no undefined task runtime can land in the tasks history.
538 - Fix median computation implementation once again.
542 - Unit tests for median and queue implementations.
544 ## [2.4.13] - 2023-05-08
548 - Fix worker choice strategy options validation.
549 - Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
551 ## [2.4.12] - 2023-05-06
555 - Support multiple task functions per worker.
556 - Add custom worker weights support to worker choice strategies options.
560 - Use O(1) queue implementation for tasks queueing.
564 - Fix median computation implementation.
565 - Fix fair share worker choice strategy internals update.
567 ## [2.4.11] - 2023-04-23
571 - Optimize free worker finding in worker choice strategies.
573 ## [2.4.10] - 2023-04-15
577 - Fix typescript type definition for task function: ensure the input data is optional.
578 - Fix typescript type definition for pool execute(): ensure the input data is optional.
580 ## [2.4.9] - 2023-04-15
584 - Add tasks queue enablement runtime setter to pool.
585 - Add tasks queue options runtime setter to pool.
586 - Add worker choice strategy options runtime setter to pool.
590 - Remove the tasks queuing experimental status.
594 - Fix task function type definition and validation.
595 - Fix worker choice strategy options handling.
597 ## [2.4.8] - 2023-04-12
601 - Fix message between main worker and worker type definition for tasks.
602 - Fix code documentation.
604 ## [2.4.7] - 2023-04-11
608 - Add worker tasks queue options to pool options.
612 - Fix missing documentation.
614 ## [2.4.6] - 2023-04-10
618 - Ensure one task at a time is executed per worker with tasks queueing enabled.
619 - Properly count worker executing tasks with tasks queueing enabled.
621 ## [2.4.5] - 2023-04-09
625 - Use monotonic high resolution timer for worker tasks runtime.
626 - Add worker tasks median runtime to statistics.
627 - Add worker tasks queue (experimental).
629 ## [2.4.4] - 2023-04-07
633 - Add `PoolEvents` enumeration and `PoolEvent` type.
637 - Destroy worker only on alive check.
639 ## [2.4.3] - 2023-04-07
643 - Fix typedoc generation with inheritance.
645 ## [2.4.2] - 2023-04-06
649 - Add `full` event to dynamic pool.
650 - Keep worker choice strategy in memory for conditional reuse.
654 - Fix possible negative worker key at worker removal in worker choice strategies.
656 ## [2.4.1] - 2023-04-05
660 - Optimize worker choice strategy for dynamic pool.
664 - Ensure dynamic pool does not alter worker choice strategy expected behavior.
666 ## [2.4.0] - 2023-04-04
670 - Add `LESS_BUSY` worker choice strategy.
674 - Optimize worker storage in pool.
675 - Optimize worker alive status check.
676 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
677 - Optimize `LESS_USED` worker choice strategy.
678 - Update benchmark versus external threads pools.
679 - Optimize tasks usage statistics requirements for worker choice strategy.
683 - Ensure trimmable characters are checked at pool initialization.
684 - Fix message id integer overflow.
685 - Fix pool worker removal in worker choice strategy internals.
686 - Fix package publication with pnpm.
688 ## [2.4.0-3] - 2023-04-04
692 - Add `LESS_BUSY` worker choice strategy.
696 - Optimize worker storage in pool.
697 - Optimize worker alive status check.
698 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
699 - Optimize `LESS_USED` worker choice strategy.
700 - Update benchmark versus external threads pools.
704 - Ensure trimmable characters are checked at pool initialization.
705 - Fix message id integer overflow.
706 - Fix pool worker removal in worker choice strategy internals.
707 - Fix package publication with pnpm.
709 ## [2.4.0-2] - 2023-04-03
713 - Add `LESS_BUSY` worker choice strategy.
717 - Optimize worker storage in pool.
718 - Optimize worker alive status check.
719 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
720 - Optimize `LESS_USED` worker choice strategy.
724 - Ensure trimmable characters are checked at pool initialization.
725 - Fix message id integer overflow.
726 - Fix pool worker removal in worker choice strategy internals.
727 - Fix package publication with pnpm.
729 ## [2.4.0-1] - 2023-04-03
733 - Add `LESS_BUSY` worker choice strategy.
737 - Optimize worker storage in pool.
738 - Optimize worker alive status check.
739 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
740 - Optimize `LESS_USED` worker choice strategy.
744 - Ensure trimmable characters are checked at pool initialization.
745 - Fix message id integer overflow.
746 - Fix pool worker removal in worker choice strategy internals.
748 ## [2.4.0-0] - 2023-04-03
752 - Add `LESS_BUSY` worker choice strategy.
756 - Optimize worker storage in pool.
757 - Optimize worker alive status check.
758 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
759 - Optimize `LESS_USED` worker choice strategy.
763 - Ensure trimmable characters are checked at pool initialization.
764 - Fix message id integer overflow.
765 - Fix pool worker removal in worker choice strategy internals.
767 ## [2.3.10] - 2023-03-18
771 - Fix package.json `exports` syntax for ESM and CommonJS.
775 - Permit SemVer pre-release publication.
777 ## [2.3.10-2] - 2023-03-18
781 - Fix package.json `exports` syntax for ESM and CommonJS.
783 ## [2.3.10-1] - 2023-03-18
787 - Permit SemVer pre-release publication.
789 ## [2.3.10-0] - 2023-03-18
793 - Fix package.json `exports` syntax for ESM and CommonJS.
795 ## [2.3.9] - 2023-03-18
799 - Introduce ESM module support along with CommonJS one.
803 - Fix brown paper bag bug referencing the same object literal.
805 ## [2.3.8] - 2023-03-18
809 - Switch internal benchmarking code to benny.
810 - Switch to TypeScript 5.x.x.
811 - Switch rollup bundler plugins to core ones.
812 - Switch to TSDoc syntax.
813 - Enforce conventional commits.
817 - Fix random integer generator.
818 - Fix worker choice strategy pool type identification at initialization.
820 ## [2.3.7] - 2022-10-23
824 - Switch to open collective FOSS project funding platform.
825 - Switch to ts-standard linter configuration on TypeScript code.
829 - Fixed missing async on pool execute method.
830 - Fixed typing in TypeScript example.
831 - Fixed types in unit tests.
833 ## [2.3.6] - 2022-10-22
837 - Cleanup pool attributes and methods.
838 - Refine error types thrown.
842 - Fix continuous integration build on windows.
843 - Fix code coverage reporting by using c8 instead of nyc.
845 ## [2.3.5] - 2022-10-21
849 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
850 - Optimize tasks usage lookup implementation.
854 - Fix missed pool event emitter type export.
855 - Fix typedoc documentation generation.
857 ## [2.3.4] - 2022-10-17
861 - Fully automate release process with release-it.
865 - Optimize fair share task scheduling algorithm implementation.
866 - Update benchmark versus external pools results with latest version.
868 ## [2.3.3] - 2022-10-15
872 - Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
874 ## [2.3.2] - 2022-10-14
878 - Optimize fair share worker selection strategy implementation.
882 - Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
884 ## [2.3.1] - 2022-10-13
888 - Pool worker choice strategies:
889 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
890 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
892 ## [2.2.2] - 2022-10-09
896 - Fixed `README.md` file.
898 ## [2.2.1] - 2022-10-08
902 - Dynamic worker choice strategy change at runtime.
904 ## [2.2.0] - 2022-01-05
908 - Support only Node.js version 16.x.x for cluster pool: upstream cluster API have changed on that version.
910 ## [2.1.0] - 2021-08-29
914 - Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
918 - `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
919 - `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
920 - `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
921 - `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
923 ## [2.0.2] - 2021-05-12
927 - Fix `busy` event emission on fixed pool type
929 ## [2.0.1] - 2021-03-16
933 - Check if pool options are properly set.
934 - `busy` event is emitted on all pool types.
936 ## [2.0.0] - 2021-03-01
940 - Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
944 - `FullPool` event is now renamed to `busy`.
945 - `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
946 _Find more details on our JSDoc._
948 - `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
950 - We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
952 ### Pool options types declaration merge
954 `FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
956 #### New `export` strategy
960 const DynamicThreadPool = require('poolifier/lib/dynamic')
962 const { DynamicThreadPool } = require('poolifier/lib/dynamic')
965 But you should always prefer just using
968 const { DynamicThreadPool } = require('poolifier')
971 #### New type definitions for input data and response
973 For cluster worker and worker-thread pools, you can now only send and receive structured-cloneable data.
974 _This is not a limitation by poolifier but Node.js._
976 #### Public property replacements
978 `numWorkers` property is now `numberOfWorkers`
980 #### Internal (protected) properties and methods renaming
982 These properties are not intended for end users
984 - `id` => `nextMessageId`
986 These methods are not intended for end users
988 - `_chooseWorker` => `chooseWorker`
989 - `_newWorker` => `createWorker`
990 - `_execute` => `internalExecute`
991 - `_chooseWorker` => `chooseWorker`
992 - `_checkAlive` => `checkAlive`
994 - `_runAsync` => `runAsync`
996 ## [1.1.0] - 2020-05-21
1000 - ThreadWorker support async functions as option
1001 - Various external library patches
1003 ## [1.0.0] - 2020-01-24
1007 - FixedThreadPool implementation
1008 - DynamicThreadPool implementation
1009 - WorkerThread implementation to improve developer experience