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.22] - 2023-08-10
14 - Structure markdown documentation (PR #811).
18 - Add missing `types` field to package.json `exports`.
20 ## [2.6.21] - 2023-08-03
24 - Improve code documentation.
25 - Code refactoring and cleanup for better maintainability and readability.
27 ## [2.6.20] - 2023-07-21
31 - Fix queued tasks redistribution on error task execution starvation.
32 - Ensure task queueing per worker condition is untangled from the pool busyness semantic.
36 - Drastically reduce lookups by worker in the worker nodes.
38 ## [2.6.19] - 2023-07-20
42 - Dedicated internal communication channel for worker_threads pools.
44 ## [2.6.18] - 2023-07-19
48 - Code refactoring and cleanup for better maintainability and readability. Bundle size is a bit smaller.
50 ## [2.6.17] - 2023-07-16
54 - Add `listTaskFunctions()` method to worker class.
56 ## [2.6.16] - 2023-07-12
60 - Fix pool startup detection.
61 - Fix worker task functions handling.
63 ## [2.6.15] - 2023-07-11
67 - Take into account worker node readiness in worker choice strategies.
69 ## [2.6.14] - 2023-07-10
73 - Fix task function statistics tracking.
75 ## [2.6.13] - 2023-07-10
79 - Add per task function statistics tracking.
80 - Add public methods to manipulate the worker task functions at runtime.
82 ## [2.6.12] - 2023-07-09
86 - Workaround import issue with `node:os` module in node 16.x.x.
88 ## [2.6.11] - 2023-07-09
92 - Fix pool readiness semantic.
94 ## [2.6.10] - 2023-07-08
98 - Ensure workers are not recreated on error at pool startup.
102 - Add `ready` and `strategy` fields to pool information.
103 - Add pool event `ready` to notify when the number of workers created in the pool has reached the maximum size expected and are ready.
104 - Add dynamic pool sizing checks.
106 ## [2.6.9] - 2023-07-07
110 - Recreate the right worker type on uncaught exception.
114 - Add minimum and maximum to internal measurement statistics.
115 - Add `runTime` and `waitTime` to pool information.
116 - Check worker inactive time only on dynamic worker.
118 ## [2.6.8] - 2023-07-03
122 - Brown paper bag release to fix version handling in pool information.
124 ## [2.6.7] - 2023-07-03
128 - Ensure worker queued tasks at error are reassigned to other pool workers.
132 - Add pool `utilization` ratio to pool information.
133 - Add `version` to pool information.
134 - Add worker information to worker nodes.
136 ## [2.6.6] - 2023-07-01
140 - Add safe helper `availableParallelism` to help sizing the pool.
144 - Ensure message handler is only registered in worker.
146 ## [2.6.5] - 2023-06-27
150 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
154 - Artificial version bump to 2.6.5 to workaround publication issue.
155 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
156 - Ensure pool event is emitted before task error promise rejection.
157 - Fix queued tasks count computation.
161 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
163 ## [2.6.4] - 2023-06-27
167 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
171 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
172 - Ensure pool event is emitted before task error promise rejection.
173 - Fix queued tasks count computation.
177 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
179 ## [2.6.3] - 2023-06-19
183 - Ensure no tasks are queued when trying to soft kill a dynamic worker.
184 - Update strategies internals after statistics computation.
188 - Optimize O(1) queue implementation.
190 ## [2.6.2] - 2023-06-12
194 - Fix new worker use after creation in dynamic pool given the current worker choice strategy.
196 ## [2.6.1] - 2023-06-10
200 - Add worker choice strategy documentation: [README.md](./src/pools/selection-strategies/README.md).
204 - Fix average statistics computation: ensure failed tasks are not accounted.
206 ## [2.6.0] - 2023-06-09
210 - Add `LEAST_ELU` worker choice strategy (experimental).
211 - Add tasks ELU instead of runtime support to `FAIR_SHARE` worker choice strategy.
215 - Refactor pool worker node usage internals.
216 - Breaking change: refactor worker choice strategy statistics requirements: the syntax of the worker choice strategy options has changed.
217 - Breaking change: pool information `info` property object fields have been renamed.
221 - Fix wait time accounting.
222 - Ensure worker choice strategy `LEAST_BUSY` accounts also tasks wait time.
223 - Ensure worker choice strategy `LEAST_USED` accounts also queued tasks.
225 ## [2.5.4] - 2023-06-07
229 - Add Event Loop Utilization (ELU) statistics to worker tasks usage.
233 - Compute statistics at the worker level only if needed.
234 - Add `worker_threads` options to thread pool options.
238 - Make the `LEAST_BUSY` strategy only relies on task runtime.
240 ## [2.5.3] - 2023-06-04
244 - Refine pool information content.
245 - Limit pool internals public exposure.
247 ## [2.5.2] - 2023-06-02
251 - Add `taskError` pool event for task execution error.
252 - Add pool information `info` property to pool.
253 - Emit pool information on `busy` and `full` pool events.
255 ## [2.5.1] - 2023-06-01
259 - Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
260 - Add `error` pool event for uncaught worker error.
262 ## [2.5.0] - 2023-05-31
266 - Switch pool event emitter to `EventEmitterAsyncResource`.
267 - Add tasks wait time accounting in per worker tasks usage.
268 - Add interleaved weighted round robin `INTERLEAVED_WEIGHTED_ROUND_ROBIN` worker choice strategy (experimental).
272 - Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
274 ## [2.4.14] - 2023-05-09
278 - Ensure no undefined task runtime can land in the tasks history.
279 - Fix median computation implementation once again.
283 - Unit tests for median and queue implementations.
285 ## [2.4.13] - 2023-05-08
289 - Fix worker choice strategy options validation.
290 - Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
292 ## [2.4.12] - 2023-05-06
296 - Support multiple task functions per worker.
297 - Add custom worker weights support to worker choice strategies options.
301 - Use O(1) queue implementation for tasks queueing.
305 - Fix median computation implementation.
306 - Fix fair share worker choice strategy internals update.
308 ## [2.4.11] - 2023-04-23
312 - Optimize free worker finding in worker choice strategies.
314 ## [2.4.10] - 2023-04-15
318 - Fix typescript type definition for task function: ensure the input data is optional.
319 - Fix typescript type definition for pool execute(): ensure the input data is optional.
321 ## [2.4.9] - 2023-04-15
325 - Add tasks queue enablement runtime setter to pool.
326 - Add tasks queue options runtime setter to pool.
327 - Add worker choice strategy options runtime setter to pool.
331 - Remove the tasks queuing experimental status.
335 - Fix task function type definition and validation.
336 - Fix worker choice strategy options handling.
338 ## [2.4.8] - 2023-04-12
342 - Fix message between main worker and worker type definition for tasks.
343 - Fix code documentation.
345 ## [2.4.7] - 2023-04-11
349 - Add worker tasks queue options to pool options.
353 - Fix missing documentation.
355 ## [2.4.6] - 2023-04-10
359 - Ensure one task at a time is executed per worker with tasks queueing enabled.
360 - Properly count worker executing tasks with tasks queueing enabled.
362 ## [2.4.5] - 2023-04-09
366 - Use monotonic high resolution timer for worker tasks runtime.
367 - Add worker tasks median runtime to statistics.
368 - Add worker tasks queue (experimental).
370 ## [2.4.4] - 2023-04-07
374 - Add `PoolEvents` enumeration and `PoolEvent` type.
378 - Destroy worker only on alive check.
380 ## [2.4.3] - 2023-04-07
384 - Fix typedoc generation with inheritance.
386 ## [2.4.2] - 2023-04-06
390 - Add `full` event to dynamic pool.
391 - Keep worker choice strategy in memory for conditional reuse.
395 - Fix possible negative worker key at worker removal in worker choice strategies.
397 ## [2.4.1] - 2023-04-05
401 - Optimize worker choice strategy for dynamic pool.
405 - Ensure dynamic pool does not alter worker choice strategy expected behavior.
407 ## [2.4.0] - 2023-04-04
411 - Add `LESS_BUSY` worker choice strategy.
415 - Optimize worker storage in pool.
416 - Optimize worker alive status check.
417 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
418 - Optimize `LESS_USED` worker choice strategy.
419 - Update benchmarks versus external threads pools.
420 - Optimize tasks usage statistics requirements for worker choice strategy.
424 - Ensure trimmable characters are checked at pool initialization.
425 - Fix message id integer overflow.
426 - Fix pool worker removal in worker choice strategy internals.
427 - Fix package publication with pnpm.
429 ## [2.4.0-3] - 2023-04-04
433 - Add `LESS_BUSY` worker choice strategy.
437 - Optimize worker storage in pool.
438 - Optimize worker alive status check.
439 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
440 - Optimize `LESS_USED` worker choice strategy.
441 - Update benchmarks versus external threads pools.
445 - Ensure trimmable characters are checked at pool initialization.
446 - Fix message id integer overflow.
447 - Fix pool worker removal in worker choice strategy internals.
448 - Fix package publication with pnpm.
450 ## [2.4.0-2] - 2023-04-03
454 - Add `LESS_BUSY` worker choice strategy.
458 - Optimize worker storage in pool.
459 - Optimize worker alive status check.
460 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
461 - Optimize `LESS_USED` 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-1] - 2023-04-03
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.
485 - Ensure trimmable characters are checked at pool initialization.
486 - Fix message id integer overflow.
487 - Fix pool worker removal in worker choice strategy internals.
489 ## [2.4.0-0] - 2023-04-03
493 - Add `LESS_BUSY` worker choice strategy.
497 - Optimize worker storage in pool.
498 - Optimize worker alive status check.
499 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
500 - Optimize `LESS_USED` worker choice strategy.
504 - Ensure trimmable characters are checked at pool initialization.
505 - Fix message id integer overflow.
506 - Fix pool worker removal in worker choice strategy internals.
508 ## [2.3.10] - 2023-03-18
512 - Fix package.json `exports` syntax for ESM and CommonJS.
516 - Permit SemVer pre-release publication.
518 ## [2.3.10-2] - 2023-03-18
522 - Fix package.json `exports` syntax for ESM and CommonJS.
524 ## [2.3.10-1] - 2023-03-18
528 - Permit SemVer pre-release publication.
530 ## [2.3.10-0] - 2023-03-18
534 - Fix package.json `exports` syntax for ESM and CommonJS.
536 ## [2.3.9] - 2023-03-18
540 - Introduce ESM module support along with CommonJS one.
544 - Fix brown paper bag bug referencing the same object literal.
546 ## [2.3.8] - 2023-03-18
550 - Switch internal benchmarking code to benny.
551 - Switch to TypeScript 5.x.x.
552 - Switch rollup bundler plugins to core ones.
553 - Switch to TSDoc syntax.
554 - Enforce conventional commits.
558 - Fix random integer generator.
559 - Fix worker choice strategy pool type identification at initialization.
561 ## [2.3.7] - 2022-10-23
565 - Switch to open collective FOSS project funding platform.
566 - Switch to ts-standard linter configuration on TypeScript code.
570 - Fixed missing async on pool execute method.
571 - Fixed typing in TypeScript example.
572 - Fixed types in unit tests.
574 ## [2.3.6] - 2022-10-22
578 - Cleanup pool attributes and methods.
579 - Refine error types thrown.
583 - Fix continuous integration build on windows.
584 - Fix code coverage reporting by using c8 instead of nyc.
586 ## [2.3.5] - 2022-10-21
590 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
591 - Optimize tasks usage lookup implementation.
595 - Fix missed pool event emitter type export.
596 - Fix typedoc documentation generation.
598 ## [2.3.4] - 2022-10-17
602 - Fully automate release process with release-it.
606 - Optimize fair share task scheduling algorithm implementation.
607 - Update benchmarks versus external pools results with latest version.
609 ## [2.3.3] - 2022-10-15
613 - Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
615 ## [2.3.2] - 2022-10-14
619 - Optimize fair share worker selection strategy implementation.
623 - Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
625 ## [2.3.1] - 2022-10-13
629 - Pool worker choice strategies:
630 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
631 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
633 ## [2.2.2] - 2022-10-09
637 - Fixed `README.md` file.
639 ## [2.2.1] - 2022-10-08
643 - Dynamic worker choice strategy change at runtime.
645 ## [2.2.0] - 2022-01-05
649 - Support only Node.js version 16.x.x for cluster pool: upstream cluster API have changed on that version.
651 ## [2.1.0] - 2021-08-29
655 - Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
659 - `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
660 - `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
661 - `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
662 - `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
664 ## [2.0.2] - 2021-05-12
668 - Fix `busy` event emission on fixed pool type
670 ## [2.0.1] - 2021-03-16
674 - Check if pool options are properly set.
675 - `busy` event is emitted on all pool types.
677 ## [2.0.0] - 2021-03-01
681 - Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
685 - `FullPool` event is now renamed to `busy`.
686 - `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
687 _Find more details on our JSDoc._
689 - `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
691 - We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
693 ### Pool options types declaration merge
695 `FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
697 #### New `export` strategy
701 const DynamicThreadPool = require('poolifier/lib/dynamic')
703 const { DynamicThreadPool } = require('poolifier/lib/dynamic')
706 But you should always prefer just using
709 const { DynamicThreadPool } = require('poolifier')
712 #### New type definitions for input data and response
714 For cluster worker and worker-thread pools, you can now only send and receive structured-cloneable data.
715 _This is not a limitation by poolifier but Node.js._
717 #### Public property replacements
719 `numWorkers` property is now `numberOfWorkers`
721 #### Internal (protected) properties and methods renaming
723 These properties are not intended for end users
725 - `id` => `nextMessageId`
727 These methods are not intended for end users
729 - `_chooseWorker` => `chooseWorker`
730 - `_newWorker` => `createWorker`
731 - `_execute` => `internalExecute`
732 - `_chooseWorker` => `chooseWorker`
733 - `_checkAlive` => `checkAlive`
735 - `_runAsync` => `runAsync`
737 ## [1.1.0] - 2020-05-21
741 - ThreadWorker support async functions as option
742 - Various external library patches
744 ## [1.0.0] - 2020-01-24
748 - FixedThreadPool implementation
749 - DynamicThreadPool implementation
750 - WorkerThread implementation to improve developer experience