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.17] - 2023-07-16
14 - Add `listTaskFunctions()` method to worker class.
16 ## [2.6.16] - 2023-07-12
20 - Fix pool startup detection.
21 - Fix worker task functions handling.
23 ## [2.6.15] - 2023-07-11
27 - Take into account worker node readiness in worker choice strategies.
29 ## [2.6.14] - 2023-07-10
33 - Fix task function statistics tracking.
35 ## [2.6.13] - 2023-07-10
39 - Add per task function statistics tracking.
40 - Add public methods to manipulate the worker task functions at runtime.
42 ## [2.6.12] - 2023-07-09
46 - Workaround import issue with `node:os` module in node 16.x.x.
48 ## [2.6.11] - 2023-07-09
52 - Fix pool readiness semantic.
54 ## [2.6.10] - 2023-07-08
58 - Ensure workers are not recreated on error at pool startup.
62 - Add `ready` and `strategy` fields to pool information.
63 - Add pool event `ready` to notify when the number of workers created in the pool has reached the maximum size expected and are ready.
64 - Add dynamic pool sizing checks.
66 ## [2.6.9] - 2023-07-07
70 - Recreate the right worker type on uncaught exception.
74 - Add minimum and maximum to internal measurement statistics.
75 - Add `runTime` and `waitTime` to pool information.
76 - Check worker inactive time only on dynamic worker.
78 ## [2.6.8] - 2023-07-03
82 - Brown paper bag release to fix version handling in pool information.
84 ## [2.6.7] - 2023-07-03
88 - Ensure worker queued tasks at error are reassigned to other pool workers.
92 - Add pool `utilization` ratio to pool information.
93 - Add `version` to pool information.
94 - Add worker information to worker nodes.
96 ## [2.6.6] - 2023-07-01
100 - Add safe helper `availableParallelism` to help sizing the pool.
104 - Ensure message handler is only registered in worker.
106 ## [2.6.5] - 2023-06-27
110 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
114 - Artificial version bump to 2.6.5 to workaround publication issue.
115 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
116 - Ensure pool event is emitted before task error promise rejection.
117 - Fix queued tasks count computation.
121 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
123 ## [2.6.4] - 2023-06-27
127 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
131 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
132 - Ensure pool event is emitted before task error promise rejection.
133 - Fix queued tasks count computation.
137 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
139 ## [2.6.3] - 2023-06-19
143 - Ensure no tasks are queued when trying to soft kill a dynamic worker.
144 - Update strategies internals after statistics computation.
148 - Optimize O(1) queue implementation.
150 ## [2.6.2] - 2023-06-12
154 - Fix new worker use after creation in dynamic pool given the current worker choice strategy.
156 ## [2.6.1] - 2023-06-10
160 - Add worker choice strategy documentation: [README.md](./src/pools/selection-strategies/README.md).
164 - Fix average statistics computation: ensure failed tasks are not accounted.
166 ## [2.6.0] - 2023-06-09
170 - Add `LEAST_ELU` worker choice strategy (experimental).
171 - Add tasks ELU instead of runtime support to `FAIR_SHARE` worker choice strategy.
175 - Refactor pool worker node usage internals.
176 - Breaking change: refactor worker choice strategy statistics requirements: the syntax of the worker choice strategy options has changed.
177 - Breaking change: pool information `info` property object fields have been renamed.
181 - Fix wait time accounting.
182 - Ensure worker choice strategy `LEAST_BUSY` accounts also tasks wait time.
183 - Ensure worker choice strategy `LEAST_USED` accounts also queued tasks.
185 ## [2.5.4] - 2023-06-07
189 - Add Event Loop Utilization (ELU) statistics to worker tasks usage.
193 - Compute statistics at the worker level only if needed.
194 - Add `worker_threads` options to thread pool options.
198 - Make the `LEAST_BUSY` strategy only relies on task runtime.
200 ## [2.5.3] - 2023-06-04
204 - Refine pool information content.
205 - Limit pool internals public exposure.
207 ## [2.5.2] - 2023-06-02
211 - Add `taskError` pool event for task execution error.
212 - Add pool information `info` property to pool.
213 - Emit pool information on `busy` and `full` pool events.
215 ## [2.5.1] - 2023-06-01
219 - Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
220 - Add `error` pool event for uncaught worker error.
222 ## [2.5.0] - 2023-05-31
226 - Switch pool event emitter to `EventEmitterAsyncResource`.
227 - Add tasks wait time accounting in per worker tasks usage.
228 - Add interleaved weighted round robin `INTERLEAVED_WEIGHTED_ROUND_ROBIN` worker choice strategy (experimental).
232 - Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
234 ## [2.4.14] - 2023-05-09
238 - Ensure no undefined task runtime can land in the tasks history.
239 - Fix median computation implementation once again.
243 - Unit tests for median and queue implementations.
245 ## [2.4.13] - 2023-05-08
249 - Fix worker choice strategy options validation.
250 - Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
252 ## [2.4.12] - 2023-05-06
256 - Support multiple task functions per worker.
257 - Add custom worker weights support to worker choice strategies options.
261 - Use O(1) queue implementation for tasks queueing.
265 - Fix median computation implementation.
266 - Fix fair share worker choice strategy internals update.
268 ## [2.4.11] - 2023-04-23
272 - Optimize free worker finding in worker choice strategies.
274 ## [2.4.10] - 2023-04-15
278 - Fix typescript type definition for worker function: ensure the input data is optional.
279 - Fix typescript type definition for pool execute(): ensure the input data is optional.
281 ## [2.4.9] - 2023-04-15
285 - Add tasks queue enablement runtime setter to pool.
286 - Add tasks queue options runtime setter to pool.
287 - Add worker choice strategy options runtime setter to pool.
291 - Remove the tasks queuing experimental status.
295 - Fix worker function type definition and validation.
296 - Fix worker choice strategy options handling.
298 ## [2.4.8] - 2023-04-12
302 - Fix message between main worker and worker type definition for tasks.
303 - Fix code documentation.
305 ## [2.4.7] - 2023-04-11
309 - Add worker tasks queue options to pool options.
313 - Fix missing documentation.
315 ## [2.4.6] - 2023-04-10
319 - Ensure one task at a time is executed per worker with tasks queueing enabled.
320 - Properly count worker executing tasks with tasks queueing enabled.
322 ## [2.4.5] - 2023-04-09
326 - Use monotonic high resolution timer for worker tasks runtime.
327 - Add worker tasks median runtime to statistics.
328 - Add worker tasks queue (experimental).
330 ## [2.4.4] - 2023-04-07
334 - Add `PoolEvents` enumeration and `PoolEvent` type.
338 - Destroy worker only on alive check.
340 ## [2.4.3] - 2023-04-07
344 - Fix typedoc generation with inheritance.
346 ## [2.4.2] - 2023-04-06
350 - Add `full` event to dynamic pool.
351 - Keep worker choice strategy in memory for conditional reuse.
355 - Fix possible negative worker key at worker removal in worker choice strategies.
357 ## [2.4.1] - 2023-04-05
361 - Optimize worker choice strategy for dynamic pool.
365 - Ensure dynamic pool does not alter worker choice strategy expected behavior.
367 ## [2.4.0] - 2023-04-04
371 - Add `LESS_BUSY` worker choice strategy.
375 - Optimize worker storage in pool.
376 - Optimize worker alive status check.
377 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
378 - Optimize `LESS_USED` worker choice strategy.
379 - Update benchmarks versus external threads pools.
380 - Optimize tasks usage statistics requirements for worker choice strategy.
384 - Ensure trimmable characters are checked at pool initialization.
385 - Fix message id integer overflow.
386 - Fix pool worker removal in worker choice strategy internals.
387 - Fix package publication with pnpm.
389 ## [2.4.0-3] - 2023-04-04
393 - Add `LESS_BUSY` worker choice strategy.
397 - Optimize worker storage in pool.
398 - Optimize worker alive status check.
399 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
400 - Optimize `LESS_USED` worker choice strategy.
401 - Update benchmarks versus external threads pools.
405 - Ensure trimmable characters are checked at pool initialization.
406 - Fix message id integer overflow.
407 - Fix pool worker removal in worker choice strategy internals.
408 - Fix package publication with pnpm.
410 ## [2.4.0-2] - 2023-04-03
414 - Add `LESS_BUSY` worker choice strategy.
418 - Optimize worker storage in pool.
419 - Optimize worker alive status check.
420 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
421 - Optimize `LESS_USED` worker choice strategy.
425 - Ensure trimmable characters are checked at pool initialization.
426 - Fix message id integer overflow.
427 - Fix pool worker removal in worker choice strategy internals.
428 - Fix package publication with pnpm.
430 ## [2.4.0-1] - 2023-04-03
434 - Add `LESS_BUSY` worker choice strategy.
438 - Optimize worker storage in pool.
439 - Optimize worker alive status check.
440 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
441 - Optimize `LESS_USED` worker choice strategy.
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.
449 ## [2.4.0-0] - 2023-04-03
453 - Add `LESS_BUSY` worker choice strategy.
457 - Optimize worker storage in pool.
458 - Optimize worker alive status check.
459 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
460 - Optimize `LESS_USED` worker choice strategy.
464 - Ensure trimmable characters are checked at pool initialization.
465 - Fix message id integer overflow.
466 - Fix pool worker removal in worker choice strategy internals.
468 ## [2.3.10] - 2023-03-18
472 - Fix `exports` syntax for ESM and CommonJS.
476 - Permit SemVer pre-release publication.
478 ## [2.3.10-2] - 2023-03-18
482 - Fix `exports` syntax for ESM and CommonJS.
484 ## [2.3.10-1] - 2023-03-18
488 - Permit SemVer pre-release publication.
490 ## [2.3.10-0] - 2023-03-18
494 - Fix `exports` syntax for ESM and CommonJS.
496 ## [2.3.9] - 2023-03-18
500 - Introduce ESM module support along with CommonJS one.
504 - Fix brown paper bag bug referencing the same object literal.
506 ## [2.3.8] - 2023-03-18
510 - Switch internal benchmarking code to benny.
511 - Switch to TypeScript 5.x.x.
512 - Switch rollup bundler plugins to core ones.
513 - Switch to TSDoc syntax.
514 - Enforce conventional commits.
518 - Fix random integer generator.
519 - Fix worker choice strategy pool type identification at initialization.
521 ## [2.3.7] - 2022-10-23
525 - Switch to open collective FOSS project funding platform.
526 - Switch to ts-standard linter configuration on TypeScript code.
530 - Fixed missing async on pool execute method.
531 - Fixed typing in TypeScript example.
532 - Fixed types in unit tests.
534 ## [2.3.6] - 2022-10-22
538 - Cleanup pool attributes and methods.
539 - Refine error types thrown.
543 - Fix continuous integration build on windows.
544 - Fix code coverage reporting by using c8 instead of nyc.
546 ## [2.3.5] - 2022-10-21
550 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
551 - Optimize tasks usage lookup implementation.
555 - Fix missed pool event emitter type export.
556 - Fix typedoc documentation generation.
558 ## [2.3.4] - 2022-10-17
562 - Fully automate release process with release-it.
566 - Optimize fair share task scheduling algorithm implementation.
567 - Update benchmarks versus external pools results with latest version.
569 ## [2.3.3] - 2022-10-15
573 - Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
575 ## [2.3.2] - 2022-10-14
579 - Optimize fair share worker selection strategy implementation.
583 - Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
585 ## [2.3.1] - 2022-10-13
589 - Pool worker choice strategies:
590 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
591 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
593 ## [2.2.2] - 2022-10-09
597 - Fixed `README.md` file.
599 ## [2.2.1] - 2022-10-08
603 - Dynamic worker choice strategy change at runtime.
605 ## [2.2.0] - 2022-01-05
609 - Support only NodeJS version 16.x.x for cluster pool: upstream cluster API have changed on that version.
611 ## [2.1.0] - 2021-08-29
615 - Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
619 - `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
620 - `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
621 - `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
622 - `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
624 ## [2.0.2] - 2021-05-12
628 - Fix `busy` event emission on fixed pool type
630 ## [2.0.1] - 2021-03-16
634 - Check if pool options are properly set.
635 - `busy` event is emitted on all pool types.
637 ## [2.0.0] - 2021-03-01
641 - Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
645 - `FullPool` event is now renamed to `busy`.
646 - `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
647 _Find more details on our JSDoc._
649 - `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
651 - We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
653 ### Pool options types declaration merge
655 `FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
657 #### New `export` strategy
661 const DynamicThreadPool = require('poolifier/lib/dynamic')
663 const { DynamicThreadPool } = require('poolifier/lib/dynamic')
666 But you should always prefer just using
669 const { DynamicThreadPool } = require('poolifier')
672 #### New type definitions for input data and response
674 For cluster worker and worker-thread pools, you can now only send and receive structured-cloneable data.
675 _This is not a limitation by poolifier but NodeJS._
677 #### Public property replacements
679 `numWorkers` property is now `numberOfWorkers`
681 #### Internal (protected) properties and methods renaming
683 These properties are not intended for end users
685 - `id` => `nextMessageId`
687 These methods are not intended for end users
689 - `_chooseWorker` => `chooseWorker`
690 - `_newWorker` => `createWorker`
691 - `_execute` => `internalExecute`
692 - `_chooseWorker` => `chooseWorker`
693 - `_checkAlive` => `checkAlive`
695 - `_runAsync` => `runAsync`
697 ## [1.1.0] - 2020-05-21
701 - ThreadWorker support async functions as option
702 - Various external library patches
704 ## [1.0.0] - 2020-01-24
708 - FixedThreadPool implementation
709 - DynamicThreadPool implementation
710 - WorkerThread implementation to improve developer experience