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.23] - 2023-08-11
14 - Fix pool busyness semantic when tasks queueing is enabled: the pool is busy when the number of executing tasks on each worker has reached the maximum tasks concurrency per worker.
18 - HTTP client pool examples: fetch, node-fetch and axios with multiple task functions.
19 - HTTP server pool examples: express, fastify.
21 ## [2.6.22] - 2023-08-10
25 - Add missing `types` field to package.json `exports`.
29 - Structure markdown documentation (PR #811).
31 ## [2.6.21] - 2023-08-03
35 - Improve code documentation.
36 - Code refactoring and cleanup for better maintainability and readability.
38 ## [2.6.20] - 2023-07-21
42 - Fix queued tasks redistribution on error task execution starvation.
43 - Ensure task queueing per worker condition is untangled from the pool busyness semantic.
47 - Drastically reduce lookups by worker in the worker nodes.
49 ## [2.6.19] - 2023-07-20
53 - Dedicated internal communication channel for worker_threads pools.
55 ## [2.6.18] - 2023-07-19
59 - Code refactoring and cleanup for better maintainability and readability. Bundle size is a bit smaller.
61 ## [2.6.17] - 2023-07-16
65 - Add `listTaskFunctions()` method to worker class.
67 ## [2.6.16] - 2023-07-12
71 - Fix pool startup detection.
72 - Fix worker task functions handling.
74 ## [2.6.15] - 2023-07-11
78 - Take into account worker node readiness in worker choice strategies.
80 ## [2.6.14] - 2023-07-10
84 - Fix task function statistics tracking.
86 ## [2.6.13] - 2023-07-10
90 - Add per task function statistics tracking.
91 - Add public methods to manipulate the worker task functions at runtime.
93 ## [2.6.12] - 2023-07-09
97 - Workaround import issue with `node:os` module in node 16.x.x.
99 ## [2.6.11] - 2023-07-09
103 - Fix pool readiness semantic.
105 ## [2.6.10] - 2023-07-08
109 - Ensure workers are not recreated on error at pool startup.
113 - Add `ready` and `strategy` fields to pool information.
114 - Add pool event `ready` to notify when the number of workers created in the pool has reached the maximum size expected and are ready.
115 - Add dynamic pool sizing checks.
117 ## [2.6.9] - 2023-07-07
121 - Recreate the right worker type on uncaught exception.
125 - Add minimum and maximum to internal measurement statistics.
126 - Add `runTime` and `waitTime` to pool information.
127 - Check worker inactive time only on dynamic worker.
129 ## [2.6.8] - 2023-07-03
133 - Brown paper bag release to fix version handling in pool information.
135 ## [2.6.7] - 2023-07-03
139 - Ensure worker queued tasks at error are reassigned to other pool workers.
143 - Add pool `utilization` ratio to pool information.
144 - Add `version` to pool information.
145 - Add worker information to worker nodes.
147 ## [2.6.6] - 2023-07-01
151 - Add safe helper `availableParallelism` to help sizing the pool.
155 - Ensure message handler is only registered in worker.
157 ## [2.6.5] - 2023-06-27
161 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
165 - Artificial version bump to 2.6.5 to workaround publication issue.
166 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
167 - Ensure pool event is emitted before task error promise rejection.
168 - Fix queued tasks count computation.
172 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
174 ## [2.6.4] - 2023-06-27
178 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
182 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
183 - Ensure pool event is emitted before task error promise rejection.
184 - Fix queued tasks count computation.
188 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
190 ## [2.6.3] - 2023-06-19
194 - Ensure no tasks are queued when trying to soft kill a dynamic worker.
195 - Update strategies internals after statistics computation.
199 - Optimize O(1) queue implementation.
201 ## [2.6.2] - 2023-06-12
205 - Fix new worker use after creation in dynamic pool given the current worker choice strategy.
207 ## [2.6.1] - 2023-06-10
211 - Add worker choice strategy documentation: [README.md](./docs/worker-choice-strategies.md).
215 - Fix average statistics computation: ensure failed tasks are not accounted.
217 ## [2.6.0] - 2023-06-09
221 - Add `LEAST_ELU` worker choice strategy (experimental).
222 - Add tasks ELU instead of runtime support to `FAIR_SHARE` worker choice strategy.
226 - Refactor pool worker node usage internals.
227 - Breaking change: refactor worker choice strategy statistics requirements: the syntax of the worker choice strategy options has changed.
228 - Breaking change: pool information `info` property object fields have been renamed.
232 - Fix wait time accounting.
233 - Ensure worker choice strategy `LEAST_BUSY` accounts also tasks wait time.
234 - Ensure worker choice strategy `LEAST_USED` accounts also queued tasks.
236 ## [2.5.4] - 2023-06-07
240 - Add Event Loop Utilization (ELU) statistics to worker tasks usage.
244 - Compute statistics at the worker level only if needed.
245 - Add `worker_threads` options to thread pool options.
249 - Make the `LEAST_BUSY` strategy only relies on task runtime.
251 ## [2.5.3] - 2023-06-04
255 - Refine pool information content.
256 - Limit pool internals public exposure.
258 ## [2.5.2] - 2023-06-02
262 - Add `taskError` pool event for task execution error.
263 - Add pool information `info` property to pool.
264 - Emit pool information on `busy` and `full` pool events.
266 ## [2.5.1] - 2023-06-01
270 - Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
271 - Add `error` pool event for uncaught worker error.
273 ## [2.5.0] - 2023-05-31
277 - Switch pool event emitter to `EventEmitterAsyncResource`.
278 - Add tasks wait time accounting in per worker tasks usage.
279 - Add interleaved weighted round robin `INTERLEAVED_WEIGHTED_ROUND_ROBIN` worker choice strategy (experimental).
283 - Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
285 ## [2.4.14] - 2023-05-09
289 - Ensure no undefined task runtime can land in the tasks history.
290 - Fix median computation implementation once again.
294 - Unit tests for median and queue implementations.
296 ## [2.4.13] - 2023-05-08
300 - Fix worker choice strategy options validation.
301 - Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
303 ## [2.4.12] - 2023-05-06
307 - Support multiple task functions per worker.
308 - Add custom worker weights support to worker choice strategies options.
312 - Use O(1) queue implementation for tasks queueing.
316 - Fix median computation implementation.
317 - Fix fair share worker choice strategy internals update.
319 ## [2.4.11] - 2023-04-23
323 - Optimize free worker finding in worker choice strategies.
325 ## [2.4.10] - 2023-04-15
329 - Fix typescript type definition for task function: ensure the input data is optional.
330 - Fix typescript type definition for pool execute(): ensure the input data is optional.
332 ## [2.4.9] - 2023-04-15
336 - Add tasks queue enablement runtime setter to pool.
337 - Add tasks queue options runtime setter to pool.
338 - Add worker choice strategy options runtime setter to pool.
342 - Remove the tasks queuing experimental status.
346 - Fix task function type definition and validation.
347 - Fix worker choice strategy options handling.
349 ## [2.4.8] - 2023-04-12
353 - Fix message between main worker and worker type definition for tasks.
354 - Fix code documentation.
356 ## [2.4.7] - 2023-04-11
360 - Add worker tasks queue options to pool options.
364 - Fix missing documentation.
366 ## [2.4.6] - 2023-04-10
370 - Ensure one task at a time is executed per worker with tasks queueing enabled.
371 - Properly count worker executing tasks with tasks queueing enabled.
373 ## [2.4.5] - 2023-04-09
377 - Use monotonic high resolution timer for worker tasks runtime.
378 - Add worker tasks median runtime to statistics.
379 - Add worker tasks queue (experimental).
381 ## [2.4.4] - 2023-04-07
385 - Add `PoolEvents` enumeration and `PoolEvent` type.
389 - Destroy worker only on alive check.
391 ## [2.4.3] - 2023-04-07
395 - Fix typedoc generation with inheritance.
397 ## [2.4.2] - 2023-04-06
401 - Add `full` event to dynamic pool.
402 - Keep worker choice strategy in memory for conditional reuse.
406 - Fix possible negative worker key at worker removal in worker choice strategies.
408 ## [2.4.1] - 2023-04-05
412 - Optimize worker choice strategy for dynamic pool.
416 - Ensure dynamic pool does not alter worker choice strategy expected behavior.
418 ## [2.4.0] - 2023-04-04
422 - Add `LESS_BUSY` worker choice strategy.
426 - Optimize worker storage in pool.
427 - Optimize worker alive status check.
428 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
429 - Optimize `LESS_USED` worker choice strategy.
430 - Update benchmarks versus external threads pools.
431 - Optimize tasks usage statistics requirements for worker choice strategy.
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-3] - 2023-04-04
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.
452 - Update benchmarks versus external threads pools.
456 - Ensure trimmable characters are checked at pool initialization.
457 - Fix message id integer overflow.
458 - Fix pool worker removal in worker choice strategy internals.
459 - Fix package publication with pnpm.
461 ## [2.4.0-2] - 2023-04-03
465 - Add `LESS_BUSY` worker choice strategy.
469 - Optimize worker storage in pool.
470 - Optimize worker alive status check.
471 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
472 - Optimize `LESS_USED` worker choice strategy.
476 - Ensure trimmable characters are checked at pool initialization.
477 - Fix message id integer overflow.
478 - Fix pool worker removal in worker choice strategy internals.
479 - Fix package publication with pnpm.
481 ## [2.4.0-1] - 2023-04-03
485 - Add `LESS_BUSY` worker choice strategy.
489 - Optimize worker storage in pool.
490 - Optimize worker alive status check.
491 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
492 - Optimize `LESS_USED` worker choice strategy.
496 - Ensure trimmable characters are checked at pool initialization.
497 - Fix message id integer overflow.
498 - Fix pool worker removal in worker choice strategy internals.
500 ## [2.4.0-0] - 2023-04-03
504 - Add `LESS_BUSY` worker choice strategy.
508 - Optimize worker storage in pool.
509 - Optimize worker alive status check.
510 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
511 - Optimize `LESS_USED` worker choice strategy.
515 - Ensure trimmable characters are checked at pool initialization.
516 - Fix message id integer overflow.
517 - Fix pool worker removal in worker choice strategy internals.
519 ## [2.3.10] - 2023-03-18
523 - Fix package.json `exports` syntax for ESM and CommonJS.
527 - Permit SemVer pre-release publication.
529 ## [2.3.10-2] - 2023-03-18
533 - Fix package.json `exports` syntax for ESM and CommonJS.
535 ## [2.3.10-1] - 2023-03-18
539 - Permit SemVer pre-release publication.
541 ## [2.3.10-0] - 2023-03-18
545 - Fix package.json `exports` syntax for ESM and CommonJS.
547 ## [2.3.9] - 2023-03-18
551 - Introduce ESM module support along with CommonJS one.
555 - Fix brown paper bag bug referencing the same object literal.
557 ## [2.3.8] - 2023-03-18
561 - Switch internal benchmarking code to benny.
562 - Switch to TypeScript 5.x.x.
563 - Switch rollup bundler plugins to core ones.
564 - Switch to TSDoc syntax.
565 - Enforce conventional commits.
569 - Fix random integer generator.
570 - Fix worker choice strategy pool type identification at initialization.
572 ## [2.3.7] - 2022-10-23
576 - Switch to open collective FOSS project funding platform.
577 - Switch to ts-standard linter configuration on TypeScript code.
581 - Fixed missing async on pool execute method.
582 - Fixed typing in TypeScript example.
583 - Fixed types in unit tests.
585 ## [2.3.6] - 2022-10-22
589 - Cleanup pool attributes and methods.
590 - Refine error types thrown.
594 - Fix continuous integration build on windows.
595 - Fix code coverage reporting by using c8 instead of nyc.
597 ## [2.3.5] - 2022-10-21
601 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
602 - Optimize tasks usage lookup implementation.
606 - Fix missed pool event emitter type export.
607 - Fix typedoc documentation generation.
609 ## [2.3.4] - 2022-10-17
613 - Fully automate release process with release-it.
617 - Optimize fair share task scheduling algorithm implementation.
618 - Update benchmarks versus external pools results with latest version.
620 ## [2.3.3] - 2022-10-15
624 - Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
626 ## [2.3.2] - 2022-10-14
630 - Optimize fair share worker selection strategy implementation.
634 - Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
636 ## [2.3.1] - 2022-10-13
640 - Pool worker choice strategies:
641 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
642 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
644 ## [2.2.2] - 2022-10-09
648 - Fixed `README.md` file.
650 ## [2.2.1] - 2022-10-08
654 - Dynamic worker choice strategy change at runtime.
656 ## [2.2.0] - 2022-01-05
660 - Support only Node.js version 16.x.x for cluster pool: upstream cluster API have changed on that version.
662 ## [2.1.0] - 2021-08-29
666 - Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
670 - `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
671 - `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
672 - `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
673 - `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
675 ## [2.0.2] - 2021-05-12
679 - Fix `busy` event emission on fixed pool type
681 ## [2.0.1] - 2021-03-16
685 - Check if pool options are properly set.
686 - `busy` event is emitted on all pool types.
688 ## [2.0.0] - 2021-03-01
692 - Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
696 - `FullPool` event is now renamed to `busy`.
697 - `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
698 _Find more details on our JSDoc._
700 - `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
702 - We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
704 ### Pool options types declaration merge
706 `FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
708 #### New `export` strategy
712 const DynamicThreadPool = require('poolifier/lib/dynamic')
714 const { DynamicThreadPool } = require('poolifier/lib/dynamic')
717 But you should always prefer just using
720 const { DynamicThreadPool } = require('poolifier')
723 #### New type definitions for input data and response
725 For cluster worker and worker-thread pools, you can now only send and receive structured-cloneable data.
726 _This is not a limitation by poolifier but Node.js._
728 #### Public property replacements
730 `numWorkers` property is now `numberOfWorkers`
732 #### Internal (protected) properties and methods renaming
734 These properties are not intended for end users
736 - `id` => `nextMessageId`
738 These methods are not intended for end users
740 - `_chooseWorker` => `chooseWorker`
741 - `_newWorker` => `createWorker`
742 - `_execute` => `internalExecute`
743 - `_chooseWorker` => `chooseWorker`
744 - `_checkAlive` => `checkAlive`
746 - `_runAsync` => `runAsync`
748 ## [1.1.0] - 2020-05-21
752 - ThreadWorker support async functions as option
753 - Various external library patches
755 ## [1.0.0] - 2020-01-24
759 - FixedThreadPool implementation
760 - DynamicThreadPool implementation
761 - WorkerThread implementation to improve developer experience