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 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.
16 - HTTP client pool examples: fetch, node-fetch and axios with multiple task functions.
17 - HTTP server pool examples: express, fastify.
19 ## [2.6.22] - 2023-08-10
23 - Add missing `types` field to package.json `exports`.
27 - Structure markdown documentation (PR #811).
29 ## [2.6.21] - 2023-08-03
33 - Improve code documentation.
34 - Code refactoring and cleanup for better maintainability and readability.
36 ## [2.6.20] - 2023-07-21
40 - Fix queued tasks redistribution on error task execution starvation.
41 - Ensure task queueing per worker condition is untangled from the pool busyness semantic.
45 - Drastically reduce lookups by worker in the worker nodes.
47 ## [2.6.19] - 2023-07-20
51 - Dedicated internal communication channel for worker_threads pools.
53 ## [2.6.18] - 2023-07-19
57 - Code refactoring and cleanup for better maintainability and readability. Bundle size is a bit smaller.
59 ## [2.6.17] - 2023-07-16
63 - Add `listTaskFunctions()` method to worker class.
65 ## [2.6.16] - 2023-07-12
69 - Fix pool startup detection.
70 - Fix worker task functions handling.
72 ## [2.6.15] - 2023-07-11
76 - Take into account worker node readiness in worker choice strategies.
78 ## [2.6.14] - 2023-07-10
82 - Fix task function statistics tracking.
84 ## [2.6.13] - 2023-07-10
88 - Add per task function statistics tracking.
89 - Add public methods to manipulate the worker task functions at runtime.
91 ## [2.6.12] - 2023-07-09
95 - Workaround import issue with `node:os` module in node 16.x.x.
97 ## [2.6.11] - 2023-07-09
101 - Fix pool readiness semantic.
103 ## [2.6.10] - 2023-07-08
107 - Ensure workers are not recreated on error at pool startup.
111 - Add `ready` and `strategy` fields to pool information.
112 - Add pool event `ready` to notify when the number of workers created in the pool has reached the maximum size expected and are ready.
113 - Add dynamic pool sizing checks.
115 ## [2.6.9] - 2023-07-07
119 - Recreate the right worker type on uncaught exception.
123 - Add minimum and maximum to internal measurement statistics.
124 - Add `runTime` and `waitTime` to pool information.
125 - Check worker inactive time only on dynamic worker.
127 ## [2.6.8] - 2023-07-03
131 - Brown paper bag release to fix version handling in pool information.
133 ## [2.6.7] - 2023-07-03
137 - Ensure worker queued tasks at error are reassigned to other pool workers.
141 - Add pool `utilization` ratio to pool information.
142 - Add `version` to pool information.
143 - Add worker information to worker nodes.
145 ## [2.6.6] - 2023-07-01
149 - Add safe helper `availableParallelism` to help sizing the pool.
153 - Ensure message handler is only registered in worker.
155 ## [2.6.5] - 2023-06-27
159 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
163 - Artificial version bump to 2.6.5 to workaround publication issue.
164 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
165 - Ensure pool event is emitted before task error promise rejection.
166 - Fix queued tasks count computation.
170 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
172 ## [2.6.4] - 2023-06-27
176 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
180 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
181 - Ensure pool event is emitted before task error promise rejection.
182 - Fix queued tasks count computation.
186 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
188 ## [2.6.3] - 2023-06-19
192 - Ensure no tasks are queued when trying to soft kill a dynamic worker.
193 - Update strategies internals after statistics computation.
197 - Optimize O(1) queue implementation.
199 ## [2.6.2] - 2023-06-12
203 - Fix new worker use after creation in dynamic pool given the current worker choice strategy.
205 ## [2.6.1] - 2023-06-10
209 - Add worker choice strategy documentation: [README.md](./docs/worker-choice-strategies.md).
213 - Fix average statistics computation: ensure failed tasks are not accounted.
215 ## [2.6.0] - 2023-06-09
219 - Add `LEAST_ELU` worker choice strategy (experimental).
220 - Add tasks ELU instead of runtime support to `FAIR_SHARE` worker choice strategy.
224 - Refactor pool worker node usage internals.
225 - Breaking change: refactor worker choice strategy statistics requirements: the syntax of the worker choice strategy options has changed.
226 - Breaking change: pool information `info` property object fields have been renamed.
230 - Fix wait time accounting.
231 - Ensure worker choice strategy `LEAST_BUSY` accounts also tasks wait time.
232 - Ensure worker choice strategy `LEAST_USED` accounts also queued tasks.
234 ## [2.5.4] - 2023-06-07
238 - Add Event Loop Utilization (ELU) statistics to worker tasks usage.
242 - Compute statistics at the worker level only if needed.
243 - Add `worker_threads` options to thread pool options.
247 - Make the `LEAST_BUSY` strategy only relies on task runtime.
249 ## [2.5.3] - 2023-06-04
253 - Refine pool information content.
254 - Limit pool internals public exposure.
256 ## [2.5.2] - 2023-06-02
260 - Add `taskError` pool event for task execution error.
261 - Add pool information `info` property to pool.
262 - Emit pool information on `busy` and `full` pool events.
264 ## [2.5.1] - 2023-06-01
268 - Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
269 - Add `error` pool event for uncaught worker error.
271 ## [2.5.0] - 2023-05-31
275 - Switch pool event emitter to `EventEmitterAsyncResource`.
276 - Add tasks wait time accounting in per worker tasks usage.
277 - Add interleaved weighted round robin `INTERLEAVED_WEIGHTED_ROUND_ROBIN` worker choice strategy (experimental).
281 - Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
283 ## [2.4.14] - 2023-05-09
287 - Ensure no undefined task runtime can land in the tasks history.
288 - Fix median computation implementation once again.
292 - Unit tests for median and queue implementations.
294 ## [2.4.13] - 2023-05-08
298 - Fix worker choice strategy options validation.
299 - Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
301 ## [2.4.12] - 2023-05-06
305 - Support multiple task functions per worker.
306 - Add custom worker weights support to worker choice strategies options.
310 - Use O(1) queue implementation for tasks queueing.
314 - Fix median computation implementation.
315 - Fix fair share worker choice strategy internals update.
317 ## [2.4.11] - 2023-04-23
321 - Optimize free worker finding in worker choice strategies.
323 ## [2.4.10] - 2023-04-15
327 - Fix typescript type definition for task function: ensure the input data is optional.
328 - Fix typescript type definition for pool execute(): ensure the input data is optional.
330 ## [2.4.9] - 2023-04-15
334 - Add tasks queue enablement runtime setter to pool.
335 - Add tasks queue options runtime setter to pool.
336 - Add worker choice strategy options runtime setter to pool.
340 - Remove the tasks queuing experimental status.
344 - Fix task function type definition and validation.
345 - Fix worker choice strategy options handling.
347 ## [2.4.8] - 2023-04-12
351 - Fix message between main worker and worker type definition for tasks.
352 - Fix code documentation.
354 ## [2.4.7] - 2023-04-11
358 - Add worker tasks queue options to pool options.
362 - Fix missing documentation.
364 ## [2.4.6] - 2023-04-10
368 - Ensure one task at a time is executed per worker with tasks queueing enabled.
369 - Properly count worker executing tasks with tasks queueing enabled.
371 ## [2.4.5] - 2023-04-09
375 - Use monotonic high resolution timer for worker tasks runtime.
376 - Add worker tasks median runtime to statistics.
377 - Add worker tasks queue (experimental).
379 ## [2.4.4] - 2023-04-07
383 - Add `PoolEvents` enumeration and `PoolEvent` type.
387 - Destroy worker only on alive check.
389 ## [2.4.3] - 2023-04-07
393 - Fix typedoc generation with inheritance.
395 ## [2.4.2] - 2023-04-06
399 - Add `full` event to dynamic pool.
400 - Keep worker choice strategy in memory for conditional reuse.
404 - Fix possible negative worker key at worker removal in worker choice strategies.
406 ## [2.4.1] - 2023-04-05
410 - Optimize worker choice strategy for dynamic pool.
414 - Ensure dynamic pool does not alter worker choice strategy expected behavior.
416 ## [2.4.0] - 2023-04-04
420 - Add `LESS_BUSY` worker choice strategy.
424 - Optimize worker storage in pool.
425 - Optimize worker alive status check.
426 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
427 - Optimize `LESS_USED` worker choice strategy.
428 - Update benchmarks versus external threads pools.
429 - Optimize tasks usage statistics requirements for worker choice strategy.
433 - Ensure trimmable characters are checked at pool initialization.
434 - Fix message id integer overflow.
435 - Fix pool worker removal in worker choice strategy internals.
436 - Fix package publication with pnpm.
438 ## [2.4.0-3] - 2023-04-04
442 - Add `LESS_BUSY` worker choice strategy.
446 - Optimize worker storage in pool.
447 - Optimize worker alive status check.
448 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
449 - Optimize `LESS_USED` worker choice strategy.
450 - Update benchmarks versus external threads pools.
454 - Ensure trimmable characters are checked at pool initialization.
455 - Fix message id integer overflow.
456 - Fix pool worker removal in worker choice strategy internals.
457 - Fix package publication with pnpm.
459 ## [2.4.0-2] - 2023-04-03
463 - Add `LESS_BUSY` worker choice strategy.
467 - Optimize worker storage in pool.
468 - Optimize worker alive status check.
469 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
470 - Optimize `LESS_USED` worker choice strategy.
474 - Ensure trimmable characters are checked at pool initialization.
475 - Fix message id integer overflow.
476 - Fix pool worker removal in worker choice strategy internals.
477 - Fix package publication with pnpm.
479 ## [2.4.0-1] - 2023-04-03
483 - Add `LESS_BUSY` worker choice strategy.
487 - Optimize worker storage in pool.
488 - Optimize worker alive status check.
489 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
490 - Optimize `LESS_USED` worker choice strategy.
494 - Ensure trimmable characters are checked at pool initialization.
495 - Fix message id integer overflow.
496 - Fix pool worker removal in worker choice strategy internals.
498 ## [2.4.0-0] - 2023-04-03
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.
513 - Ensure trimmable characters are checked at pool initialization.
514 - Fix message id integer overflow.
515 - Fix pool worker removal in worker choice strategy internals.
517 ## [2.3.10] - 2023-03-18
521 - Fix package.json `exports` syntax for ESM and CommonJS.
525 - Permit SemVer pre-release publication.
527 ## [2.3.10-2] - 2023-03-18
531 - Fix package.json `exports` syntax for ESM and CommonJS.
533 ## [2.3.10-1] - 2023-03-18
537 - Permit SemVer pre-release publication.
539 ## [2.3.10-0] - 2023-03-18
543 - Fix package.json `exports` syntax for ESM and CommonJS.
545 ## [2.3.9] - 2023-03-18
549 - Introduce ESM module support along with CommonJS one.
553 - Fix brown paper bag bug referencing the same object literal.
555 ## [2.3.8] - 2023-03-18
559 - Switch internal benchmarking code to benny.
560 - Switch to TypeScript 5.x.x.
561 - Switch rollup bundler plugins to core ones.
562 - Switch to TSDoc syntax.
563 - Enforce conventional commits.
567 - Fix random integer generator.
568 - Fix worker choice strategy pool type identification at initialization.
570 ## [2.3.7] - 2022-10-23
574 - Switch to open collective FOSS project funding platform.
575 - Switch to ts-standard linter configuration on TypeScript code.
579 - Fixed missing async on pool execute method.
580 - Fixed typing in TypeScript example.
581 - Fixed types in unit tests.
583 ## [2.3.6] - 2022-10-22
587 - Cleanup pool attributes and methods.
588 - Refine error types thrown.
592 - Fix continuous integration build on windows.
593 - Fix code coverage reporting by using c8 instead of nyc.
595 ## [2.3.5] - 2022-10-21
599 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
600 - Optimize tasks usage lookup implementation.
604 - Fix missed pool event emitter type export.
605 - Fix typedoc documentation generation.
607 ## [2.3.4] - 2022-10-17
611 - Fully automate release process with release-it.
615 - Optimize fair share task scheduling algorithm implementation.
616 - Update benchmarks versus external pools results with latest version.
618 ## [2.3.3] - 2022-10-15
622 - Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
624 ## [2.3.2] - 2022-10-14
628 - Optimize fair share worker selection strategy implementation.
632 - Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
634 ## [2.3.1] - 2022-10-13
638 - Pool worker choice strategies:
639 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
640 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
642 ## [2.2.2] - 2022-10-09
646 - Fixed `README.md` file.
648 ## [2.2.1] - 2022-10-08
652 - Dynamic worker choice strategy change at runtime.
654 ## [2.2.0] - 2022-01-05
658 - Support only Node.js version 16.x.x for cluster pool: upstream cluster API have changed on that version.
660 ## [2.1.0] - 2021-08-29
664 - Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
668 - `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
669 - `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
670 - `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
671 - `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
673 ## [2.0.2] - 2021-05-12
677 - Fix `busy` event emission on fixed pool type
679 ## [2.0.1] - 2021-03-16
683 - Check if pool options are properly set.
684 - `busy` event is emitted on all pool types.
686 ## [2.0.0] - 2021-03-01
690 - Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
694 - `FullPool` event is now renamed to `busy`.
695 - `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
696 _Find more details on our JSDoc._
698 - `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
700 - We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
702 ### Pool options types declaration merge
704 `FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
706 #### New `export` strategy
710 const DynamicThreadPool = require('poolifier/lib/dynamic')
712 const { DynamicThreadPool } = require('poolifier/lib/dynamic')
715 But you should always prefer just using
718 const { DynamicThreadPool } = require('poolifier')
721 #### New type definitions for input data and response
723 For cluster worker and worker-thread pools, you can now only send and receive structured-cloneable data.
724 _This is not a limitation by poolifier but Node.js._
726 #### Public property replacements
728 `numWorkers` property is now `numberOfWorkers`
730 #### Internal (protected) properties and methods renaming
732 These properties are not intended for end users
734 - `id` => `nextMessageId`
736 These methods are not intended for end users
738 - `_chooseWorker` => `chooseWorker`
739 - `_newWorker` => `createWorker`
740 - `_execute` => `internalExecute`
741 - `_chooseWorker` => `chooseWorker`
742 - `_checkAlive` => `checkAlive`
744 - `_runAsync` => `runAsync`
746 ## [1.1.0] - 2020-05-21
750 - ThreadWorker support async functions as option
751 - Various external library patches
753 ## [1.0.0] - 2020-01-24
757 - FixedThreadPool implementation
758 - DynamicThreadPool implementation
759 - WorkerThread implementation to improve developer experience