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 - Fix task stealing related tasks queue options handling at runtime.
14 ## [2.6.45] - 2023-09-17
18 - Disable publication on GitHub packages registry on release until authentication issue is fixed.
19 - Rename `listTaskFunctions()` to `listTaskFunctionNames()` in pool and worker API.
23 - Add `addTaskFunction()`, `removeTaskFunction()`, `setDefaultTaskFunction()` methods to pool API.
24 - Add `startWorkers` to pool options to whether start the minimum number of workers at pool creation or not.
25 - Add `start()` method to pool API to start the minimum number of workers.
26 - 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.
27 - Continuous internal benchmarking: https://poolifier.github.io/benchmark-results/dev/bench.
29 ## [2.6.44] - 2023-09-08
33 - Use a dedicated PAT to publish on GitHub packages registry.
37 - Publish on GitHub packages registry on release.
41 - Switch from rome to biome: [PR #1128](https://github.com/poolifier/poolifier/pull/1128).
43 ## [2.6.43] - 2023-09-08
47 - Publish on GitHub packages registry on release.
51 - Switch from rome to biome: [PR #1128](https://github.com/poolifier/poolifier/pull/1128).
53 ## [2.6.42] - 2023-09-06
57 - Optimize hot code paths implementation: avoid unnecessary branching, add and use optimized helpers (min, max), use reduce() array helper, ...
59 ## [2.6.41] - 2023-09-03
63 - Optimize worker choice strategies implementation.
65 ## [2.6.40] - 2023-09-01
69 - Do not pre-choose in WRR worker choice strategy to avoid bias.
70 - Avoid array out of bound in worker choice strategies after worker node removal.
72 ## [2.6.39] - 2023-08-30
76 - Fix race condition in worker choice strategies at worker node info querying while not yet initialized.
78 ## [2.6.38] - 2023-08-30
82 - Bundle typescript types declaration into one file.
86 - Improve interleaved weighted round robin worker choice strategy implementation.
88 ## [2.6.37] - 2023-08-28
92 - Ensure unused worker usage statistics are deleted at runtime.
96 - Rename worker choice strategy options `choiceRetries` to `retries`.
97 - Avoid unnecessary branching in worker choice strategies.
99 ## [2.6.36] - 2023-08-27
103 - Fix pool `execute()` arguments check.
107 - Make continuous tasks stealing algorithm less aggressive.
108 - Fine tune tasks stealing algorithm under back pressure.
110 ## [2.6.35] - 2023-08-25
114 - Don't account worker usage statistics for tasks that have failed.
115 - Fix pool information runtime and wait time median computation.
119 - Update simple moving average implementation to use a circular buffer.
120 - Update simple moving median implementation to use a circular buffer.
121 - Account for stolen tasks in worker usage statistics and pool information.
125 - Continuous tasks stealing algorithm.
127 ## [2.6.34] - 2023-08-24
131 - Avoid cascading tasks stealing under back pressure.
135 - Add fastpath to queued tasks rescheduling.
137 ## [2.6.33] - 2023-08-24
141 - Fix queued tasks rescheduling.
145 - Rename tasks queue options `queueMaxSize` to `size`.
149 - Task stealing scheduling algorithm if tasks queueing is enabled.
151 ## [2.6.32] - 2023-08-23
155 - Ensure no task can be executed when the pool is destroyed.
159 - Add `queueMaxSize` option to tasks queue options.
160 - Add O(1) deque implementation implemented with doubly linked list and use it for tasks queueing.
161 - Add tasks stealing algorithm when a worker node queue is back pressured if tasks queueing is enabled.
163 ## [2.6.31] - 2023-08-20
167 - Fix worker choice strategy retries mechanism in some edge cases.
171 - Make orthogonal worker choice strategies tasks distribution and created dynamic worker usage.
172 - Remove the experimental status of the `LEAST_ELU` worker choice strategy.
174 ## [2.6.30] - 2023-08-19
178 - Ensure pool event `backPressure` is emitted.
179 - Ensure pool event `full` is emitted only once.
180 - Ensure worker node cannot be instantiated without proper arguments.
182 ## [2.6.29] - 2023-08-18
186 - Fix race condition between ready and task functions worker message handling at startup.
187 - Fix duplicate task function worker usage statistics computation per task function.
188 - Update task function worker usage statistics if and only if there's at least two different task functions.
189 - Fix race condition at task function worker usage executing task computation leading to negative value.
193 - 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).
194 - Use back pressure detection in worker choice strategies.
195 - Add worker choice strategies retries mechanism if no worker is eligible.
197 ## [2.6.28] - 2023-08-16
201 - Ensure pool workers are properly initialized.
205 - HTTP server pool examples: express-cluster, express-hybrid.
209 - Remove now useless branching in worker hot code path.
211 ## [2.6.27] - 2023-08-15
215 - Add `KillHandler` type definition to exported types.
219 - Add `destroy` event to pool API.
221 ## [2.6.26] - 2023-08-15
225 - Add kill handler to worker options allowing to execute custom code when worker is killed.
226 - Add `listTaskFunctions()` method to pool API.
227 - SMTP client pool example: nodemailer.
229 ## [2.6.25] - 2023-08-13
233 - HTTP server pool examples: fastify-cluster, fastify-hybrid.
234 - WebSocket server pool examples: ws-cluster, ws-hybrid.
236 ## [2.6.24] - 2023-08-12
240 - Add array of transferable objects to the `execute()` method arguments.
241 - WebSocket server pool examples: ws-worker_threads.
243 ## [2.6.23] - 2023-08-11
247 - 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.
251 - HTTP client pool examples: fetch, node-fetch and axios with multiple task functions.
252 - HTTP server pool examples: express-worker_threads, fastify-worker_threads.
254 ## [2.6.22] - 2023-08-10
258 - Add missing `types` field to package.json `exports`.
262 - Structure markdown documentation (PR #811).
264 ## [2.6.21] - 2023-08-03
268 - Improve code documentation.
269 - Code refactoring and cleanup for better maintainability and readability.
271 ## [2.6.20] - 2023-07-21
275 - Fix queued tasks redistribution on error task execution starvation.
276 - Ensure tasks queueing per worker condition is untangled from the pool busyness semantic.
280 - Drastically reduce lookups by worker in the worker nodes.
282 ## [2.6.19] - 2023-07-20
286 - Dedicated internal communication channel for worker_threads pools.
288 ## [2.6.18] - 2023-07-19
292 - Code refactoring and cleanup for better maintainability and readability. Bundle size is a bit smaller.
294 ## [2.6.17] - 2023-07-16
298 - Add `listTaskFunctions()` method to worker API.
300 ## [2.6.16] - 2023-07-12
304 - Fix pool startup detection.
305 - Fix worker task functions handling.
307 ## [2.6.15] - 2023-07-11
311 - Take into account worker node readiness in worker choice strategies.
313 ## [2.6.14] - 2023-07-10
317 - Fix task function statistics tracking.
319 ## [2.6.13] - 2023-07-10
323 - Add per task function statistics tracking.
324 - Add public methods to manipulate the worker task functions at runtime.
326 ## [2.6.12] - 2023-07-09
330 - Workaround import issue with `node:os` module in node 16.x.x.
332 ## [2.6.11] - 2023-07-09
336 - Fix pool readiness semantic.
338 ## [2.6.10] - 2023-07-08
342 - Ensure workers are not recreated on error at pool startup.
346 - Add `ready` and `strategy` fields to pool information.
347 - Add pool event `ready` to notify when the number of workers created in the pool has reached the maximum size expected and are ready.
348 - Add dynamic pool sizing checks.
350 ## [2.6.9] - 2023-07-07
354 - Recreate the right worker type on uncaught exception.
358 - Add minimum and maximum to internal measurement statistics.
359 - Add `runTime` and `waitTime` to pool information.
360 - Check worker inactive time only on dynamic worker.
362 ## [2.6.8] - 2023-07-03
366 - Brown paper bag release to fix version handling in pool information.
368 ## [2.6.7] - 2023-07-03
372 - Ensure worker queued tasks at error are reassigned to other pool workers.
376 - Add pool `utilization` ratio to pool information.
377 - Add `version` to pool information.
378 - Add worker information to worker nodes.
380 ## [2.6.6] - 2023-07-01
384 - Add safe helper `availableParallelism()` to help sizing the pool.
388 - Ensure message handler is only registered in worker.
390 ## [2.6.5] - 2023-06-27
394 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
398 - Artificial version bump to 2.6.5 to workaround publication issue.
399 - Ensure cluster pool `destroy()` gracefully shutdowns worker's server.
400 - Ensure pool event is emitted before task error promise rejection.
401 - Fix queued tasks count computation.
405 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
407 ## [2.6.4] - 2023-06-27
411 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
415 - Ensure cluster pool `destroy()` gracefully shutdowns worker's server.
416 - Ensure pool event is emitted before task error promise rejection.
417 - Fix queued tasks count computation.
421 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
423 ## [2.6.3] - 2023-06-19
427 - Ensure no tasks are queued when trying to soft kill a dynamic worker.
428 - Update strategies internals after statistics computation.
432 - Optimize O(1) queue implementation.
434 ## [2.6.2] - 2023-06-12
438 - Fix new worker use after creation in dynamic pool given the current worker choice strategy.
440 ## [2.6.1] - 2023-06-10
444 - Add worker choice strategy documentation: [README.md](./docs/worker-choice-strategies.md).
448 - Fix average statistics computation: ensure failed tasks are not accounted.
450 ## [2.6.0] - 2023-06-09
454 - Add `LEAST_ELU` worker choice strategy (experimental).
455 - Add tasks ELU instead of runtime support to `FAIR_SHARE` worker choice strategy.
459 - Refactor pool worker node usage internals.
460 - Breaking change: refactor worker choice strategy statistics requirements: the syntax of the worker choice strategy options has changed.
461 - Breaking change: pool information `info` property object fields have been renamed.
465 - Fix wait time accounting.
466 - Ensure worker choice strategy `LEAST_BUSY` accounts also tasks wait time.
467 - Ensure worker choice strategy `LEAST_USED` accounts also queued tasks.
469 ## [2.5.4] - 2023-06-07
473 - Add Event Loop Utilization (ELU) statistics to worker tasks usage.
477 - Compute statistics at the worker level only if needed.
478 - Add `worker_threads` options to thread pool options.
482 - Make the `LEAST_BUSY` strategy only relies on task runtime.
484 ## [2.5.3] - 2023-06-04
488 - Refine pool information content.
489 - Limit pool internals public exposure.
491 ## [2.5.2] - 2023-06-02
495 - Add `taskError` pool event for task execution error.
496 - Add pool information `info` property to pool.
497 - Emit pool information on `busy` and `full` pool events.
499 ## [2.5.1] - 2023-06-01
503 - Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
504 - Add `error` pool event for uncaught worker error.
506 ## [2.5.0] - 2023-05-31
510 - Switch pool event emitter to `EventEmitterAsyncResource`.
511 - Add tasks wait time accounting in per worker tasks usage.
512 - Add interleaved weighted round robin `INTERLEAVED_WEIGHTED_ROUND_ROBIN` worker choice strategy (experimental).
516 - Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
518 ## [2.4.14] - 2023-05-09
522 - Ensure no undefined task runtime can land in the tasks history.
523 - Fix median computation implementation once again.
527 - Unit tests for median and queue implementations.
529 ## [2.4.13] - 2023-05-08
533 - Fix worker choice strategy options validation.
534 - Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
536 ## [2.4.12] - 2023-05-06
540 - Support multiple task functions per worker.
541 - Add custom worker weights support to worker choice strategies options.
545 - Use O(1) queue implementation for tasks queueing.
549 - Fix median computation implementation.
550 - Fix fair share worker choice strategy internals update.
552 ## [2.4.11] - 2023-04-23
556 - Optimize free worker finding in worker choice strategies.
558 ## [2.4.10] - 2023-04-15
562 - Fix typescript type definition for task function: ensure the input data is optional.
563 - Fix typescript type definition for pool execute(): ensure the input data is optional.
565 ## [2.4.9] - 2023-04-15
569 - Add tasks queue enablement runtime setter to pool.
570 - Add tasks queue options runtime setter to pool.
571 - Add worker choice strategy options runtime setter to pool.
575 - Remove the tasks queuing experimental status.
579 - Fix task function type definition and validation.
580 - Fix worker choice strategy options handling.
582 ## [2.4.8] - 2023-04-12
586 - Fix message between main worker and worker type definition for tasks.
587 - Fix code documentation.
589 ## [2.4.7] - 2023-04-11
593 - Add worker tasks queue options to pool options.
597 - Fix missing documentation.
599 ## [2.4.6] - 2023-04-10
603 - Ensure one task at a time is executed per worker with tasks queueing enabled.
604 - Properly count worker executing tasks with tasks queueing enabled.
606 ## [2.4.5] - 2023-04-09
610 - Use monotonic high resolution timer for worker tasks runtime.
611 - Add worker tasks median runtime to statistics.
612 - Add worker tasks queue (experimental).
614 ## [2.4.4] - 2023-04-07
618 - Add `PoolEvents` enumeration and `PoolEvent` type.
622 - Destroy worker only on alive check.
624 ## [2.4.3] - 2023-04-07
628 - Fix typedoc generation with inheritance.
630 ## [2.4.2] - 2023-04-06
634 - Add `full` event to dynamic pool.
635 - Keep worker choice strategy in memory for conditional reuse.
639 - Fix possible negative worker key at worker removal in worker choice strategies.
641 ## [2.4.1] - 2023-04-05
645 - Optimize worker choice strategy for dynamic pool.
649 - Ensure dynamic pool does not alter worker choice strategy expected behavior.
651 ## [2.4.0] - 2023-04-04
655 - Add `LESS_BUSY` worker choice strategy.
659 - Optimize worker storage in pool.
660 - Optimize worker alive status check.
661 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
662 - Optimize `LESS_USED` worker choice strategy.
663 - Update benchmark versus external threads pools.
664 - Optimize tasks usage statistics requirements for worker choice strategy.
668 - Ensure trimmable characters are checked at pool initialization.
669 - Fix message id integer overflow.
670 - Fix pool worker removal in worker choice strategy internals.
671 - Fix package publication with pnpm.
673 ## [2.4.0-3] - 2023-04-04
677 - Add `LESS_BUSY` worker choice strategy.
681 - Optimize worker storage in pool.
682 - Optimize worker alive status check.
683 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
684 - Optimize `LESS_USED` worker choice strategy.
685 - Update benchmark versus external threads pools.
689 - Ensure trimmable characters are checked at pool initialization.
690 - Fix message id integer overflow.
691 - Fix pool worker removal in worker choice strategy internals.
692 - Fix package publication with pnpm.
694 ## [2.4.0-2] - 2023-04-03
698 - Add `LESS_BUSY` worker choice strategy.
702 - Optimize worker storage in pool.
703 - Optimize worker alive status check.
704 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
705 - Optimize `LESS_USED` worker choice strategy.
709 - Ensure trimmable characters are checked at pool initialization.
710 - Fix message id integer overflow.
711 - Fix pool worker removal in worker choice strategy internals.
712 - Fix package publication with pnpm.
714 ## [2.4.0-1] - 2023-04-03
718 - Add `LESS_BUSY` worker choice strategy.
722 - Optimize worker storage in pool.
723 - Optimize worker alive status check.
724 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
725 - Optimize `LESS_USED` worker choice strategy.
729 - Ensure trimmable characters are checked at pool initialization.
730 - Fix message id integer overflow.
731 - Fix pool worker removal in worker choice strategy internals.
733 ## [2.4.0-0] - 2023-04-03
737 - Add `LESS_BUSY` worker choice strategy.
741 - Optimize worker storage in pool.
742 - Optimize worker alive status check.
743 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
744 - Optimize `LESS_USED` worker choice strategy.
748 - Ensure trimmable characters are checked at pool initialization.
749 - Fix message id integer overflow.
750 - Fix pool worker removal in worker choice strategy internals.
752 ## [2.3.10] - 2023-03-18
756 - Fix package.json `exports` syntax for ESM and CommonJS.
760 - Permit SemVer pre-release publication.
762 ## [2.3.10-2] - 2023-03-18
766 - Fix package.json `exports` syntax for ESM and CommonJS.
768 ## [2.3.10-1] - 2023-03-18
772 - Permit SemVer pre-release publication.
774 ## [2.3.10-0] - 2023-03-18
778 - Fix package.json `exports` syntax for ESM and CommonJS.
780 ## [2.3.9] - 2023-03-18
784 - Introduce ESM module support along with CommonJS one.
788 - Fix brown paper bag bug referencing the same object literal.
790 ## [2.3.8] - 2023-03-18
794 - Switch internal benchmarking code to benny.
795 - Switch to TypeScript 5.x.x.
796 - Switch rollup bundler plugins to core ones.
797 - Switch to TSDoc syntax.
798 - Enforce conventional commits.
802 - Fix random integer generator.
803 - Fix worker choice strategy pool type identification at initialization.
805 ## [2.3.7] - 2022-10-23
809 - Switch to open collective FOSS project funding platform.
810 - Switch to ts-standard linter configuration on TypeScript code.
814 - Fixed missing async on pool execute method.
815 - Fixed typing in TypeScript example.
816 - Fixed types in unit tests.
818 ## [2.3.6] - 2022-10-22
822 - Cleanup pool attributes and methods.
823 - Refine error types thrown.
827 - Fix continuous integration build on windows.
828 - Fix code coverage reporting by using c8 instead of nyc.
830 ## [2.3.5] - 2022-10-21
834 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
835 - Optimize tasks usage lookup implementation.
839 - Fix missed pool event emitter type export.
840 - Fix typedoc documentation generation.
842 ## [2.3.4] - 2022-10-17
846 - Fully automate release process with release-it.
850 - Optimize fair share task scheduling algorithm implementation.
851 - Update benchmark versus external pools results with latest version.
853 ## [2.3.3] - 2022-10-15
857 - Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
859 ## [2.3.2] - 2022-10-14
863 - Optimize fair share worker selection strategy implementation.
867 - Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
869 ## [2.3.1] - 2022-10-13
873 - Pool worker choice strategies:
874 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
875 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
877 ## [2.2.2] - 2022-10-09
881 - Fixed `README.md` file.
883 ## [2.2.1] - 2022-10-08
887 - Dynamic worker choice strategy change at runtime.
889 ## [2.2.0] - 2022-01-05
893 - Support only Node.js version 16.x.x for cluster pool: upstream cluster API have changed on that version.
895 ## [2.1.0] - 2021-08-29
899 - Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
903 - `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
904 - `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
905 - `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
906 - `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
908 ## [2.0.2] - 2021-05-12
912 - Fix `busy` event emission on fixed pool type
914 ## [2.0.1] - 2021-03-16
918 - Check if pool options are properly set.
919 - `busy` event is emitted on all pool types.
921 ## [2.0.0] - 2021-03-01
925 - Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
929 - `FullPool` event is now renamed to `busy`.
930 - `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
931 _Find more details on our JSDoc._
933 - `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
935 - We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
937 ### Pool options types declaration merge
939 `FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
941 #### New `export` strategy
945 const DynamicThreadPool = require('poolifier/lib/dynamic')
947 const { DynamicThreadPool } = require('poolifier/lib/dynamic')
950 But you should always prefer just using
953 const { DynamicThreadPool } = require('poolifier')
956 #### New type definitions for input data and response
958 For cluster worker and worker-thread pools, you can now only send and receive structured-cloneable data.
959 _This is not a limitation by poolifier but Node.js._
961 #### Public property replacements
963 `numWorkers` property is now `numberOfWorkers`
965 #### Internal (protected) properties and methods renaming
967 These properties are not intended for end users
969 - `id` => `nextMessageId`
971 These methods are not intended for end users
973 - `_chooseWorker` => `chooseWorker`
974 - `_newWorker` => `createWorker`
975 - `_execute` => `internalExecute`
976 - `_chooseWorker` => `chooseWorker`
977 - `_checkAlive` => `checkAlive`
979 - `_runAsync` => `runAsync`
981 ## [1.1.0] - 2020-05-21
985 - ThreadWorker support async functions as option
986 - Various external library patches
988 ## [1.0.0] - 2020-01-24
992 - FixedThreadPool implementation
993 - DynamicThreadPool implementation
994 - WorkerThread implementation to improve developer experience