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.6.31] - 2023-08-20
14 - Fix worker choice strategy retries mechanism in some edge cases.
18 - Make orthogonal worker choice strategies tasks distribution and created dynamic worker usage.
19 - Remove the experimental status of the `LEAST_ELU` worker choice strategy.
21 ## [2.6.30] - 2023-08-19
25 - Ensure pool event `backPressure` is emitted.
26 - Ensure pool event `full` is emitted only once.
27 - Ensure worker node cannot be instantiated without proper arguments.
29 ## [2.6.29] - 2023-08-18
33 - Fix race condition between ready and task functions worker message handling at startup.
34 - Fix duplicate task function worker usage statistics computation per task function.
35 - Update task function worker usage statistics if and only if there's at least two different task functions.
36 - Fix race condition at task function worker usage executing task computation leading to negative value.
40 - 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).
41 - Use back pressure detection in worker choice strategies.
42 - Add worker choice strategies retries mechanism if no worker is eligible.
44 ## [2.6.28] - 2023-08-16
48 - Ensure pool workers are properly initialized.
52 - HTTP server pool examples: express-cluster, express-hybrid.
56 - Remove now useless branching in worker hot code path.
58 ## [2.6.27] - 2023-08-15
62 - Add `KillHandler` type definition to exported types.
66 - Add `destroy` event to pool API.
68 ## [2.6.26] - 2023-08-15
72 - Add kill handler to worker options allowing to execute custom code when worker is killed.
73 - Add `listTaskFunctions()` method to pool API.
74 - SMTP server pool example: nodemailer.
76 ## [2.6.25] - 2023-08-13
80 - HTTP server pool examples: fastify-cluster, fastify-hybrid.
81 - WebSocket server pool examples: ws-cluster, ws-hybrid.
83 ## [2.6.24] - 2023-08-12
87 - Add array of transferable objects to the `execute()` method arguments.
88 - WebSocket server pool examples: ws-worker_threads.
90 ## [2.6.23] - 2023-08-11
94 - 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.
98 - HTTP client pool examples: fetch, node-fetch and axios with multiple task functions.
99 - HTTP server pool examples: express-worker_threads, fastify-worker_threads.
101 ## [2.6.22] - 2023-08-10
105 - Add missing `types` field to package.json `exports`.
109 - Structure markdown documentation (PR #811).
111 ## [2.6.21] - 2023-08-03
115 - Improve code documentation.
116 - Code refactoring and cleanup for better maintainability and readability.
118 ## [2.6.20] - 2023-07-21
122 - Fix queued tasks redistribution on error task execution starvation.
123 - Ensure tasks queueing per worker condition is untangled from the pool busyness semantic.
127 - Drastically reduce lookups by worker in the worker nodes.
129 ## [2.6.19] - 2023-07-20
133 - Dedicated internal communication channel for worker_threads pools.
135 ## [2.6.18] - 2023-07-19
139 - Code refactoring and cleanup for better maintainability and readability. Bundle size is a bit smaller.
141 ## [2.6.17] - 2023-07-16
145 - Add `listTaskFunctions()` method to worker API.
147 ## [2.6.16] - 2023-07-12
151 - Fix pool startup detection.
152 - Fix worker task functions handling.
154 ## [2.6.15] - 2023-07-11
158 - Take into account worker node readiness in worker choice strategies.
160 ## [2.6.14] - 2023-07-10
164 - Fix task function statistics tracking.
166 ## [2.6.13] - 2023-07-10
170 - Add per task function statistics tracking.
171 - Add public methods to manipulate the worker task functions at runtime.
173 ## [2.6.12] - 2023-07-09
177 - Workaround import issue with `node:os` module in node 16.x.x.
179 ## [2.6.11] - 2023-07-09
183 - Fix pool readiness semantic.
185 ## [2.6.10] - 2023-07-08
189 - Ensure workers are not recreated on error at pool startup.
193 - Add `ready` and `strategy` fields to pool information.
194 - Add pool event `ready` to notify when the number of workers created in the pool has reached the maximum size expected and are ready.
195 - Add dynamic pool sizing checks.
197 ## [2.6.9] - 2023-07-07
201 - Recreate the right worker type on uncaught exception.
205 - Add minimum and maximum to internal measurement statistics.
206 - Add `runTime` and `waitTime` to pool information.
207 - Check worker inactive time only on dynamic worker.
209 ## [2.6.8] - 2023-07-03
213 - Brown paper bag release to fix version handling in pool information.
215 ## [2.6.7] - 2023-07-03
219 - Ensure worker queued tasks at error are reassigned to other pool workers.
223 - Add pool `utilization` ratio to pool information.
224 - Add `version` to pool information.
225 - Add worker information to worker nodes.
227 ## [2.6.6] - 2023-07-01
231 - Add safe helper `availableParallelism()` to help sizing the pool.
235 - Ensure message handler is only registered in worker.
237 ## [2.6.5] - 2023-06-27
241 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
245 - Artificial version bump to 2.6.5 to workaround publication issue.
246 - Ensure cluster pool `destroy()` gracefully shutdowns worker's server.
247 - Ensure pool event is emitted before task error promise rejection.
248 - Fix queued tasks count computation.
252 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
254 ## [2.6.4] - 2023-06-27
258 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
262 - Ensure cluster pool `destroy()` gracefully shutdowns worker's server.
263 - Ensure pool event is emitted before task error promise rejection.
264 - Fix queued tasks count computation.
268 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
270 ## [2.6.3] - 2023-06-19
274 - Ensure no tasks are queued when trying to soft kill a dynamic worker.
275 - Update strategies internals after statistics computation.
279 - Optimize O(1) queue implementation.
281 ## [2.6.2] - 2023-06-12
285 - Fix new worker use after creation in dynamic pool given the current worker choice strategy.
287 ## [2.6.1] - 2023-06-10
291 - Add worker choice strategy documentation: [README.md](./docs/worker-choice-strategies.md).
295 - Fix average statistics computation: ensure failed tasks are not accounted.
297 ## [2.6.0] - 2023-06-09
301 - Add `LEAST_ELU` worker choice strategy (experimental).
302 - Add tasks ELU instead of runtime support to `FAIR_SHARE` worker choice strategy.
306 - Refactor pool worker node usage internals.
307 - Breaking change: refactor worker choice strategy statistics requirements: the syntax of the worker choice strategy options has changed.
308 - Breaking change: pool information `info` property object fields have been renamed.
312 - Fix wait time accounting.
313 - Ensure worker choice strategy `LEAST_BUSY` accounts also tasks wait time.
314 - Ensure worker choice strategy `LEAST_USED` accounts also queued tasks.
316 ## [2.5.4] - 2023-06-07
320 - Add Event Loop Utilization (ELU) statistics to worker tasks usage.
324 - Compute statistics at the worker level only if needed.
325 - Add `worker_threads` options to thread pool options.
329 - Make the `LEAST_BUSY` strategy only relies on task runtime.
331 ## [2.5.3] - 2023-06-04
335 - Refine pool information content.
336 - Limit pool internals public exposure.
338 ## [2.5.2] - 2023-06-02
342 - Add `taskError` pool event for task execution error.
343 - Add pool information `info` property to pool.
344 - Emit pool information on `busy` and `full` pool events.
346 ## [2.5.1] - 2023-06-01
350 - Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
351 - Add `error` pool event for uncaught worker error.
353 ## [2.5.0] - 2023-05-31
357 - Switch pool event emitter to `EventEmitterAsyncResource`.
358 - Add tasks wait time accounting in per worker tasks usage.
359 - Add interleaved weighted round robin `INTERLEAVED_WEIGHTED_ROUND_ROBIN` worker choice strategy (experimental).
363 - Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
365 ## [2.4.14] - 2023-05-09
369 - Ensure no undefined task runtime can land in the tasks history.
370 - Fix median computation implementation once again.
374 - Unit tests for median and queue implementations.
376 ## [2.4.13] - 2023-05-08
380 - Fix worker choice strategy options validation.
381 - Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
383 ## [2.4.12] - 2023-05-06
387 - Support multiple task functions per worker.
388 - Add custom worker weights support to worker choice strategies options.
392 - Use O(1) queue implementation for tasks queueing.
396 - Fix median computation implementation.
397 - Fix fair share worker choice strategy internals update.
399 ## [2.4.11] - 2023-04-23
403 - Optimize free worker finding in worker choice strategies.
405 ## [2.4.10] - 2023-04-15
409 - Fix typescript type definition for task function: ensure the input data is optional.
410 - Fix typescript type definition for pool execute(): ensure the input data is optional.
412 ## [2.4.9] - 2023-04-15
416 - Add tasks queue enablement runtime setter to pool.
417 - Add tasks queue options runtime setter to pool.
418 - Add worker choice strategy options runtime setter to pool.
422 - Remove the tasks queuing experimental status.
426 - Fix task function type definition and validation.
427 - Fix worker choice strategy options handling.
429 ## [2.4.8] - 2023-04-12
433 - Fix message between main worker and worker type definition for tasks.
434 - Fix code documentation.
436 ## [2.4.7] - 2023-04-11
440 - Add worker tasks queue options to pool options.
444 - Fix missing documentation.
446 ## [2.4.6] - 2023-04-10
450 - Ensure one task at a time is executed per worker with tasks queueing enabled.
451 - Properly count worker executing tasks with tasks queueing enabled.
453 ## [2.4.5] - 2023-04-09
457 - Use monotonic high resolution timer for worker tasks runtime.
458 - Add worker tasks median runtime to statistics.
459 - Add worker tasks queue (experimental).
461 ## [2.4.4] - 2023-04-07
465 - Add `PoolEvents` enumeration and `PoolEvent` type.
469 - Destroy worker only on alive check.
471 ## [2.4.3] - 2023-04-07
475 - Fix typedoc generation with inheritance.
477 ## [2.4.2] - 2023-04-06
481 - Add `full` event to dynamic pool.
482 - Keep worker choice strategy in memory for conditional reuse.
486 - Fix possible negative worker key at worker removal in worker choice strategies.
488 ## [2.4.1] - 2023-04-05
492 - Optimize worker choice strategy for dynamic pool.
496 - Ensure dynamic pool does not alter worker choice strategy expected behavior.
498 ## [2.4.0] - 2023-04-04
502 - Add `LESS_BUSY` worker choice strategy.
506 - Optimize worker storage in pool.
507 - Optimize worker alive status check.
508 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
509 - Optimize `LESS_USED` worker choice strategy.
510 - Update benchmarks versus external threads pools.
511 - Optimize tasks usage statistics requirements for worker choice strategy.
515 - Ensure trimmable characters are checked at pool initialization.
516 - Fix message id integer overflow.
517 - Fix pool worker removal in worker choice strategy internals.
518 - Fix package publication with pnpm.
520 ## [2.4.0-3] - 2023-04-04
524 - Add `LESS_BUSY` worker choice strategy.
528 - Optimize worker storage in pool.
529 - Optimize worker alive status check.
530 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
531 - Optimize `LESS_USED` worker choice strategy.
532 - Update benchmarks versus external threads pools.
536 - Ensure trimmable characters are checked at pool initialization.
537 - Fix message id integer overflow.
538 - Fix pool worker removal in worker choice strategy internals.
539 - Fix package publication with pnpm.
541 ## [2.4.0-2] - 2023-04-03
545 - Add `LESS_BUSY` worker choice strategy.
549 - Optimize worker storage in pool.
550 - Optimize worker alive status check.
551 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
552 - Optimize `LESS_USED` worker choice strategy.
556 - Ensure trimmable characters are checked at pool initialization.
557 - Fix message id integer overflow.
558 - Fix pool worker removal in worker choice strategy internals.
559 - Fix package publication with pnpm.
561 ## [2.4.0-1] - 2023-04-03
565 - Add `LESS_BUSY` worker choice strategy.
569 - Optimize worker storage in pool.
570 - Optimize worker alive status check.
571 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
572 - Optimize `LESS_USED` worker choice strategy.
576 - Ensure trimmable characters are checked at pool initialization.
577 - Fix message id integer overflow.
578 - Fix pool worker removal in worker choice strategy internals.
580 ## [2.4.0-0] - 2023-04-03
584 - Add `LESS_BUSY` worker choice strategy.
588 - Optimize worker storage in pool.
589 - Optimize worker alive status check.
590 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
591 - Optimize `LESS_USED` worker choice strategy.
595 - Ensure trimmable characters are checked at pool initialization.
596 - Fix message id integer overflow.
597 - Fix pool worker removal in worker choice strategy internals.
599 ## [2.3.10] - 2023-03-18
603 - Fix package.json `exports` syntax for ESM and CommonJS.
607 - Permit SemVer pre-release publication.
609 ## [2.3.10-2] - 2023-03-18
613 - Fix package.json `exports` syntax for ESM and CommonJS.
615 ## [2.3.10-1] - 2023-03-18
619 - Permit SemVer pre-release publication.
621 ## [2.3.10-0] - 2023-03-18
625 - Fix package.json `exports` syntax for ESM and CommonJS.
627 ## [2.3.9] - 2023-03-18
631 - Introduce ESM module support along with CommonJS one.
635 - Fix brown paper bag bug referencing the same object literal.
637 ## [2.3.8] - 2023-03-18
641 - Switch internal benchmarking code to benny.
642 - Switch to TypeScript 5.x.x.
643 - Switch rollup bundler plugins to core ones.
644 - Switch to TSDoc syntax.
645 - Enforce conventional commits.
649 - Fix random integer generator.
650 - Fix worker choice strategy pool type identification at initialization.
652 ## [2.3.7] - 2022-10-23
656 - Switch to open collective FOSS project funding platform.
657 - Switch to ts-standard linter configuration on TypeScript code.
661 - Fixed missing async on pool execute method.
662 - Fixed typing in TypeScript example.
663 - Fixed types in unit tests.
665 ## [2.3.6] - 2022-10-22
669 - Cleanup pool attributes and methods.
670 - Refine error types thrown.
674 - Fix continuous integration build on windows.
675 - Fix code coverage reporting by using c8 instead of nyc.
677 ## [2.3.5] - 2022-10-21
681 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
682 - Optimize tasks usage lookup implementation.
686 - Fix missed pool event emitter type export.
687 - Fix typedoc documentation generation.
689 ## [2.3.4] - 2022-10-17
693 - Fully automate release process with release-it.
697 - Optimize fair share task scheduling algorithm implementation.
698 - Update benchmarks versus external pools results with latest version.
700 ## [2.3.3] - 2022-10-15
704 - Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
706 ## [2.3.2] - 2022-10-14
710 - Optimize fair share worker selection strategy implementation.
714 - Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
716 ## [2.3.1] - 2022-10-13
720 - Pool worker choice strategies:
721 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
722 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
724 ## [2.2.2] - 2022-10-09
728 - Fixed `README.md` file.
730 ## [2.2.1] - 2022-10-08
734 - Dynamic worker choice strategy change at runtime.
736 ## [2.2.0] - 2022-01-05
740 - Support only Node.js version 16.x.x for cluster pool: upstream cluster API have changed on that version.
742 ## [2.1.0] - 2021-08-29
746 - Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
750 - `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
751 - `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
752 - `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
753 - `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
755 ## [2.0.2] - 2021-05-12
759 - Fix `busy` event emission on fixed pool type
761 ## [2.0.1] - 2021-03-16
765 - Check if pool options are properly set.
766 - `busy` event is emitted on all pool types.
768 ## [2.0.0] - 2021-03-01
772 - Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
776 - `FullPool` event is now renamed to `busy`.
777 - `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
778 _Find more details on our JSDoc._
780 - `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
782 - We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
784 ### Pool options types declaration merge
786 `FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
788 #### New `export` strategy
792 const DynamicThreadPool = require('poolifier/lib/dynamic')
794 const { DynamicThreadPool } = require('poolifier/lib/dynamic')
797 But you should always prefer just using
800 const { DynamicThreadPool } = require('poolifier')
803 #### New type definitions for input data and response
805 For cluster worker and worker-thread pools, you can now only send and receive structured-cloneable data.
806 _This is not a limitation by poolifier but Node.js._
808 #### Public property replacements
810 `numWorkers` property is now `numberOfWorkers`
812 #### Internal (protected) properties and methods renaming
814 These properties are not intended for end users
816 - `id` => `nextMessageId`
818 These methods are not intended for end users
820 - `_chooseWorker` => `chooseWorker`
821 - `_newWorker` => `createWorker`
822 - `_execute` => `internalExecute`
823 - `_chooseWorker` => `chooseWorker`
824 - `_checkAlive` => `checkAlive`
826 - `_runAsync` => `runAsync`
828 ## [1.1.0] - 2020-05-21
832 - ThreadWorker support async functions as option
833 - Various external library patches
835 ## [1.0.0] - 2020-01-24
839 - FixedThreadPool implementation
840 - DynamicThreadPool implementation
841 - WorkerThread implementation to improve developer experience