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 - Structure markdown documentation (PR #811).
16 - Add missing `types` field to package.json `exports`.
18 ## [2.6.21] - 2023-08-03
22 - Improve code documentation.
23 - Code refactoring and cleanup for better maintainability and readability.
25 ## [2.6.20] - 2023-07-21
29 - Fix queued tasks redistribution on error task execution starvation.
30 - Ensure task queueing per worker condition is untangled from the pool busyness semantic.
34 - Drastically reduce lookups by worker in the worker nodes.
36 ## [2.6.19] - 2023-07-20
40 - Dedicated internal communication channel for worker_threads pools.
42 ## [2.6.18] - 2023-07-19
46 - Code refactoring and cleanup for better maintainability and readability. Bundle size is a bit smaller.
48 ## [2.6.17] - 2023-07-16
52 - Add `listTaskFunctions()` method to worker class.
54 ## [2.6.16] - 2023-07-12
58 - Fix pool startup detection.
59 - Fix worker task functions handling.
61 ## [2.6.15] - 2023-07-11
65 - Take into account worker node readiness in worker choice strategies.
67 ## [2.6.14] - 2023-07-10
71 - Fix task function statistics tracking.
73 ## [2.6.13] - 2023-07-10
77 - Add per task function statistics tracking.
78 - Add public methods to manipulate the worker task functions at runtime.
80 ## [2.6.12] - 2023-07-09
84 - Workaround import issue with `node:os` module in node 16.x.x.
86 ## [2.6.11] - 2023-07-09
90 - Fix pool readiness semantic.
92 ## [2.6.10] - 2023-07-08
96 - Ensure workers are not recreated on error at pool startup.
100 - Add `ready` and `strategy` fields to pool information.
101 - Add pool event `ready` to notify when the number of workers created in the pool has reached the maximum size expected and are ready.
102 - Add dynamic pool sizing checks.
104 ## [2.6.9] - 2023-07-07
108 - Recreate the right worker type on uncaught exception.
112 - Add minimum and maximum to internal measurement statistics.
113 - Add `runTime` and `waitTime` to pool information.
114 - Check worker inactive time only on dynamic worker.
116 ## [2.6.8] - 2023-07-03
120 - Brown paper bag release to fix version handling in pool information.
122 ## [2.6.7] - 2023-07-03
126 - Ensure worker queued tasks at error are reassigned to other pool workers.
130 - Add pool `utilization` ratio to pool information.
131 - Add `version` to pool information.
132 - Add worker information to worker nodes.
134 ## [2.6.6] - 2023-07-01
138 - Add safe helper `availableParallelism` to help sizing the pool.
142 - Ensure message handler is only registered in worker.
144 ## [2.6.5] - 2023-06-27
148 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
152 - Artificial version bump to 2.6.5 to workaround publication issue.
153 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
154 - Ensure pool event is emitted before task error promise rejection.
155 - Fix queued tasks count computation.
159 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
161 ## [2.6.4] - 2023-06-27
165 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
169 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
170 - Ensure pool event is emitted before task error promise rejection.
171 - Fix queued tasks count computation.
175 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
177 ## [2.6.3] - 2023-06-19
181 - Ensure no tasks are queued when trying to soft kill a dynamic worker.
182 - Update strategies internals after statistics computation.
186 - Optimize O(1) queue implementation.
188 ## [2.6.2] - 2023-06-12
192 - Fix new worker use after creation in dynamic pool given the current worker choice strategy.
194 ## [2.6.1] - 2023-06-10
198 - Add worker choice strategy documentation: [README.md](./src/pools/selection-strategies/README.md).
202 - Fix average statistics computation: ensure failed tasks are not accounted.
204 ## [2.6.0] - 2023-06-09
208 - Add `LEAST_ELU` worker choice strategy (experimental).
209 - Add tasks ELU instead of runtime support to `FAIR_SHARE` worker choice strategy.
213 - Refactor pool worker node usage internals.
214 - Breaking change: refactor worker choice strategy statistics requirements: the syntax of the worker choice strategy options has changed.
215 - Breaking change: pool information `info` property object fields have been renamed.
219 - Fix wait time accounting.
220 - Ensure worker choice strategy `LEAST_BUSY` accounts also tasks wait time.
221 - Ensure worker choice strategy `LEAST_USED` accounts also queued tasks.
223 ## [2.5.4] - 2023-06-07
227 - Add Event Loop Utilization (ELU) statistics to worker tasks usage.
231 - Compute statistics at the worker level only if needed.
232 - Add `worker_threads` options to thread pool options.
236 - Make the `LEAST_BUSY` strategy only relies on task runtime.
238 ## [2.5.3] - 2023-06-04
242 - Refine pool information content.
243 - Limit pool internals public exposure.
245 ## [2.5.2] - 2023-06-02
249 - Add `taskError` pool event for task execution error.
250 - Add pool information `info` property to pool.
251 - Emit pool information on `busy` and `full` pool events.
253 ## [2.5.1] - 2023-06-01
257 - Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
258 - Add `error` pool event for uncaught worker error.
260 ## [2.5.0] - 2023-05-31
264 - Switch pool event emitter to `EventEmitterAsyncResource`.
265 - Add tasks wait time accounting in per worker tasks usage.
266 - Add interleaved weighted round robin `INTERLEAVED_WEIGHTED_ROUND_ROBIN` worker choice strategy (experimental).
270 - Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
272 ## [2.4.14] - 2023-05-09
276 - Ensure no undefined task runtime can land in the tasks history.
277 - Fix median computation implementation once again.
281 - Unit tests for median and queue implementations.
283 ## [2.4.13] - 2023-05-08
287 - Fix worker choice strategy options validation.
288 - Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
290 ## [2.4.12] - 2023-05-06
294 - Support multiple task functions per worker.
295 - Add custom worker weights support to worker choice strategies options.
299 - Use O(1) queue implementation for tasks queueing.
303 - Fix median computation implementation.
304 - Fix fair share worker choice strategy internals update.
306 ## [2.4.11] - 2023-04-23
310 - Optimize free worker finding in worker choice strategies.
312 ## [2.4.10] - 2023-04-15
316 - Fix typescript type definition for task function: ensure the input data is optional.
317 - Fix typescript type definition for pool execute(): ensure the input data is optional.
319 ## [2.4.9] - 2023-04-15
323 - Add tasks queue enablement runtime setter to pool.
324 - Add tasks queue options runtime setter to pool.
325 - Add worker choice strategy options runtime setter to pool.
329 - Remove the tasks queuing experimental status.
333 - Fix task function type definition and validation.
334 - Fix worker choice strategy options handling.
336 ## [2.4.8] - 2023-04-12
340 - Fix message between main worker and worker type definition for tasks.
341 - Fix code documentation.
343 ## [2.4.7] - 2023-04-11
347 - Add worker tasks queue options to pool options.
351 - Fix missing documentation.
353 ## [2.4.6] - 2023-04-10
357 - Ensure one task at a time is executed per worker with tasks queueing enabled.
358 - Properly count worker executing tasks with tasks queueing enabled.
360 ## [2.4.5] - 2023-04-09
364 - Use monotonic high resolution timer for worker tasks runtime.
365 - Add worker tasks median runtime to statistics.
366 - Add worker tasks queue (experimental).
368 ## [2.4.4] - 2023-04-07
372 - Add `PoolEvents` enumeration and `PoolEvent` type.
376 - Destroy worker only on alive check.
378 ## [2.4.3] - 2023-04-07
382 - Fix typedoc generation with inheritance.
384 ## [2.4.2] - 2023-04-06
388 - Add `full` event to dynamic pool.
389 - Keep worker choice strategy in memory for conditional reuse.
393 - Fix possible negative worker key at worker removal in worker choice strategies.
395 ## [2.4.1] - 2023-04-05
399 - Optimize worker choice strategy for dynamic pool.
403 - Ensure dynamic pool does not alter worker choice strategy expected behavior.
405 ## [2.4.0] - 2023-04-04
409 - Add `LESS_BUSY` worker choice strategy.
413 - Optimize worker storage in pool.
414 - Optimize worker alive status check.
415 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
416 - Optimize `LESS_USED` worker choice strategy.
417 - Update benchmarks versus external threads pools.
418 - Optimize tasks usage statistics requirements for worker choice strategy.
422 - Ensure trimmable characters are checked at pool initialization.
423 - Fix message id integer overflow.
424 - Fix pool worker removal in worker choice strategy internals.
425 - Fix package publication with pnpm.
427 ## [2.4.0-3] - 2023-04-04
431 - Add `LESS_BUSY` worker choice strategy.
435 - Optimize worker storage in pool.
436 - Optimize worker alive status check.
437 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
438 - Optimize `LESS_USED` worker choice strategy.
439 - Update benchmarks versus external threads pools.
443 - Ensure trimmable characters are checked at pool initialization.
444 - Fix message id integer overflow.
445 - Fix pool worker removal in worker choice strategy internals.
446 - Fix package publication with pnpm.
448 ## [2.4.0-2] - 2023-04-03
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.
463 - Ensure trimmable characters are checked at pool initialization.
464 - Fix message id integer overflow.
465 - Fix pool worker removal in worker choice strategy internals.
466 - Fix package publication with pnpm.
468 ## [2.4.0-1] - 2023-04-03
472 - Add `LESS_BUSY` worker choice strategy.
476 - Optimize worker storage in pool.
477 - Optimize worker alive status check.
478 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
479 - Optimize `LESS_USED` worker choice strategy.
483 - Ensure trimmable characters are checked at pool initialization.
484 - Fix message id integer overflow.
485 - Fix pool worker removal in worker choice strategy internals.
487 ## [2.4.0-0] - 2023-04-03
491 - Add `LESS_BUSY` worker choice strategy.
495 - Optimize worker storage in pool.
496 - Optimize worker alive status check.
497 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
498 - Optimize `LESS_USED` worker choice strategy.
502 - Ensure trimmable characters are checked at pool initialization.
503 - Fix message id integer overflow.
504 - Fix pool worker removal in worker choice strategy internals.
506 ## [2.3.10] - 2023-03-18
510 - Fix package.json `exports` syntax for ESM and CommonJS.
514 - Permit SemVer pre-release publication.
516 ## [2.3.10-2] - 2023-03-18
520 - Fix package.json `exports` syntax for ESM and CommonJS.
522 ## [2.3.10-1] - 2023-03-18
526 - Permit SemVer pre-release publication.
528 ## [2.3.10-0] - 2023-03-18
532 - Fix package.json `exports` syntax for ESM and CommonJS.
534 ## [2.3.9] - 2023-03-18
538 - Introduce ESM module support along with CommonJS one.
542 - Fix brown paper bag bug referencing the same object literal.
544 ## [2.3.8] - 2023-03-18
548 - Switch internal benchmarking code to benny.
549 - Switch to TypeScript 5.x.x.
550 - Switch rollup bundler plugins to core ones.
551 - Switch to TSDoc syntax.
552 - Enforce conventional commits.
556 - Fix random integer generator.
557 - Fix worker choice strategy pool type identification at initialization.
559 ## [2.3.7] - 2022-10-23
563 - Switch to open collective FOSS project funding platform.
564 - Switch to ts-standard linter configuration on TypeScript code.
568 - Fixed missing async on pool execute method.
569 - Fixed typing in TypeScript example.
570 - Fixed types in unit tests.
572 ## [2.3.6] - 2022-10-22
576 - Cleanup pool attributes and methods.
577 - Refine error types thrown.
581 - Fix continuous integration build on windows.
582 - Fix code coverage reporting by using c8 instead of nyc.
584 ## [2.3.5] - 2022-10-21
588 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
589 - Optimize tasks usage lookup implementation.
593 - Fix missed pool event emitter type export.
594 - Fix typedoc documentation generation.
596 ## [2.3.4] - 2022-10-17
600 - Fully automate release process with release-it.
604 - Optimize fair share task scheduling algorithm implementation.
605 - Update benchmarks versus external pools results with latest version.
607 ## [2.3.3] - 2022-10-15
611 - Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
613 ## [2.3.2] - 2022-10-14
617 - Optimize fair share worker selection strategy implementation.
621 - Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
623 ## [2.3.1] - 2022-10-13
627 - Pool worker choice strategies:
628 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
629 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
631 ## [2.2.2] - 2022-10-09
635 - Fixed `README.md` file.
637 ## [2.2.1] - 2022-10-08
641 - Dynamic worker choice strategy change at runtime.
643 ## [2.2.0] - 2022-01-05
647 - Support only Node.js version 16.x.x for cluster pool: upstream cluster API have changed on that version.
649 ## [2.1.0] - 2021-08-29
653 - Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
657 - `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
658 - `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
659 - `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
660 - `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
662 ## [2.0.2] - 2021-05-12
666 - Fix `busy` event emission on fixed pool type
668 ## [2.0.1] - 2021-03-16
672 - Check if pool options are properly set.
673 - `busy` event is emitted on all pool types.
675 ## [2.0.0] - 2021-03-01
679 - Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
683 - `FullPool` event is now renamed to `busy`.
684 - `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
685 _Find more details on our JSDoc._
687 - `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
689 - We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
691 ### Pool options types declaration merge
693 `FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
695 #### New `export` strategy
699 const DynamicThreadPool = require('poolifier/lib/dynamic')
701 const { DynamicThreadPool } = require('poolifier/lib/dynamic')
704 But you should always prefer just using
707 const { DynamicThreadPool } = require('poolifier')
710 #### New type definitions for input data and response
712 For cluster worker and worker-thread pools, you can now only send and receive structured-cloneable data.
713 _This is not a limitation by poolifier but Node.js._
715 #### Public property replacements
717 `numWorkers` property is now `numberOfWorkers`
719 #### Internal (protected) properties and methods renaming
721 These properties are not intended for end users
723 - `id` => `nextMessageId`
725 These methods are not intended for end users
727 - `_chooseWorker` => `chooseWorker`
728 - `_newWorker` => `createWorker`
729 - `_execute` => `internalExecute`
730 - `_chooseWorker` => `chooseWorker`
731 - `_checkAlive` => `checkAlive`
733 - `_runAsync` => `runAsync`
735 ## [1.1.0] - 2020-05-21
739 - ThreadWorker support async functions as option
740 - Various external library patches
742 ## [1.0.0] - 2020-01-24
746 - FixedThreadPool implementation
747 - DynamicThreadPool implementation
748 - WorkerThread implementation to improve developer experience