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 - Continuous internal benchmarking.
18 ## [2.6.44] - 2023-09-08
22 - Use a dedicated PAT to publish on GitHub packages registry.
26 - Publish on GitHub packages registry on release.
30 - Switch from rome to biome: [PR #1128](https://github.com/poolifier/poolifier/pull/1128).
32 ## [2.6.43] - 2023-09-08
36 - Publish on GitHub packages registry on release.
40 - Switch from rome to biome: [PR #1128](https://github.com/poolifier/poolifier/pull/1128).
42 ## [2.6.42] - 2023-09-06
46 - Optimize hot code paths implementation: avoid unnecessary branching, add and use optimized helpers (min, max), use reduce() array helper, ...
48 ## [2.6.41] - 2023-09-03
52 - Optimize worker choice strategies implementation.
54 ## [2.6.40] - 2023-09-01
58 - Do not pre-choose in WRR worker choice strategy to avoid bias.
59 - Avoid array out of bound in worker choice strategies after worker node removal.
61 ## [2.6.39] - 2023-08-30
65 - Fix race condition in worker choice strategies at worker node info querying while not yet initialized.
67 ## [2.6.38] - 2023-08-30
71 - Bundle typescript types declaration into one file.
75 - Improve interleaved weighted round robin worker choice strategy implementation.
77 ## [2.6.37] - 2023-08-28
81 - Ensure unused worker usage statistics are deleted at runtime.
85 - Rename worker choice strategy options `choiceRetries` to `retries`.
86 - Avoid unnecessary branching in worker choice strategies.
88 ## [2.6.36] - 2023-08-27
92 - Fix pool `execute()` arguments check.
96 - Make continuous tasks stealing algorithm less aggressive.
97 - Fine tune tasks stealing algorithm under back pressure.
99 ## [2.6.35] - 2023-08-25
103 - Don't account worker usage statistics for tasks that have failed.
104 - Fix pool information runtime and wait time median computation.
108 - Update simple moving average implementation to use a circular buffer.
109 - Update simple moving median implementation to use a circular buffer.
110 - Account for stolen tasks in worker usage statistics and pool information.
114 - Continuous tasks stealing algorithm.
116 ## [2.6.34] - 2023-08-24
120 - Avoid cascading tasks stealing under back pressure.
124 - Add fastpath to queued tasks rescheduling.
126 ## [2.6.33] - 2023-08-24
130 - Fix queued tasks rescheduling.
134 - Rename tasks queue options `queueMaxSize` to `size`.
138 - Task stealing scheduling algorithm if tasks queueing is enabled.
140 ## [2.6.32] - 2023-08-23
144 - Ensure no task can be executed when the pool is destroyed.
148 - Add `queueMaxSize` option to tasks queue options.
149 - Add O(1) deque implementation implemented with doubly linked list and use it for tasks queueing.
150 - Add tasks stealing algorithm when a worker node queue is back pressured if tasks queueing is enabled.
152 ## [2.6.31] - 2023-08-20
156 - Fix worker choice strategy retries mechanism in some edge cases.
160 - Make orthogonal worker choice strategies tasks distribution and created dynamic worker usage.
161 - Remove the experimental status of the `LEAST_ELU` worker choice strategy.
163 ## [2.6.30] - 2023-08-19
167 - Ensure pool event `backPressure` is emitted.
168 - Ensure pool event `full` is emitted only once.
169 - Ensure worker node cannot be instantiated without proper arguments.
171 ## [2.6.29] - 2023-08-18
175 - Fix race condition between ready and task functions worker message handling at startup.
176 - Fix duplicate task function worker usage statistics computation per task function.
177 - Update task function worker usage statistics if and only if there's at least two different task functions.
178 - Fix race condition at task function worker usage executing task computation leading to negative value.
182 - 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).
183 - Use back pressure detection in worker choice strategies.
184 - Add worker choice strategies retries mechanism if no worker is eligible.
186 ## [2.6.28] - 2023-08-16
190 - Ensure pool workers are properly initialized.
194 - HTTP server pool examples: express-cluster, express-hybrid.
198 - Remove now useless branching in worker hot code path.
200 ## [2.6.27] - 2023-08-15
204 - Add `KillHandler` type definition to exported types.
208 - Add `destroy` event to pool API.
210 ## [2.6.26] - 2023-08-15
214 - Add kill handler to worker options allowing to execute custom code when worker is killed.
215 - Add `listTaskFunctions()` method to pool API.
216 - SMTP client pool example: nodemailer.
218 ## [2.6.25] - 2023-08-13
222 - HTTP server pool examples: fastify-cluster, fastify-hybrid.
223 - WebSocket server pool examples: ws-cluster, ws-hybrid.
225 ## [2.6.24] - 2023-08-12
229 - Add array of transferable objects to the `execute()` method arguments.
230 - WebSocket server pool examples: ws-worker_threads.
232 ## [2.6.23] - 2023-08-11
236 - 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.
240 - HTTP client pool examples: fetch, node-fetch and axios with multiple task functions.
241 - HTTP server pool examples: express-worker_threads, fastify-worker_threads.
243 ## [2.6.22] - 2023-08-10
247 - Add missing `types` field to package.json `exports`.
251 - Structure markdown documentation (PR #811).
253 ## [2.6.21] - 2023-08-03
257 - Improve code documentation.
258 - Code refactoring and cleanup for better maintainability and readability.
260 ## [2.6.20] - 2023-07-21
264 - Fix queued tasks redistribution on error task execution starvation.
265 - Ensure tasks queueing per worker condition is untangled from the pool busyness semantic.
269 - Drastically reduce lookups by worker in the worker nodes.
271 ## [2.6.19] - 2023-07-20
275 - Dedicated internal communication channel for worker_threads pools.
277 ## [2.6.18] - 2023-07-19
281 - Code refactoring and cleanup for better maintainability and readability. Bundle size is a bit smaller.
283 ## [2.6.17] - 2023-07-16
287 - Add `listTaskFunctions()` method to worker API.
289 ## [2.6.16] - 2023-07-12
293 - Fix pool startup detection.
294 - Fix worker task functions handling.
296 ## [2.6.15] - 2023-07-11
300 - Take into account worker node readiness in worker choice strategies.
302 ## [2.6.14] - 2023-07-10
306 - Fix task function statistics tracking.
308 ## [2.6.13] - 2023-07-10
312 - Add per task function statistics tracking.
313 - Add public methods to manipulate the worker task functions at runtime.
315 ## [2.6.12] - 2023-07-09
319 - Workaround import issue with `node:os` module in node 16.x.x.
321 ## [2.6.11] - 2023-07-09
325 - Fix pool readiness semantic.
327 ## [2.6.10] - 2023-07-08
331 - Ensure workers are not recreated on error at pool startup.
335 - Add `ready` and `strategy` fields to pool information.
336 - Add pool event `ready` to notify when the number of workers created in the pool has reached the maximum size expected and are ready.
337 - Add dynamic pool sizing checks.
339 ## [2.6.9] - 2023-07-07
343 - Recreate the right worker type on uncaught exception.
347 - Add minimum and maximum to internal measurement statistics.
348 - Add `runTime` and `waitTime` to pool information.
349 - Check worker inactive time only on dynamic worker.
351 ## [2.6.8] - 2023-07-03
355 - Brown paper bag release to fix version handling in pool information.
357 ## [2.6.7] - 2023-07-03
361 - Ensure worker queued tasks at error are reassigned to other pool workers.
365 - Add pool `utilization` ratio to pool information.
366 - Add `version` to pool information.
367 - Add worker information to worker nodes.
369 ## [2.6.6] - 2023-07-01
373 - Add safe helper `availableParallelism()` to help sizing the pool.
377 - Ensure message handler is only registered in worker.
379 ## [2.6.5] - 2023-06-27
383 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
387 - Artificial version bump to 2.6.5 to workaround publication issue.
388 - Ensure cluster pool `destroy()` gracefully shutdowns worker's server.
389 - Ensure pool event is emitted before task error promise rejection.
390 - Fix queued tasks count computation.
394 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
396 ## [2.6.4] - 2023-06-27
400 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
404 - Ensure cluster pool `destroy()` gracefully shutdowns worker's server.
405 - Ensure pool event is emitted before task error promise rejection.
406 - Fix queued tasks count computation.
410 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
412 ## [2.6.3] - 2023-06-19
416 - Ensure no tasks are queued when trying to soft kill a dynamic worker.
417 - Update strategies internals after statistics computation.
421 - Optimize O(1) queue implementation.
423 ## [2.6.2] - 2023-06-12
427 - Fix new worker use after creation in dynamic pool given the current worker choice strategy.
429 ## [2.6.1] - 2023-06-10
433 - Add worker choice strategy documentation: [README.md](./docs/worker-choice-strategies.md).
437 - Fix average statistics computation: ensure failed tasks are not accounted.
439 ## [2.6.0] - 2023-06-09
443 - Add `LEAST_ELU` worker choice strategy (experimental).
444 - Add tasks ELU instead of runtime support to `FAIR_SHARE` worker choice strategy.
448 - Refactor pool worker node usage internals.
449 - Breaking change: refactor worker choice strategy statistics requirements: the syntax of the worker choice strategy options has changed.
450 - Breaking change: pool information `info` property object fields have been renamed.
454 - Fix wait time accounting.
455 - Ensure worker choice strategy `LEAST_BUSY` accounts also tasks wait time.
456 - Ensure worker choice strategy `LEAST_USED` accounts also queued tasks.
458 ## [2.5.4] - 2023-06-07
462 - Add Event Loop Utilization (ELU) statistics to worker tasks usage.
466 - Compute statistics at the worker level only if needed.
467 - Add `worker_threads` options to thread pool options.
471 - Make the `LEAST_BUSY` strategy only relies on task runtime.
473 ## [2.5.3] - 2023-06-04
477 - Refine pool information content.
478 - Limit pool internals public exposure.
480 ## [2.5.2] - 2023-06-02
484 - Add `taskError` pool event for task execution error.
485 - Add pool information `info` property to pool.
486 - Emit pool information on `busy` and `full` pool events.
488 ## [2.5.1] - 2023-06-01
492 - Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
493 - Add `error` pool event for uncaught worker error.
495 ## [2.5.0] - 2023-05-31
499 - Switch pool event emitter to `EventEmitterAsyncResource`.
500 - Add tasks wait time accounting in per worker tasks usage.
501 - Add interleaved weighted round robin `INTERLEAVED_WEIGHTED_ROUND_ROBIN` worker choice strategy (experimental).
505 - Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
507 ## [2.4.14] - 2023-05-09
511 - Ensure no undefined task runtime can land in the tasks history.
512 - Fix median computation implementation once again.
516 - Unit tests for median and queue implementations.
518 ## [2.4.13] - 2023-05-08
522 - Fix worker choice strategy options validation.
523 - Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
525 ## [2.4.12] - 2023-05-06
529 - Support multiple task functions per worker.
530 - Add custom worker weights support to worker choice strategies options.
534 - Use O(1) queue implementation for tasks queueing.
538 - Fix median computation implementation.
539 - Fix fair share worker choice strategy internals update.
541 ## [2.4.11] - 2023-04-23
545 - Optimize free worker finding in worker choice strategies.
547 ## [2.4.10] - 2023-04-15
551 - Fix typescript type definition for task function: ensure the input data is optional.
552 - Fix typescript type definition for pool execute(): ensure the input data is optional.
554 ## [2.4.9] - 2023-04-15
558 - Add tasks queue enablement runtime setter to pool.
559 - Add tasks queue options runtime setter to pool.
560 - Add worker choice strategy options runtime setter to pool.
564 - Remove the tasks queuing experimental status.
568 - Fix task function type definition and validation.
569 - Fix worker choice strategy options handling.
571 ## [2.4.8] - 2023-04-12
575 - Fix message between main worker and worker type definition for tasks.
576 - Fix code documentation.
578 ## [2.4.7] - 2023-04-11
582 - Add worker tasks queue options to pool options.
586 - Fix missing documentation.
588 ## [2.4.6] - 2023-04-10
592 - Ensure one task at a time is executed per worker with tasks queueing enabled.
593 - Properly count worker executing tasks with tasks queueing enabled.
595 ## [2.4.5] - 2023-04-09
599 - Use monotonic high resolution timer for worker tasks runtime.
600 - Add worker tasks median runtime to statistics.
601 - Add worker tasks queue (experimental).
603 ## [2.4.4] - 2023-04-07
607 - Add `PoolEvents` enumeration and `PoolEvent` type.
611 - Destroy worker only on alive check.
613 ## [2.4.3] - 2023-04-07
617 - Fix typedoc generation with inheritance.
619 ## [2.4.2] - 2023-04-06
623 - Add `full` event to dynamic pool.
624 - Keep worker choice strategy in memory for conditional reuse.
628 - Fix possible negative worker key at worker removal in worker choice strategies.
630 ## [2.4.1] - 2023-04-05
634 - Optimize worker choice strategy for dynamic pool.
638 - Ensure dynamic pool does not alter worker choice strategy expected behavior.
640 ## [2.4.0] - 2023-04-04
644 - Add `LESS_BUSY` worker choice strategy.
648 - Optimize worker storage in pool.
649 - Optimize worker alive status check.
650 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
651 - Optimize `LESS_USED` worker choice strategy.
652 - Update benchmarks versus external threads pools.
653 - Optimize tasks usage statistics requirements for worker choice strategy.
657 - Ensure trimmable characters are checked at pool initialization.
658 - Fix message id integer overflow.
659 - Fix pool worker removal in worker choice strategy internals.
660 - Fix package publication with pnpm.
662 ## [2.4.0-3] - 2023-04-04
666 - Add `LESS_BUSY` worker choice strategy.
670 - Optimize worker storage in pool.
671 - Optimize worker alive status check.
672 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
673 - Optimize `LESS_USED` worker choice strategy.
674 - Update benchmarks versus external threads pools.
678 - Ensure trimmable characters are checked at pool initialization.
679 - Fix message id integer overflow.
680 - Fix pool worker removal in worker choice strategy internals.
681 - Fix package publication with pnpm.
683 ## [2.4.0-2] - 2023-04-03
687 - Add `LESS_BUSY` worker choice strategy.
691 - Optimize worker storage in pool.
692 - Optimize worker alive status check.
693 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
694 - Optimize `LESS_USED` worker choice strategy.
698 - Ensure trimmable characters are checked at pool initialization.
699 - Fix message id integer overflow.
700 - Fix pool worker removal in worker choice strategy internals.
701 - Fix package publication with pnpm.
703 ## [2.4.0-1] - 2023-04-03
707 - Add `LESS_BUSY` worker choice strategy.
711 - Optimize worker storage in pool.
712 - Optimize worker alive status check.
713 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
714 - Optimize `LESS_USED` worker choice strategy.
718 - Ensure trimmable characters are checked at pool initialization.
719 - Fix message id integer overflow.
720 - Fix pool worker removal in worker choice strategy internals.
722 ## [2.4.0-0] - 2023-04-03
726 - Add `LESS_BUSY` worker choice strategy.
730 - Optimize worker storage in pool.
731 - Optimize worker alive status check.
732 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
733 - Optimize `LESS_USED` worker choice strategy.
737 - Ensure trimmable characters are checked at pool initialization.
738 - Fix message id integer overflow.
739 - Fix pool worker removal in worker choice strategy internals.
741 ## [2.3.10] - 2023-03-18
745 - Fix package.json `exports` syntax for ESM and CommonJS.
749 - Permit SemVer pre-release publication.
751 ## [2.3.10-2] - 2023-03-18
755 - Fix package.json `exports` syntax for ESM and CommonJS.
757 ## [2.3.10-1] - 2023-03-18
761 - Permit SemVer pre-release publication.
763 ## [2.3.10-0] - 2023-03-18
767 - Fix package.json `exports` syntax for ESM and CommonJS.
769 ## [2.3.9] - 2023-03-18
773 - Introduce ESM module support along with CommonJS one.
777 - Fix brown paper bag bug referencing the same object literal.
779 ## [2.3.8] - 2023-03-18
783 - Switch internal benchmarking code to benny.
784 - Switch to TypeScript 5.x.x.
785 - Switch rollup bundler plugins to core ones.
786 - Switch to TSDoc syntax.
787 - Enforce conventional commits.
791 - Fix random integer generator.
792 - Fix worker choice strategy pool type identification at initialization.
794 ## [2.3.7] - 2022-10-23
798 - Switch to open collective FOSS project funding platform.
799 - Switch to ts-standard linter configuration on TypeScript code.
803 - Fixed missing async on pool execute method.
804 - Fixed typing in TypeScript example.
805 - Fixed types in unit tests.
807 ## [2.3.6] - 2022-10-22
811 - Cleanup pool attributes and methods.
812 - Refine error types thrown.
816 - Fix continuous integration build on windows.
817 - Fix code coverage reporting by using c8 instead of nyc.
819 ## [2.3.5] - 2022-10-21
823 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
824 - Optimize tasks usage lookup implementation.
828 - Fix missed pool event emitter type export.
829 - Fix typedoc documentation generation.
831 ## [2.3.4] - 2022-10-17
835 - Fully automate release process with release-it.
839 - Optimize fair share task scheduling algorithm implementation.
840 - Update benchmarks versus external pools results with latest version.
842 ## [2.3.3] - 2022-10-15
846 - Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
848 ## [2.3.2] - 2022-10-14
852 - Optimize fair share worker selection strategy implementation.
856 - Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
858 ## [2.3.1] - 2022-10-13
862 - Pool worker choice strategies:
863 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
864 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
866 ## [2.2.2] - 2022-10-09
870 - Fixed `README.md` file.
872 ## [2.2.1] - 2022-10-08
876 - Dynamic worker choice strategy change at runtime.
878 ## [2.2.0] - 2022-01-05
882 - Support only Node.js version 16.x.x for cluster pool: upstream cluster API have changed on that version.
884 ## [2.1.0] - 2021-08-29
888 - Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
892 - `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
893 - `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
894 - `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
895 - `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
897 ## [2.0.2] - 2021-05-12
901 - Fix `busy` event emission on fixed pool type
903 ## [2.0.1] - 2021-03-16
907 - Check if pool options are properly set.
908 - `busy` event is emitted on all pool types.
910 ## [2.0.0] - 2021-03-01
914 - Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
918 - `FullPool` event is now renamed to `busy`.
919 - `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
920 _Find more details on our JSDoc._
922 - `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
924 - We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
926 ### Pool options types declaration merge
928 `FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
930 #### New `export` strategy
934 const DynamicThreadPool = require('poolifier/lib/dynamic')
936 const { DynamicThreadPool } = require('poolifier/lib/dynamic')
939 But you should always prefer just using
942 const { DynamicThreadPool } = require('poolifier')
945 #### New type definitions for input data and response
947 For cluster worker and worker-thread pools, you can now only send and receive structured-cloneable data.
948 _This is not a limitation by poolifier but Node.js._
950 #### Public property replacements
952 `numWorkers` property is now `numberOfWorkers`
954 #### Internal (protected) properties and methods renaming
956 These properties are not intended for end users
958 - `id` => `nextMessageId`
960 These methods are not intended for end users
962 - `_chooseWorker` => `chooseWorker`
963 - `_newWorker` => `createWorker`
964 - `_execute` => `internalExecute`
965 - `_chooseWorker` => `chooseWorker`
966 - `_checkAlive` => `checkAlive`
968 - `_runAsync` => `runAsync`
970 ## [1.1.0] - 2020-05-21
974 - ThreadWorker support async functions as option
975 - Various external library patches
977 ## [1.0.0] - 2020-01-24
981 - FixedThreadPool implementation
982 - DynamicThreadPool implementation
983 - WorkerThread implementation to improve developer experience