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 - Ensure pool event `backPressure` is emitted.
13 - Ensure pool event `full` is emitted only once.
14 - Ensure worker node cannot be instantiated without proper arguments.
16 ## [2.6.29] - 2023-08-18
20 - Fix race condition between ready and task functions worker message handling at startup.
21 - Fix duplicate task function worker usage statistics computation per task function.
22 - Update task function worker usage statistics if and only if there's at least two different task functions.
23 - Fix race condition at task function worker usage executing task computation leading to negative value.
27 - 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).
28 - Use back pressure detection in worker choice strategies.
29 - Add worker choice strategies retries mechanism if no worker is eligible.
31 ## [2.6.28] - 2023-08-16
35 - Ensure pool workers are properly initialized.
39 - HTTP server pool examples: express-cluster, express-hybrid.
43 - Remove now useless branching in worker hot code path.
45 ## [2.6.27] - 2023-08-15
49 - Add `KillHandler` type definition to exported types.
53 - Add `destroy` event to pool API.
55 ## [2.6.26] - 2023-08-15
59 - Add kill handler to worker options allowing to execute custom code when worker is killed.
60 - Add `listTaskFunctions()` method to pool API.
61 - SMTP server pool example: nodemailer.
63 ## [2.6.25] - 2023-08-13
67 - HTTP server pool examples: fastify-cluster, fastify-hybrid.
68 - WebSocket server pool examples: ws-cluster, ws-hybrid.
70 ## [2.6.24] - 2023-08-12
74 - Add array of transferable objects to the `execute()` method arguments.
75 - WebSocket server pool examples: ws-worker_threads.
77 ## [2.6.23] - 2023-08-11
81 - 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.
85 - HTTP client pool examples: fetch, node-fetch and axios with multiple task functions.
86 - HTTP server pool examples: express-worker_threads, fastify-worker_threads.
88 ## [2.6.22] - 2023-08-10
92 - Add missing `types` field to package.json `exports`.
96 - Structure markdown documentation (PR #811).
98 ## [2.6.21] - 2023-08-03
102 - Improve code documentation.
103 - Code refactoring and cleanup for better maintainability and readability.
105 ## [2.6.20] - 2023-07-21
109 - Fix queued tasks redistribution on error task execution starvation.
110 - Ensure tasks queueing per worker condition is untangled from the pool busyness semantic.
114 - Drastically reduce lookups by worker in the worker nodes.
116 ## [2.6.19] - 2023-07-20
120 - Dedicated internal communication channel for worker_threads pools.
122 ## [2.6.18] - 2023-07-19
126 - Code refactoring and cleanup for better maintainability and readability. Bundle size is a bit smaller.
128 ## [2.6.17] - 2023-07-16
132 - Add `listTaskFunctions()` method to worker API.
134 ## [2.6.16] - 2023-07-12
138 - Fix pool startup detection.
139 - Fix worker task functions handling.
141 ## [2.6.15] - 2023-07-11
145 - Take into account worker node readiness in worker choice strategies.
147 ## [2.6.14] - 2023-07-10
151 - Fix task function statistics tracking.
153 ## [2.6.13] - 2023-07-10
157 - Add per task function statistics tracking.
158 - Add public methods to manipulate the worker task functions at runtime.
160 ## [2.6.12] - 2023-07-09
164 - Workaround import issue with `node:os` module in node 16.x.x.
166 ## [2.6.11] - 2023-07-09
170 - Fix pool readiness semantic.
172 ## [2.6.10] - 2023-07-08
176 - Ensure workers are not recreated on error at pool startup.
180 - Add `ready` and `strategy` fields to pool information.
181 - Add pool event `ready` to notify when the number of workers created in the pool has reached the maximum size expected and are ready.
182 - Add dynamic pool sizing checks.
184 ## [2.6.9] - 2023-07-07
188 - Recreate the right worker type on uncaught exception.
192 - Add minimum and maximum to internal measurement statistics.
193 - Add `runTime` and `waitTime` to pool information.
194 - Check worker inactive time only on dynamic worker.
196 ## [2.6.8] - 2023-07-03
200 - Brown paper bag release to fix version handling in pool information.
202 ## [2.6.7] - 2023-07-03
206 - Ensure worker queued tasks at error are reassigned to other pool workers.
210 - Add pool `utilization` ratio to pool information.
211 - Add `version` to pool information.
212 - Add worker information to worker nodes.
214 ## [2.6.6] - 2023-07-01
218 - Add safe helper `availableParallelism()` to help sizing the pool.
222 - Ensure message handler is only registered in worker.
224 ## [2.6.5] - 2023-06-27
228 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
232 - Artificial version bump to 2.6.5 to workaround publication issue.
233 - Ensure cluster pool `destroy()` gracefully shutdowns worker's server.
234 - Ensure pool event is emitted before task error promise rejection.
235 - Fix queued tasks count computation.
239 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
241 ## [2.6.4] - 2023-06-27
245 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
249 - Ensure cluster pool `destroy()` gracefully shutdowns worker's server.
250 - Ensure pool event is emitted before task error promise rejection.
251 - Fix queued tasks count computation.
255 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
257 ## [2.6.3] - 2023-06-19
261 - Ensure no tasks are queued when trying to soft kill a dynamic worker.
262 - Update strategies internals after statistics computation.
266 - Optimize O(1) queue implementation.
268 ## [2.6.2] - 2023-06-12
272 - Fix new worker use after creation in dynamic pool given the current worker choice strategy.
274 ## [2.6.1] - 2023-06-10
278 - Add worker choice strategy documentation: [README.md](./docs/worker-choice-strategies.md).
282 - Fix average statistics computation: ensure failed tasks are not accounted.
284 ## [2.6.0] - 2023-06-09
288 - Add `LEAST_ELU` worker choice strategy (experimental).
289 - Add tasks ELU instead of runtime support to `FAIR_SHARE` worker choice strategy.
293 - Refactor pool worker node usage internals.
294 - Breaking change: refactor worker choice strategy statistics requirements: the syntax of the worker choice strategy options has changed.
295 - Breaking change: pool information `info` property object fields have been renamed.
299 - Fix wait time accounting.
300 - Ensure worker choice strategy `LEAST_BUSY` accounts also tasks wait time.
301 - Ensure worker choice strategy `LEAST_USED` accounts also queued tasks.
303 ## [2.5.4] - 2023-06-07
307 - Add Event Loop Utilization (ELU) statistics to worker tasks usage.
311 - Compute statistics at the worker level only if needed.
312 - Add `worker_threads` options to thread pool options.
316 - Make the `LEAST_BUSY` strategy only relies on task runtime.
318 ## [2.5.3] - 2023-06-04
322 - Refine pool information content.
323 - Limit pool internals public exposure.
325 ## [2.5.2] - 2023-06-02
329 - Add `taskError` pool event for task execution error.
330 - Add pool information `info` property to pool.
331 - Emit pool information on `busy` and `full` pool events.
333 ## [2.5.1] - 2023-06-01
337 - Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
338 - Add `error` pool event for uncaught worker error.
340 ## [2.5.0] - 2023-05-31
344 - Switch pool event emitter to `EventEmitterAsyncResource`.
345 - Add tasks wait time accounting in per worker tasks usage.
346 - Add interleaved weighted round robin `INTERLEAVED_WEIGHTED_ROUND_ROBIN` worker choice strategy (experimental).
350 - Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
352 ## [2.4.14] - 2023-05-09
356 - Ensure no undefined task runtime can land in the tasks history.
357 - Fix median computation implementation once again.
361 - Unit tests for median and queue implementations.
363 ## [2.4.13] - 2023-05-08
367 - Fix worker choice strategy options validation.
368 - Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
370 ## [2.4.12] - 2023-05-06
374 - Support multiple task functions per worker.
375 - Add custom worker weights support to worker choice strategies options.
379 - Use O(1) queue implementation for tasks queueing.
383 - Fix median computation implementation.
384 - Fix fair share worker choice strategy internals update.
386 ## [2.4.11] - 2023-04-23
390 - Optimize free worker finding in worker choice strategies.
392 ## [2.4.10] - 2023-04-15
396 - Fix typescript type definition for task function: ensure the input data is optional.
397 - Fix typescript type definition for pool execute(): ensure the input data is optional.
399 ## [2.4.9] - 2023-04-15
403 - Add tasks queue enablement runtime setter to pool.
404 - Add tasks queue options runtime setter to pool.
405 - Add worker choice strategy options runtime setter to pool.
409 - Remove the tasks queuing experimental status.
413 - Fix task function type definition and validation.
414 - Fix worker choice strategy options handling.
416 ## [2.4.8] - 2023-04-12
420 - Fix message between main worker and worker type definition for tasks.
421 - Fix code documentation.
423 ## [2.4.7] - 2023-04-11
427 - Add worker tasks queue options to pool options.
431 - Fix missing documentation.
433 ## [2.4.6] - 2023-04-10
437 - Ensure one task at a time is executed per worker with tasks queueing enabled.
438 - Properly count worker executing tasks with tasks queueing enabled.
440 ## [2.4.5] - 2023-04-09
444 - Use monotonic high resolution timer for worker tasks runtime.
445 - Add worker tasks median runtime to statistics.
446 - Add worker tasks queue (experimental).
448 ## [2.4.4] - 2023-04-07
452 - Add `PoolEvents` enumeration and `PoolEvent` type.
456 - Destroy worker only on alive check.
458 ## [2.4.3] - 2023-04-07
462 - Fix typedoc generation with inheritance.
464 ## [2.4.2] - 2023-04-06
468 - Add `full` event to dynamic pool.
469 - Keep worker choice strategy in memory for conditional reuse.
473 - Fix possible negative worker key at worker removal in worker choice strategies.
475 ## [2.4.1] - 2023-04-05
479 - Optimize worker choice strategy for dynamic pool.
483 - Ensure dynamic pool does not alter worker choice strategy expected behavior.
485 ## [2.4.0] - 2023-04-04
489 - Add `LESS_BUSY` worker choice strategy.
493 - Optimize worker storage in pool.
494 - Optimize worker alive status check.
495 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
496 - Optimize `LESS_USED` worker choice strategy.
497 - Update benchmarks versus external threads pools.
498 - Optimize tasks usage statistics requirements for worker choice strategy.
502 - Ensure trimmable characters are checked at pool initialization.
503 - Fix message id integer overflow.
504 - Fix pool worker removal in worker choice strategy internals.
505 - Fix package publication with pnpm.
507 ## [2.4.0-3] - 2023-04-04
511 - Add `LESS_BUSY` worker choice strategy.
515 - Optimize worker storage in pool.
516 - Optimize worker alive status check.
517 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
518 - Optimize `LESS_USED` worker choice strategy.
519 - Update benchmarks versus external threads pools.
523 - Ensure trimmable characters are checked at pool initialization.
524 - Fix message id integer overflow.
525 - Fix pool worker removal in worker choice strategy internals.
526 - Fix package publication with pnpm.
528 ## [2.4.0-2] - 2023-04-03
532 - Add `LESS_BUSY` worker choice strategy.
536 - Optimize worker storage in pool.
537 - Optimize worker alive status check.
538 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
539 - Optimize `LESS_USED` worker choice strategy.
543 - Ensure trimmable characters are checked at pool initialization.
544 - Fix message id integer overflow.
545 - Fix pool worker removal in worker choice strategy internals.
546 - Fix package publication with pnpm.
548 ## [2.4.0-1] - 2023-04-03
552 - Add `LESS_BUSY` worker choice strategy.
556 - Optimize worker storage in pool.
557 - Optimize worker alive status check.
558 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
559 - Optimize `LESS_USED` worker choice strategy.
563 - Ensure trimmable characters are checked at pool initialization.
564 - Fix message id integer overflow.
565 - Fix pool worker removal in worker choice strategy internals.
567 ## [2.4.0-0] - 2023-04-03
571 - Add `LESS_BUSY` worker choice strategy.
575 - Optimize worker storage in pool.
576 - Optimize worker alive status check.
577 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
578 - Optimize `LESS_USED` worker choice strategy.
582 - Ensure trimmable characters are checked at pool initialization.
583 - Fix message id integer overflow.
584 - Fix pool worker removal in worker choice strategy internals.
586 ## [2.3.10] - 2023-03-18
590 - Fix package.json `exports` syntax for ESM and CommonJS.
594 - Permit SemVer pre-release publication.
596 ## [2.3.10-2] - 2023-03-18
600 - Fix package.json `exports` syntax for ESM and CommonJS.
602 ## [2.3.10-1] - 2023-03-18
606 - Permit SemVer pre-release publication.
608 ## [2.3.10-0] - 2023-03-18
612 - Fix package.json `exports` syntax for ESM and CommonJS.
614 ## [2.3.9] - 2023-03-18
618 - Introduce ESM module support along with CommonJS one.
622 - Fix brown paper bag bug referencing the same object literal.
624 ## [2.3.8] - 2023-03-18
628 - Switch internal benchmarking code to benny.
629 - Switch to TypeScript 5.x.x.
630 - Switch rollup bundler plugins to core ones.
631 - Switch to TSDoc syntax.
632 - Enforce conventional commits.
636 - Fix random integer generator.
637 - Fix worker choice strategy pool type identification at initialization.
639 ## [2.3.7] - 2022-10-23
643 - Switch to open collective FOSS project funding platform.
644 - Switch to ts-standard linter configuration on TypeScript code.
648 - Fixed missing async on pool execute method.
649 - Fixed typing in TypeScript example.
650 - Fixed types in unit tests.
652 ## [2.3.6] - 2022-10-22
656 - Cleanup pool attributes and methods.
657 - Refine error types thrown.
661 - Fix continuous integration build on windows.
662 - Fix code coverage reporting by using c8 instead of nyc.
664 ## [2.3.5] - 2022-10-21
668 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
669 - Optimize tasks usage lookup implementation.
673 - Fix missed pool event emitter type export.
674 - Fix typedoc documentation generation.
676 ## [2.3.4] - 2022-10-17
680 - Fully automate release process with release-it.
684 - Optimize fair share task scheduling algorithm implementation.
685 - Update benchmarks versus external pools results with latest version.
687 ## [2.3.3] - 2022-10-15
691 - Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
693 ## [2.3.2] - 2022-10-14
697 - Optimize fair share worker selection strategy implementation.
701 - Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
703 ## [2.3.1] - 2022-10-13
707 - Pool worker choice strategies:
708 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
709 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
711 ## [2.2.2] - 2022-10-09
715 - Fixed `README.md` file.
717 ## [2.2.1] - 2022-10-08
721 - Dynamic worker choice strategy change at runtime.
723 ## [2.2.0] - 2022-01-05
727 - Support only Node.js version 16.x.x for cluster pool: upstream cluster API have changed on that version.
729 ## [2.1.0] - 2021-08-29
733 - Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
737 - `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
738 - `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
739 - `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
740 - `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
742 ## [2.0.2] - 2021-05-12
746 - Fix `busy` event emission on fixed pool type
748 ## [2.0.1] - 2021-03-16
752 - Check if pool options are properly set.
753 - `busy` event is emitted on all pool types.
755 ## [2.0.0] - 2021-03-01
759 - Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
763 - `FullPool` event is now renamed to `busy`.
764 - `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
765 _Find more details on our JSDoc._
767 - `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
769 - We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
771 ### Pool options types declaration merge
773 `FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
775 #### New `export` strategy
779 const DynamicThreadPool = require('poolifier/lib/dynamic')
781 const { DynamicThreadPool } = require('poolifier/lib/dynamic')
784 But you should always prefer just using
787 const { DynamicThreadPool } = require('poolifier')
790 #### New type definitions for input data and response
792 For cluster worker and worker-thread pools, you can now only send and receive structured-cloneable data.
793 _This is not a limitation by poolifier but Node.js._
795 #### Public property replacements
797 `numWorkers` property is now `numberOfWorkers`
799 #### Internal (protected) properties and methods renaming
801 These properties are not intended for end users
803 - `id` => `nextMessageId`
805 These methods are not intended for end users
807 - `_chooseWorker` => `chooseWorker`
808 - `_newWorker` => `createWorker`
809 - `_execute` => `internalExecute`
810 - `_chooseWorker` => `chooseWorker`
811 - `_checkAlive` => `checkAlive`
813 - `_runAsync` => `runAsync`
815 ## [1.1.0] - 2020-05-21
819 - ThreadWorker support async functions as option
820 - Various external library patches
822 ## [1.0.0] - 2020-01-24
826 - FixedThreadPool implementation
827 - DynamicThreadPool implementation
828 - WorkerThread implementation to improve developer experience