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.21] - 2023-08-03
14 - Improve code documentation.
15 - Code refactoring and cleanup for better maintainability and readability.
17 ## [2.6.20] - 2023-07-21
21 - Fix queued tasks redistribution on error task execution starvation.
22 - Ensure task queueing per worker condition is untangled from the pool busyness semantic.
26 - Drastically reduce lookups by worker in the worker nodes.
28 ## [2.6.19] - 2023-07-20
32 - Dedicated internal communication channel for worker_threads pools.
34 ## [2.6.18] - 2023-07-19
38 - Code refactoring and cleanup for better maintainability and readability. Bundle size is a bit smaller.
40 ## [2.6.17] - 2023-07-16
44 - Add `listTaskFunctions()` method to worker class.
46 ## [2.6.16] - 2023-07-12
50 - Fix pool startup detection.
51 - Fix worker task functions handling.
53 ## [2.6.15] - 2023-07-11
57 - Take into account worker node readiness in worker choice strategies.
59 ## [2.6.14] - 2023-07-10
63 - Fix task function statistics tracking.
65 ## [2.6.13] - 2023-07-10
69 - Add per task function statistics tracking.
70 - Add public methods to manipulate the worker task functions at runtime.
72 ## [2.6.12] - 2023-07-09
76 - Workaround import issue with `node:os` module in node 16.x.x.
78 ## [2.6.11] - 2023-07-09
82 - Fix pool readiness semantic.
84 ## [2.6.10] - 2023-07-08
88 - Ensure workers are not recreated on error at pool startup.
92 - Add `ready` and `strategy` fields to pool information.
93 - Add pool event `ready` to notify when the number of workers created in the pool has reached the maximum size expected and are ready.
94 - Add dynamic pool sizing checks.
96 ## [2.6.9] - 2023-07-07
100 - Recreate the right worker type on uncaught exception.
104 - Add minimum and maximum to internal measurement statistics.
105 - Add `runTime` and `waitTime` to pool information.
106 - Check worker inactive time only on dynamic worker.
108 ## [2.6.8] - 2023-07-03
112 - Brown paper bag release to fix version handling in pool information.
114 ## [2.6.7] - 2023-07-03
118 - Ensure worker queued tasks at error are reassigned to other pool workers.
122 - Add pool `utilization` ratio to pool information.
123 - Add `version` to pool information.
124 - Add worker information to worker nodes.
126 ## [2.6.6] - 2023-07-01
130 - Add safe helper `availableParallelism` to help sizing the pool.
134 - Ensure message handler is only registered in worker.
136 ## [2.6.5] - 2023-06-27
140 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
144 - Artificial version bump to 2.6.5 to workaround publication issue.
145 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
146 - Ensure pool event is emitted before task error promise rejection.
147 - Fix queued tasks count computation.
151 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
153 ## [2.6.4] - 2023-06-27
157 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
161 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
162 - Ensure pool event is emitted before task error promise rejection.
163 - Fix queued tasks count computation.
167 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
169 ## [2.6.3] - 2023-06-19
173 - Ensure no tasks are queued when trying to soft kill a dynamic worker.
174 - Update strategies internals after statistics computation.
178 - Optimize O(1) queue implementation.
180 ## [2.6.2] - 2023-06-12
184 - Fix new worker use after creation in dynamic pool given the current worker choice strategy.
186 ## [2.6.1] - 2023-06-10
190 - Add worker choice strategy documentation: [README.md](./src/pools/selection-strategies/README.md).
194 - Fix average statistics computation: ensure failed tasks are not accounted.
196 ## [2.6.0] - 2023-06-09
200 - Add `LEAST_ELU` worker choice strategy (experimental).
201 - Add tasks ELU instead of runtime support to `FAIR_SHARE` worker choice strategy.
205 - Refactor pool worker node usage internals.
206 - Breaking change: refactor worker choice strategy statistics requirements: the syntax of the worker choice strategy options has changed.
207 - Breaking change: pool information `info` property object fields have been renamed.
211 - Fix wait time accounting.
212 - Ensure worker choice strategy `LEAST_BUSY` accounts also tasks wait time.
213 - Ensure worker choice strategy `LEAST_USED` accounts also queued tasks.
215 ## [2.5.4] - 2023-06-07
219 - Add Event Loop Utilization (ELU) statistics to worker tasks usage.
223 - Compute statistics at the worker level only if needed.
224 - Add `worker_threads` options to thread pool options.
228 - Make the `LEAST_BUSY` strategy only relies on task runtime.
230 ## [2.5.3] - 2023-06-04
234 - Refine pool information content.
235 - Limit pool internals public exposure.
237 ## [2.5.2] - 2023-06-02
241 - Add `taskError` pool event for task execution error.
242 - Add pool information `info` property to pool.
243 - Emit pool information on `busy` and `full` pool events.
245 ## [2.5.1] - 2023-06-01
249 - Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
250 - Add `error` pool event for uncaught worker error.
252 ## [2.5.0] - 2023-05-31
256 - Switch pool event emitter to `EventEmitterAsyncResource`.
257 - Add tasks wait time accounting in per worker tasks usage.
258 - Add interleaved weighted round robin `INTERLEAVED_WEIGHTED_ROUND_ROBIN` worker choice strategy (experimental).
262 - Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
264 ## [2.4.14] - 2023-05-09
268 - Ensure no undefined task runtime can land in the tasks history.
269 - Fix median computation implementation once again.
273 - Unit tests for median and queue implementations.
275 ## [2.4.13] - 2023-05-08
279 - Fix worker choice strategy options validation.
280 - Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
282 ## [2.4.12] - 2023-05-06
286 - Support multiple task functions per worker.
287 - Add custom worker weights support to worker choice strategies options.
291 - Use O(1) queue implementation for tasks queueing.
295 - Fix median computation implementation.
296 - Fix fair share worker choice strategy internals update.
298 ## [2.4.11] - 2023-04-23
302 - Optimize free worker finding in worker choice strategies.
304 ## [2.4.10] - 2023-04-15
308 - Fix typescript type definition for task function: ensure the input data is optional.
309 - Fix typescript type definition for pool execute(): ensure the input data is optional.
311 ## [2.4.9] - 2023-04-15
315 - Add tasks queue enablement runtime setter to pool.
316 - Add tasks queue options runtime setter to pool.
317 - Add worker choice strategy options runtime setter to pool.
321 - Remove the tasks queuing experimental status.
325 - Fix task function type definition and validation.
326 - Fix worker choice strategy options handling.
328 ## [2.4.8] - 2023-04-12
332 - Fix message between main worker and worker type definition for tasks.
333 - Fix code documentation.
335 ## [2.4.7] - 2023-04-11
339 - Add worker tasks queue options to pool options.
343 - Fix missing documentation.
345 ## [2.4.6] - 2023-04-10
349 - Ensure one task at a time is executed per worker with tasks queueing enabled.
350 - Properly count worker executing tasks with tasks queueing enabled.
352 ## [2.4.5] - 2023-04-09
356 - Use monotonic high resolution timer for worker tasks runtime.
357 - Add worker tasks median runtime to statistics.
358 - Add worker tasks queue (experimental).
360 ## [2.4.4] - 2023-04-07
364 - Add `PoolEvents` enumeration and `PoolEvent` type.
368 - Destroy worker only on alive check.
370 ## [2.4.3] - 2023-04-07
374 - Fix typedoc generation with inheritance.
376 ## [2.4.2] - 2023-04-06
380 - Add `full` event to dynamic pool.
381 - Keep worker choice strategy in memory for conditional reuse.
385 - Fix possible negative worker key at worker removal in worker choice strategies.
387 ## [2.4.1] - 2023-04-05
391 - Optimize worker choice strategy for dynamic pool.
395 - Ensure dynamic pool does not alter worker choice strategy expected behavior.
397 ## [2.4.0] - 2023-04-04
401 - Add `LESS_BUSY` worker choice strategy.
405 - Optimize worker storage in pool.
406 - Optimize worker alive status check.
407 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
408 - Optimize `LESS_USED` worker choice strategy.
409 - Update benchmarks versus external threads pools.
410 - Optimize tasks usage statistics requirements for worker choice strategy.
414 - Ensure trimmable characters are checked at pool initialization.
415 - Fix message id integer overflow.
416 - Fix pool worker removal in worker choice strategy internals.
417 - Fix package publication with pnpm.
419 ## [2.4.0-3] - 2023-04-04
423 - Add `LESS_BUSY` worker choice strategy.
427 - Optimize worker storage in pool.
428 - Optimize worker alive status check.
429 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
430 - Optimize `LESS_USED` worker choice strategy.
431 - Update benchmarks versus external threads pools.
435 - Ensure trimmable characters are checked at pool initialization.
436 - Fix message id integer overflow.
437 - Fix pool worker removal in worker choice strategy internals.
438 - Fix package publication with pnpm.
440 ## [2.4.0-2] - 2023-04-03
444 - Add `LESS_BUSY` worker choice strategy.
448 - Optimize worker storage in pool.
449 - Optimize worker alive status check.
450 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
451 - Optimize `LESS_USED` worker choice strategy.
455 - Ensure trimmable characters are checked at pool initialization.
456 - Fix message id integer overflow.
457 - Fix pool worker removal in worker choice strategy internals.
458 - Fix package publication with pnpm.
460 ## [2.4.0-1] - 2023-04-03
464 - Add `LESS_BUSY` worker choice strategy.
468 - Optimize worker storage in pool.
469 - Optimize worker alive status check.
470 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
471 - Optimize `LESS_USED` worker choice strategy.
475 - Ensure trimmable characters are checked at pool initialization.
476 - Fix message id integer overflow.
477 - Fix pool worker removal in worker choice strategy internals.
479 ## [2.4.0-0] - 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.3.10] - 2023-03-18
502 - Fix `exports` syntax for ESM and CommonJS.
506 - Permit SemVer pre-release publication.
508 ## [2.3.10-2] - 2023-03-18
512 - Fix `exports` syntax for ESM and CommonJS.
514 ## [2.3.10-1] - 2023-03-18
518 - Permit SemVer pre-release publication.
520 ## [2.3.10-0] - 2023-03-18
524 - Fix `exports` syntax for ESM and CommonJS.
526 ## [2.3.9] - 2023-03-18
530 - Introduce ESM module support along with CommonJS one.
534 - Fix brown paper bag bug referencing the same object literal.
536 ## [2.3.8] - 2023-03-18
540 - Switch internal benchmarking code to benny.
541 - Switch to TypeScript 5.x.x.
542 - Switch rollup bundler plugins to core ones.
543 - Switch to TSDoc syntax.
544 - Enforce conventional commits.
548 - Fix random integer generator.
549 - Fix worker choice strategy pool type identification at initialization.
551 ## [2.3.7] - 2022-10-23
555 - Switch to open collective FOSS project funding platform.
556 - Switch to ts-standard linter configuration on TypeScript code.
560 - Fixed missing async on pool execute method.
561 - Fixed typing in TypeScript example.
562 - Fixed types in unit tests.
564 ## [2.3.6] - 2022-10-22
568 - Cleanup pool attributes and methods.
569 - Refine error types thrown.
573 - Fix continuous integration build on windows.
574 - Fix code coverage reporting by using c8 instead of nyc.
576 ## [2.3.5] - 2022-10-21
580 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
581 - Optimize tasks usage lookup implementation.
585 - Fix missed pool event emitter type export.
586 - Fix typedoc documentation generation.
588 ## [2.3.4] - 2022-10-17
592 - Fully automate release process with release-it.
596 - Optimize fair share task scheduling algorithm implementation.
597 - Update benchmarks versus external pools results with latest version.
599 ## [2.3.3] - 2022-10-15
603 - Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
605 ## [2.3.2] - 2022-10-14
609 - Optimize fair share worker selection strategy implementation.
613 - Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
615 ## [2.3.1] - 2022-10-13
619 - Pool worker choice strategies:
620 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
621 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
623 ## [2.2.2] - 2022-10-09
627 - Fixed `README.md` file.
629 ## [2.2.1] - 2022-10-08
633 - Dynamic worker choice strategy change at runtime.
635 ## [2.2.0] - 2022-01-05
639 - Support only NodeJS version 16.x.x for cluster pool: upstream cluster API have changed on that version.
641 ## [2.1.0] - 2021-08-29
645 - Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
649 - `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
650 - `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
651 - `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
652 - `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
654 ## [2.0.2] - 2021-05-12
658 - Fix `busy` event emission on fixed pool type
660 ## [2.0.1] - 2021-03-16
664 - Check if pool options are properly set.
665 - `busy` event is emitted on all pool types.
667 ## [2.0.0] - 2021-03-01
671 - Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
675 - `FullPool` event is now renamed to `busy`.
676 - `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
677 _Find more details on our JSDoc._
679 - `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
681 - We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
683 ### Pool options types declaration merge
685 `FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
687 #### New `export` strategy
691 const DynamicThreadPool = require('poolifier/lib/dynamic')
693 const { DynamicThreadPool } = require('poolifier/lib/dynamic')
696 But you should always prefer just using
699 const { DynamicThreadPool } = require('poolifier')
702 #### New type definitions for input data and response
704 For cluster worker and worker-thread pools, you can now only send and receive structured-cloneable data.
705 _This is not a limitation by poolifier but NodeJS._
707 #### Public property replacements
709 `numWorkers` property is now `numberOfWorkers`
711 #### Internal (protected) properties and methods renaming
713 These properties are not intended for end users
715 - `id` => `nextMessageId`
717 These methods are not intended for end users
719 - `_chooseWorker` => `chooseWorker`
720 - `_newWorker` => `createWorker`
721 - `_execute` => `internalExecute`
722 - `_chooseWorker` => `chooseWorker`
723 - `_checkAlive` => `checkAlive`
725 - `_runAsync` => `runAsync`
727 ## [1.1.0] - 2020-05-21
731 - ThreadWorker support async functions as option
732 - Various external library patches
734 ## [1.0.0] - 2020-01-24
738 - FixedThreadPool implementation
739 - DynamicThreadPool implementation
740 - WorkerThread implementation to improve developer experience