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 - Add `KillHandler` type definition to exported types.
16 - Add `destroy` event to pool API.
18 ## [2.6.26] - 2023-08-15
22 - Add kill handler to worker options allowing to execute custom code when worker is killed.
23 - Add `listTaskFunctions()` method to pool API.
24 - SMTP server pool example: nodemailer.
26 ## [2.6.25] - 2023-08-13
30 - HTTP server pool examples: fastify-cluster, fastify-hybrid.
31 - WebSocket server pool examples: ws-cluster, ws-hybrid.
33 ## [2.6.24] - 2023-08-12
37 - Add array of transferable objects to the `execute()` method arguments.
38 - WebSocket server pool examples: ws-worker_threads.
40 ## [2.6.23] - 2023-08-11
44 - 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.
48 - HTTP client pool examples: fetch, node-fetch and axios with multiple task functions.
49 - HTTP server pool examples: express-worker_threads, fastify-worker_threads.
51 ## [2.6.22] - 2023-08-10
55 - Add missing `types` field to package.json `exports`.
59 - Structure markdown documentation (PR #811).
61 ## [2.6.21] - 2023-08-03
65 - Improve code documentation.
66 - Code refactoring and cleanup for better maintainability and readability.
68 ## [2.6.20] - 2023-07-21
72 - Fix queued tasks redistribution on error task execution starvation.
73 - Ensure task queueing per worker condition is untangled from the pool busyness semantic.
77 - Drastically reduce lookups by worker in the worker nodes.
79 ## [2.6.19] - 2023-07-20
83 - Dedicated internal communication channel for worker_threads pools.
85 ## [2.6.18] - 2023-07-19
89 - Code refactoring and cleanup for better maintainability and readability. Bundle size is a bit smaller.
91 ## [2.6.17] - 2023-07-16
95 - Add `listTaskFunctions()` method to worker API.
97 ## [2.6.16] - 2023-07-12
101 - Fix pool startup detection.
102 - Fix worker task functions handling.
104 ## [2.6.15] - 2023-07-11
108 - Take into account worker node readiness in worker choice strategies.
110 ## [2.6.14] - 2023-07-10
114 - Fix task function statistics tracking.
116 ## [2.6.13] - 2023-07-10
120 - Add per task function statistics tracking.
121 - Add public methods to manipulate the worker task functions at runtime.
123 ## [2.6.12] - 2023-07-09
127 - Workaround import issue with `node:os` module in node 16.x.x.
129 ## [2.6.11] - 2023-07-09
133 - Fix pool readiness semantic.
135 ## [2.6.10] - 2023-07-08
139 - Ensure workers are not recreated on error at pool startup.
143 - Add `ready` and `strategy` fields to pool information.
144 - Add pool event `ready` to notify when the number of workers created in the pool has reached the maximum size expected and are ready.
145 - Add dynamic pool sizing checks.
147 ## [2.6.9] - 2023-07-07
151 - Recreate the right worker type on uncaught exception.
155 - Add minimum and maximum to internal measurement statistics.
156 - Add `runTime` and `waitTime` to pool information.
157 - Check worker inactive time only on dynamic worker.
159 ## [2.6.8] - 2023-07-03
163 - Brown paper bag release to fix version handling in pool information.
165 ## [2.6.7] - 2023-07-03
169 - Ensure worker queued tasks at error are reassigned to other pool workers.
173 - Add pool `utilization` ratio to pool information.
174 - Add `version` to pool information.
175 - Add worker information to worker nodes.
177 ## [2.6.6] - 2023-07-01
181 - Add safe helper `availableParallelism` to help sizing the pool.
185 - Ensure message handler is only registered in worker.
187 ## [2.6.5] - 2023-06-27
191 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
195 - Artificial version bump to 2.6.5 to workaround publication issue.
196 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
197 - Ensure pool event is emitted before task error promise rejection.
198 - Fix queued tasks count computation.
202 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
204 ## [2.6.4] - 2023-06-27
208 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
212 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
213 - Ensure pool event is emitted before task error promise rejection.
214 - Fix queued tasks count computation.
218 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
220 ## [2.6.3] - 2023-06-19
224 - Ensure no tasks are queued when trying to soft kill a dynamic worker.
225 - Update strategies internals after statistics computation.
229 - Optimize O(1) queue implementation.
231 ## [2.6.2] - 2023-06-12
235 - Fix new worker use after creation in dynamic pool given the current worker choice strategy.
237 ## [2.6.1] - 2023-06-10
241 - Add worker choice strategy documentation: [README.md](./docs/worker-choice-strategies.md).
245 - Fix average statistics computation: ensure failed tasks are not accounted.
247 ## [2.6.0] - 2023-06-09
251 - Add `LEAST_ELU` worker choice strategy (experimental).
252 - Add tasks ELU instead of runtime support to `FAIR_SHARE` worker choice strategy.
256 - Refactor pool worker node usage internals.
257 - Breaking change: refactor worker choice strategy statistics requirements: the syntax of the worker choice strategy options has changed.
258 - Breaking change: pool information `info` property object fields have been renamed.
262 - Fix wait time accounting.
263 - Ensure worker choice strategy `LEAST_BUSY` accounts also tasks wait time.
264 - Ensure worker choice strategy `LEAST_USED` accounts also queued tasks.
266 ## [2.5.4] - 2023-06-07
270 - Add Event Loop Utilization (ELU) statistics to worker tasks usage.
274 - Compute statistics at the worker level only if needed.
275 - Add `worker_threads` options to thread pool options.
279 - Make the `LEAST_BUSY` strategy only relies on task runtime.
281 ## [2.5.3] - 2023-06-04
285 - Refine pool information content.
286 - Limit pool internals public exposure.
288 ## [2.5.2] - 2023-06-02
292 - Add `taskError` pool event for task execution error.
293 - Add pool information `info` property to pool.
294 - Emit pool information on `busy` and `full` pool events.
296 ## [2.5.1] - 2023-06-01
300 - Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
301 - Add `error` pool event for uncaught worker error.
303 ## [2.5.0] - 2023-05-31
307 - Switch pool event emitter to `EventEmitterAsyncResource`.
308 - Add tasks wait time accounting in per worker tasks usage.
309 - Add interleaved weighted round robin `INTERLEAVED_WEIGHTED_ROUND_ROBIN` worker choice strategy (experimental).
313 - Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
315 ## [2.4.14] - 2023-05-09
319 - Ensure no undefined task runtime can land in the tasks history.
320 - Fix median computation implementation once again.
324 - Unit tests for median and queue implementations.
326 ## [2.4.13] - 2023-05-08
330 - Fix worker choice strategy options validation.
331 - Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
333 ## [2.4.12] - 2023-05-06
337 - Support multiple task functions per worker.
338 - Add custom worker weights support to worker choice strategies options.
342 - Use O(1) queue implementation for tasks queueing.
346 - Fix median computation implementation.
347 - Fix fair share worker choice strategy internals update.
349 ## [2.4.11] - 2023-04-23
353 - Optimize free worker finding in worker choice strategies.
355 ## [2.4.10] - 2023-04-15
359 - Fix typescript type definition for task function: ensure the input data is optional.
360 - Fix typescript type definition for pool execute(): ensure the input data is optional.
362 ## [2.4.9] - 2023-04-15
366 - Add tasks queue enablement runtime setter to pool.
367 - Add tasks queue options runtime setter to pool.
368 - Add worker choice strategy options runtime setter to pool.
372 - Remove the tasks queuing experimental status.
376 - Fix task function type definition and validation.
377 - Fix worker choice strategy options handling.
379 ## [2.4.8] - 2023-04-12
383 - Fix message between main worker and worker type definition for tasks.
384 - Fix code documentation.
386 ## [2.4.7] - 2023-04-11
390 - Add worker tasks queue options to pool options.
394 - Fix missing documentation.
396 ## [2.4.6] - 2023-04-10
400 - Ensure one task at a time is executed per worker with tasks queueing enabled.
401 - Properly count worker executing tasks with tasks queueing enabled.
403 ## [2.4.5] - 2023-04-09
407 - Use monotonic high resolution timer for worker tasks runtime.
408 - Add worker tasks median runtime to statistics.
409 - Add worker tasks queue (experimental).
411 ## [2.4.4] - 2023-04-07
415 - Add `PoolEvents` enumeration and `PoolEvent` type.
419 - Destroy worker only on alive check.
421 ## [2.4.3] - 2023-04-07
425 - Fix typedoc generation with inheritance.
427 ## [2.4.2] - 2023-04-06
431 - Add `full` event to dynamic pool.
432 - Keep worker choice strategy in memory for conditional reuse.
436 - Fix possible negative worker key at worker removal in worker choice strategies.
438 ## [2.4.1] - 2023-04-05
442 - Optimize worker choice strategy for dynamic pool.
446 - Ensure dynamic pool does not alter worker choice strategy expected behavior.
448 ## [2.4.0] - 2023-04-04
452 - Add `LESS_BUSY` worker choice strategy.
456 - Optimize worker storage in pool.
457 - Optimize worker alive status check.
458 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
459 - Optimize `LESS_USED` worker choice strategy.
460 - Update benchmarks versus external threads pools.
461 - Optimize tasks usage statistics requirements for worker choice strategy.
465 - Ensure trimmable characters are checked at pool initialization.
466 - Fix message id integer overflow.
467 - Fix pool worker removal in worker choice strategy internals.
468 - Fix package publication with pnpm.
470 ## [2.4.0-3] - 2023-04-04
474 - Add `LESS_BUSY` worker choice strategy.
478 - Optimize worker storage in pool.
479 - Optimize worker alive status check.
480 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
481 - Optimize `LESS_USED` worker choice strategy.
482 - Update benchmarks versus external threads pools.
486 - Ensure trimmable characters are checked at pool initialization.
487 - Fix message id integer overflow.
488 - Fix pool worker removal in worker choice strategy internals.
489 - Fix package publication with pnpm.
491 ## [2.4.0-2] - 2023-04-03
495 - Add `LESS_BUSY` worker choice strategy.
499 - Optimize worker storage in pool.
500 - Optimize worker alive status check.
501 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
502 - Optimize `LESS_USED` worker choice strategy.
506 - Ensure trimmable characters are checked at pool initialization.
507 - Fix message id integer overflow.
508 - Fix pool worker removal in worker choice strategy internals.
509 - Fix package publication with pnpm.
511 ## [2.4.0-1] - 2023-04-03
515 - Add `LESS_BUSY` worker choice strategy.
519 - Optimize worker storage in pool.
520 - Optimize worker alive status check.
521 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
522 - Optimize `LESS_USED` worker choice strategy.
526 - Ensure trimmable characters are checked at pool initialization.
527 - Fix message id integer overflow.
528 - Fix pool worker removal in worker choice strategy internals.
530 ## [2.4.0-0] - 2023-04-03
534 - Add `LESS_BUSY` worker choice strategy.
538 - Optimize worker storage in pool.
539 - Optimize worker alive status check.
540 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
541 - Optimize `LESS_USED` worker choice strategy.
545 - Ensure trimmable characters are checked at pool initialization.
546 - Fix message id integer overflow.
547 - Fix pool worker removal in worker choice strategy internals.
549 ## [2.3.10] - 2023-03-18
553 - Fix package.json `exports` syntax for ESM and CommonJS.
557 - Permit SemVer pre-release publication.
559 ## [2.3.10-2] - 2023-03-18
563 - Fix package.json `exports` syntax for ESM and CommonJS.
565 ## [2.3.10-1] - 2023-03-18
569 - Permit SemVer pre-release publication.
571 ## [2.3.10-0] - 2023-03-18
575 - Fix package.json `exports` syntax for ESM and CommonJS.
577 ## [2.3.9] - 2023-03-18
581 - Introduce ESM module support along with CommonJS one.
585 - Fix brown paper bag bug referencing the same object literal.
587 ## [2.3.8] - 2023-03-18
591 - Switch internal benchmarking code to benny.
592 - Switch to TypeScript 5.x.x.
593 - Switch rollup bundler plugins to core ones.
594 - Switch to TSDoc syntax.
595 - Enforce conventional commits.
599 - Fix random integer generator.
600 - Fix worker choice strategy pool type identification at initialization.
602 ## [2.3.7] - 2022-10-23
606 - Switch to open collective FOSS project funding platform.
607 - Switch to ts-standard linter configuration on TypeScript code.
611 - Fixed missing async on pool execute method.
612 - Fixed typing in TypeScript example.
613 - Fixed types in unit tests.
615 ## [2.3.6] - 2022-10-22
619 - Cleanup pool attributes and methods.
620 - Refine error types thrown.
624 - Fix continuous integration build on windows.
625 - Fix code coverage reporting by using c8 instead of nyc.
627 ## [2.3.5] - 2022-10-21
631 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
632 - Optimize tasks usage lookup implementation.
636 - Fix missed pool event emitter type export.
637 - Fix typedoc documentation generation.
639 ## [2.3.4] - 2022-10-17
643 - Fully automate release process with release-it.
647 - Optimize fair share task scheduling algorithm implementation.
648 - Update benchmarks versus external pools results with latest version.
650 ## [2.3.3] - 2022-10-15
654 - Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
656 ## [2.3.2] - 2022-10-14
660 - Optimize fair share worker selection strategy implementation.
664 - Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
666 ## [2.3.1] - 2022-10-13
670 - Pool worker choice strategies:
671 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
672 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
674 ## [2.2.2] - 2022-10-09
678 - Fixed `README.md` file.
680 ## [2.2.1] - 2022-10-08
684 - Dynamic worker choice strategy change at runtime.
686 ## [2.2.0] - 2022-01-05
690 - Support only Node.js version 16.x.x for cluster pool: upstream cluster API have changed on that version.
692 ## [2.1.0] - 2021-08-29
696 - Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
700 - `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
701 - `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
702 - `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
703 - `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
705 ## [2.0.2] - 2021-05-12
709 - Fix `busy` event emission on fixed pool type
711 ## [2.0.1] - 2021-03-16
715 - Check if pool options are properly set.
716 - `busy` event is emitted on all pool types.
718 ## [2.0.0] - 2021-03-01
722 - Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
726 - `FullPool` event is now renamed to `busy`.
727 - `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
728 _Find more details on our JSDoc._
730 - `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
732 - We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
734 ### Pool options types declaration merge
736 `FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
738 #### New `export` strategy
742 const DynamicThreadPool = require('poolifier/lib/dynamic')
744 const { DynamicThreadPool } = require('poolifier/lib/dynamic')
747 But you should always prefer just using
750 const { DynamicThreadPool } = require('poolifier')
753 #### New type definitions for input data and response
755 For cluster worker and worker-thread pools, you can now only send and receive structured-cloneable data.
756 _This is not a limitation by poolifier but Node.js._
758 #### Public property replacements
760 `numWorkers` property is now `numberOfWorkers`
762 #### Internal (protected) properties and methods renaming
764 These properties are not intended for end users
766 - `id` => `nextMessageId`
768 These methods are not intended for end users
770 - `_chooseWorker` => `chooseWorker`
771 - `_newWorker` => `createWorker`
772 - `_execute` => `internalExecute`
773 - `_chooseWorker` => `chooseWorker`
774 - `_checkAlive` => `checkAlive`
776 - `_runAsync` => `runAsync`
778 ## [1.1.0] - 2020-05-21
782 - ThreadWorker support async functions as option
783 - Various external library patches
785 ## [1.0.0] - 2020-01-24
789 - FixedThreadPool implementation
790 - DynamicThreadPool implementation
791 - WorkerThread implementation to improve developer experience