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 - Improve code documentation.
13 - Code refactoring and cleanup for better maintainability and readability.
15 ## [2.6.20] - 2023-07-21
19 - Fix queued tasks redistribution on error task execution starvation.
20 - Ensure task queueing per worker condition is untangled from the pool busyness semantic.
24 - Drastically reduce lookups by worker in the worker nodes.
26 ## [2.6.19] - 2023-07-20
30 - Dedicated internal communication channel for worker_threads pools.
32 ## [2.6.18] - 2023-07-19
36 - Code refactoring and cleanup for better maintainability and readability. Bundle size is a bit smaller.
38 ## [2.6.17] - 2023-07-16
42 - Add `listTaskFunctions()` method to worker class.
44 ## [2.6.16] - 2023-07-12
48 - Fix pool startup detection.
49 - Fix worker task functions handling.
51 ## [2.6.15] - 2023-07-11
55 - Take into account worker node readiness in worker choice strategies.
57 ## [2.6.14] - 2023-07-10
61 - Fix task function statistics tracking.
63 ## [2.6.13] - 2023-07-10
67 - Add per task function statistics tracking.
68 - Add public methods to manipulate the worker task functions at runtime.
70 ## [2.6.12] - 2023-07-09
74 - Workaround import issue with `node:os` module in node 16.x.x.
76 ## [2.6.11] - 2023-07-09
80 - Fix pool readiness semantic.
82 ## [2.6.10] - 2023-07-08
86 - Ensure workers are not recreated on error at pool startup.
90 - Add `ready` and `strategy` fields to pool information.
91 - Add pool event `ready` to notify when the number of workers created in the pool has reached the maximum size expected and are ready.
92 - Add dynamic pool sizing checks.
94 ## [2.6.9] - 2023-07-07
98 - Recreate the right worker type on uncaught exception.
102 - Add minimum and maximum to internal measurement statistics.
103 - Add `runTime` and `waitTime` to pool information.
104 - Check worker inactive time only on dynamic worker.
106 ## [2.6.8] - 2023-07-03
110 - Brown paper bag release to fix version handling in pool information.
112 ## [2.6.7] - 2023-07-03
116 - Ensure worker queued tasks at error are reassigned to other pool workers.
120 - Add pool `utilization` ratio to pool information.
121 - Add `version` to pool information.
122 - Add worker information to worker nodes.
124 ## [2.6.6] - 2023-07-01
128 - Add safe helper `availableParallelism` to help sizing the pool.
132 - Ensure message handler is only registered in worker.
134 ## [2.6.5] - 2023-06-27
138 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
142 - Artificial version bump to 2.6.5 to workaround publication issue.
143 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
144 - Ensure pool event is emitted before task error promise rejection.
145 - Fix queued tasks count computation.
149 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
151 ## [2.6.4] - 2023-06-27
155 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
159 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
160 - Ensure pool event is emitted before task error promise rejection.
161 - Fix queued tasks count computation.
165 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
167 ## [2.6.3] - 2023-06-19
171 - Ensure no tasks are queued when trying to soft kill a dynamic worker.
172 - Update strategies internals after statistics computation.
176 - Optimize O(1) queue implementation.
178 ## [2.6.2] - 2023-06-12
182 - Fix new worker use after creation in dynamic pool given the current worker choice strategy.
184 ## [2.6.1] - 2023-06-10
188 - Add worker choice strategy documentation: [README.md](./src/pools/selection-strategies/README.md).
192 - Fix average statistics computation: ensure failed tasks are not accounted.
194 ## [2.6.0] - 2023-06-09
198 - Add `LEAST_ELU` worker choice strategy (experimental).
199 - Add tasks ELU instead of runtime support to `FAIR_SHARE` worker choice strategy.
203 - Refactor pool worker node usage internals.
204 - Breaking change: refactor worker choice strategy statistics requirements: the syntax of the worker choice strategy options has changed.
205 - Breaking change: pool information `info` property object fields have been renamed.
209 - Fix wait time accounting.
210 - Ensure worker choice strategy `LEAST_BUSY` accounts also tasks wait time.
211 - Ensure worker choice strategy `LEAST_USED` accounts also queued tasks.
213 ## [2.5.4] - 2023-06-07
217 - Add Event Loop Utilization (ELU) statistics to worker tasks usage.
221 - Compute statistics at the worker level only if needed.
222 - Add `worker_threads` options to thread pool options.
226 - Make the `LEAST_BUSY` strategy only relies on task runtime.
228 ## [2.5.3] - 2023-06-04
232 - Refine pool information content.
233 - Limit pool internals public exposure.
235 ## [2.5.2] - 2023-06-02
239 - Add `taskError` pool event for task execution error.
240 - Add pool information `info` property to pool.
241 - Emit pool information on `busy` and `full` pool events.
243 ## [2.5.1] - 2023-06-01
247 - Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
248 - Add `error` pool event for uncaught worker error.
250 ## [2.5.0] - 2023-05-31
254 - Switch pool event emitter to `EventEmitterAsyncResource`.
255 - Add tasks wait time accounting in per worker tasks usage.
256 - Add interleaved weighted round robin `INTERLEAVED_WEIGHTED_ROUND_ROBIN` worker choice strategy (experimental).
260 - Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
262 ## [2.4.14] - 2023-05-09
266 - Ensure no undefined task runtime can land in the tasks history.
267 - Fix median computation implementation once again.
271 - Unit tests for median and queue implementations.
273 ## [2.4.13] - 2023-05-08
277 - Fix worker choice strategy options validation.
278 - Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
280 ## [2.4.12] - 2023-05-06
284 - Support multiple task functions per worker.
285 - Add custom worker weights support to worker choice strategies options.
289 - Use O(1) queue implementation for tasks queueing.
293 - Fix median computation implementation.
294 - Fix fair share worker choice strategy internals update.
296 ## [2.4.11] - 2023-04-23
300 - Optimize free worker finding in worker choice strategies.
302 ## [2.4.10] - 2023-04-15
306 - Fix typescript type definition for task function: ensure the input data is optional.
307 - Fix typescript type definition for pool execute(): ensure the input data is optional.
309 ## [2.4.9] - 2023-04-15
313 - Add tasks queue enablement runtime setter to pool.
314 - Add tasks queue options runtime setter to pool.
315 - Add worker choice strategy options runtime setter to pool.
319 - Remove the tasks queuing experimental status.
323 - Fix task function type definition and validation.
324 - Fix worker choice strategy options handling.
326 ## [2.4.8] - 2023-04-12
330 - Fix message between main worker and worker type definition for tasks.
331 - Fix code documentation.
333 ## [2.4.7] - 2023-04-11
337 - Add worker tasks queue options to pool options.
341 - Fix missing documentation.
343 ## [2.4.6] - 2023-04-10
347 - Ensure one task at a time is executed per worker with tasks queueing enabled.
348 - Properly count worker executing tasks with tasks queueing enabled.
350 ## [2.4.5] - 2023-04-09
354 - Use monotonic high resolution timer for worker tasks runtime.
355 - Add worker tasks median runtime to statistics.
356 - Add worker tasks queue (experimental).
358 ## [2.4.4] - 2023-04-07
362 - Add `PoolEvents` enumeration and `PoolEvent` type.
366 - Destroy worker only on alive check.
368 ## [2.4.3] - 2023-04-07
372 - Fix typedoc generation with inheritance.
374 ## [2.4.2] - 2023-04-06
378 - Add `full` event to dynamic pool.
379 - Keep worker choice strategy in memory for conditional reuse.
383 - Fix possible negative worker key at worker removal in worker choice strategies.
385 ## [2.4.1] - 2023-04-05
389 - Optimize worker choice strategy for dynamic pool.
393 - Ensure dynamic pool does not alter worker choice strategy expected behavior.
395 ## [2.4.0] - 2023-04-04
399 - Add `LESS_BUSY` worker choice strategy.
403 - Optimize worker storage in pool.
404 - Optimize worker alive status check.
405 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
406 - Optimize `LESS_USED` worker choice strategy.
407 - Update benchmarks versus external threads pools.
408 - Optimize tasks usage statistics requirements for worker choice strategy.
412 - Ensure trimmable characters are checked at pool initialization.
413 - Fix message id integer overflow.
414 - Fix pool worker removal in worker choice strategy internals.
415 - Fix package publication with pnpm.
417 ## [2.4.0-3] - 2023-04-04
421 - Add `LESS_BUSY` worker choice strategy.
425 - Optimize worker storage in pool.
426 - Optimize worker alive status check.
427 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
428 - Optimize `LESS_USED` worker choice strategy.
429 - Update benchmarks versus external threads pools.
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-2] - 2023-04-03
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.
453 - Ensure trimmable characters are checked at pool initialization.
454 - Fix message id integer overflow.
455 - Fix pool worker removal in worker choice strategy internals.
456 - Fix package publication with pnpm.
458 ## [2.4.0-1] - 2023-04-03
462 - Add `LESS_BUSY` worker choice strategy.
466 - Optimize worker storage in pool.
467 - Optimize worker alive status check.
468 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
469 - Optimize `LESS_USED` worker choice strategy.
473 - Ensure trimmable characters are checked at pool initialization.
474 - Fix message id integer overflow.
475 - Fix pool worker removal in worker choice strategy internals.
477 ## [2.4.0-0] - 2023-04-03
481 - Add `LESS_BUSY` worker choice strategy.
485 - Optimize worker storage in pool.
486 - Optimize worker alive status check.
487 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
488 - Optimize `LESS_USED` worker choice strategy.
492 - Ensure trimmable characters are checked at pool initialization.
493 - Fix message id integer overflow.
494 - Fix pool worker removal in worker choice strategy internals.
496 ## [2.3.10] - 2023-03-18
500 - Fix `exports` syntax for ESM and CommonJS.
504 - Permit SemVer pre-release publication.
506 ## [2.3.10-2] - 2023-03-18
510 - Fix `exports` syntax for ESM and CommonJS.
512 ## [2.3.10-1] - 2023-03-18
516 - Permit SemVer pre-release publication.
518 ## [2.3.10-0] - 2023-03-18
522 - Fix `exports` syntax for ESM and CommonJS.
524 ## [2.3.9] - 2023-03-18
528 - Introduce ESM module support along with CommonJS one.
532 - Fix brown paper bag bug referencing the same object literal.
534 ## [2.3.8] - 2023-03-18
538 - Switch internal benchmarking code to benny.
539 - Switch to TypeScript 5.x.x.
540 - Switch rollup bundler plugins to core ones.
541 - Switch to TSDoc syntax.
542 - Enforce conventional commits.
546 - Fix random integer generator.
547 - Fix worker choice strategy pool type identification at initialization.
549 ## [2.3.7] - 2022-10-23
553 - Switch to open collective FOSS project funding platform.
554 - Switch to ts-standard linter configuration on TypeScript code.
558 - Fixed missing async on pool execute method.
559 - Fixed typing in TypeScript example.
560 - Fixed types in unit tests.
562 ## [2.3.6] - 2022-10-22
566 - Cleanup pool attributes and methods.
567 - Refine error types thrown.
571 - Fix continuous integration build on windows.
572 - Fix code coverage reporting by using c8 instead of nyc.
574 ## [2.3.5] - 2022-10-21
578 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
579 - Optimize tasks usage lookup implementation.
583 - Fix missed pool event emitter type export.
584 - Fix typedoc documentation generation.
586 ## [2.3.4] - 2022-10-17
590 - Fully automate release process with release-it.
594 - Optimize fair share task scheduling algorithm implementation.
595 - Update benchmarks versus external pools results with latest version.
597 ## [2.3.3] - 2022-10-15
601 - Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
603 ## [2.3.2] - 2022-10-14
607 - Optimize fair share worker selection strategy implementation.
611 - Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
613 ## [2.3.1] - 2022-10-13
617 - Pool worker choice strategies:
618 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
619 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
621 ## [2.2.2] - 2022-10-09
625 - Fixed `README.md` file.
627 ## [2.2.1] - 2022-10-08
631 - Dynamic worker choice strategy change at runtime.
633 ## [2.2.0] - 2022-01-05
637 - Support only NodeJS version 16.x.x for cluster pool: upstream cluster API have changed on that version.
639 ## [2.1.0] - 2021-08-29
643 - Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
647 - `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
648 - `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
649 - `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
650 - `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
652 ## [2.0.2] - 2021-05-12
656 - Fix `busy` event emission on fixed pool type
658 ## [2.0.1] - 2021-03-16
662 - Check if pool options are properly set.
663 - `busy` event is emitted on all pool types.
665 ## [2.0.0] - 2021-03-01
669 - Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
673 - `FullPool` event is now renamed to `busy`.
674 - `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
675 _Find more details on our JSDoc._
677 - `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
679 - We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
681 ### Pool options types declaration merge
683 `FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
685 #### New `export` strategy
689 const DynamicThreadPool = require('poolifier/lib/dynamic')
691 const { DynamicThreadPool } = require('poolifier/lib/dynamic')
694 But you should always prefer just using
697 const { DynamicThreadPool } = require('poolifier')
700 #### New type definitions for input data and response
702 For cluster worker and worker-thread pools, you can now only send and receive structured-cloneable data.
703 _This is not a limitation by poolifier but NodeJS._
705 #### Public property replacements
707 `numWorkers` property is now `numberOfWorkers`
709 #### Internal (protected) properties and methods renaming
711 These properties are not intended for end users
713 - `id` => `nextMessageId`
715 These methods are not intended for end users
717 - `_chooseWorker` => `chooseWorker`
718 - `_newWorker` => `createWorker`
719 - `_execute` => `internalExecute`
720 - `_chooseWorker` => `chooseWorker`
721 - `_checkAlive` => `checkAlive`
723 - `_runAsync` => `runAsync`
725 ## [1.1.0] - 2020-05-21
729 - ThreadWorker support async functions as option
730 - Various external library patches
732 ## [1.0.0] - 2020-01-24
736 - FixedThreadPool implementation
737 - DynamicThreadPool implementation
738 - WorkerThread implementation to improve developer experience