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 - Fix worker choice strategy retries mechanism on some edge cases.
14 ## [2.6.30] - 2023-08-19
18 - Ensure pool event `backPressure` is emitted.
19 - Ensure pool event `full` is emitted only once.
20 - Ensure worker node cannot be instantiated without proper arguments.
22 ## [2.6.29] - 2023-08-18
26 - Fix race condition between ready and task functions worker message handling at startup.
27 - Fix duplicate task function worker usage statistics computation per task function.
28 - Update task function worker usage statistics if and only if there's at least two different task functions.
29 - Fix race condition at task function worker usage executing task computation leading to negative value.
33 - Add back pressure detection on the worker node queue. Event `backPressure` is emitted when all worker node queues are full (worker node queue size >= poolMaxSize^2).
34 - Use back pressure detection in worker choice strategies.
35 - Add worker choice strategies retries mechanism if no worker is eligible.
37 ## [2.6.28] - 2023-08-16
41 - Ensure pool workers are properly initialized.
45 - HTTP server pool examples: express-cluster, express-hybrid.
49 - Remove now useless branching in worker hot code path.
51 ## [2.6.27] - 2023-08-15
55 - Add `KillHandler` type definition to exported types.
59 - Add `destroy` event to pool API.
61 ## [2.6.26] - 2023-08-15
65 - Add kill handler to worker options allowing to execute custom code when worker is killed.
66 - Add `listTaskFunctions()` method to pool API.
67 - SMTP server pool example: nodemailer.
69 ## [2.6.25] - 2023-08-13
73 - HTTP server pool examples: fastify-cluster, fastify-hybrid.
74 - WebSocket server pool examples: ws-cluster, ws-hybrid.
76 ## [2.6.24] - 2023-08-12
80 - Add array of transferable objects to the `execute()` method arguments.
81 - WebSocket server pool examples: ws-worker_threads.
83 ## [2.6.23] - 2023-08-11
87 - 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.
91 - HTTP client pool examples: fetch, node-fetch and axios with multiple task functions.
92 - HTTP server pool examples: express-worker_threads, fastify-worker_threads.
94 ## [2.6.22] - 2023-08-10
98 - Add missing `types` field to package.json `exports`.
102 - Structure markdown documentation (PR #811).
104 ## [2.6.21] - 2023-08-03
108 - Improve code documentation.
109 - Code refactoring and cleanup for better maintainability and readability.
111 ## [2.6.20] - 2023-07-21
115 - Fix queued tasks redistribution on error task execution starvation.
116 - Ensure tasks queueing per worker condition is untangled from the pool busyness semantic.
120 - Drastically reduce lookups by worker in the worker nodes.
122 ## [2.6.19] - 2023-07-20
126 - Dedicated internal communication channel for worker_threads pools.
128 ## [2.6.18] - 2023-07-19
132 - Code refactoring and cleanup for better maintainability and readability. Bundle size is a bit smaller.
134 ## [2.6.17] - 2023-07-16
138 - Add `listTaskFunctions()` method to worker API.
140 ## [2.6.16] - 2023-07-12
144 - Fix pool startup detection.
145 - Fix worker task functions handling.
147 ## [2.6.15] - 2023-07-11
151 - Take into account worker node readiness in worker choice strategies.
153 ## [2.6.14] - 2023-07-10
157 - Fix task function statistics tracking.
159 ## [2.6.13] - 2023-07-10
163 - Add per task function statistics tracking.
164 - Add public methods to manipulate the worker task functions at runtime.
166 ## [2.6.12] - 2023-07-09
170 - Workaround import issue with `node:os` module in node 16.x.x.
172 ## [2.6.11] - 2023-07-09
176 - Fix pool readiness semantic.
178 ## [2.6.10] - 2023-07-08
182 - Ensure workers are not recreated on error at pool startup.
186 - Add `ready` and `strategy` fields to pool information.
187 - Add pool event `ready` to notify when the number of workers created in the pool has reached the maximum size expected and are ready.
188 - Add dynamic pool sizing checks.
190 ## [2.6.9] - 2023-07-07
194 - Recreate the right worker type on uncaught exception.
198 - Add minimum and maximum to internal measurement statistics.
199 - Add `runTime` and `waitTime` to pool information.
200 - Check worker inactive time only on dynamic worker.
202 ## [2.6.8] - 2023-07-03
206 - Brown paper bag release to fix version handling in pool information.
208 ## [2.6.7] - 2023-07-03
212 - Ensure worker queued tasks at error are reassigned to other pool workers.
216 - Add pool `utilization` ratio to pool information.
217 - Add `version` to pool information.
218 - Add worker information to worker nodes.
220 ## [2.6.6] - 2023-07-01
224 - Add safe helper `availableParallelism()` to help sizing the pool.
228 - Ensure message handler is only registered in worker.
230 ## [2.6.5] - 2023-06-27
234 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
238 - Artificial version bump to 2.6.5 to workaround publication issue.
239 - Ensure cluster pool `destroy()` gracefully shutdowns worker's server.
240 - Ensure pool event is emitted before task error promise rejection.
241 - Fix queued tasks count computation.
245 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
247 ## [2.6.4] - 2023-06-27
251 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
255 - Ensure cluster pool `destroy()` gracefully shutdowns worker's server.
256 - Ensure pool event is emitted before task error promise rejection.
257 - Fix queued tasks count computation.
261 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
263 ## [2.6.3] - 2023-06-19
267 - Ensure no tasks are queued when trying to soft kill a dynamic worker.
268 - Update strategies internals after statistics computation.
272 - Optimize O(1) queue implementation.
274 ## [2.6.2] - 2023-06-12
278 - Fix new worker use after creation in dynamic pool given the current worker choice strategy.
280 ## [2.6.1] - 2023-06-10
284 - Add worker choice strategy documentation: [README.md](./docs/worker-choice-strategies.md).
288 - Fix average statistics computation: ensure failed tasks are not accounted.
290 ## [2.6.0] - 2023-06-09
294 - Add `LEAST_ELU` worker choice strategy (experimental).
295 - Add tasks ELU instead of runtime support to `FAIR_SHARE` worker choice strategy.
299 - Refactor pool worker node usage internals.
300 - Breaking change: refactor worker choice strategy statistics requirements: the syntax of the worker choice strategy options has changed.
301 - Breaking change: pool information `info` property object fields have been renamed.
305 - Fix wait time accounting.
306 - Ensure worker choice strategy `LEAST_BUSY` accounts also tasks wait time.
307 - Ensure worker choice strategy `LEAST_USED` accounts also queued tasks.
309 ## [2.5.4] - 2023-06-07
313 - Add Event Loop Utilization (ELU) statistics to worker tasks usage.
317 - Compute statistics at the worker level only if needed.
318 - Add `worker_threads` options to thread pool options.
322 - Make the `LEAST_BUSY` strategy only relies on task runtime.
324 ## [2.5.3] - 2023-06-04
328 - Refine pool information content.
329 - Limit pool internals public exposure.
331 ## [2.5.2] - 2023-06-02
335 - Add `taskError` pool event for task execution error.
336 - Add pool information `info` property to pool.
337 - Emit pool information on `busy` and `full` pool events.
339 ## [2.5.1] - 2023-06-01
343 - Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
344 - Add `error` pool event for uncaught worker error.
346 ## [2.5.0] - 2023-05-31
350 - Switch pool event emitter to `EventEmitterAsyncResource`.
351 - Add tasks wait time accounting in per worker tasks usage.
352 - Add interleaved weighted round robin `INTERLEAVED_WEIGHTED_ROUND_ROBIN` worker choice strategy (experimental).
356 - Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
358 ## [2.4.14] - 2023-05-09
362 - Ensure no undefined task runtime can land in the tasks history.
363 - Fix median computation implementation once again.
367 - Unit tests for median and queue implementations.
369 ## [2.4.13] - 2023-05-08
373 - Fix worker choice strategy options validation.
374 - Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
376 ## [2.4.12] - 2023-05-06
380 - Support multiple task functions per worker.
381 - Add custom worker weights support to worker choice strategies options.
385 - Use O(1) queue implementation for tasks queueing.
389 - Fix median computation implementation.
390 - Fix fair share worker choice strategy internals update.
392 ## [2.4.11] - 2023-04-23
396 - Optimize free worker finding in worker choice strategies.
398 ## [2.4.10] - 2023-04-15
402 - Fix typescript type definition for task function: ensure the input data is optional.
403 - Fix typescript type definition for pool execute(): ensure the input data is optional.
405 ## [2.4.9] - 2023-04-15
409 - Add tasks queue enablement runtime setter to pool.
410 - Add tasks queue options runtime setter to pool.
411 - Add worker choice strategy options runtime setter to pool.
415 - Remove the tasks queuing experimental status.
419 - Fix task function type definition and validation.
420 - Fix worker choice strategy options handling.
422 ## [2.4.8] - 2023-04-12
426 - Fix message between main worker and worker type definition for tasks.
427 - Fix code documentation.
429 ## [2.4.7] - 2023-04-11
433 - Add worker tasks queue options to pool options.
437 - Fix missing documentation.
439 ## [2.4.6] - 2023-04-10
443 - Ensure one task at a time is executed per worker with tasks queueing enabled.
444 - Properly count worker executing tasks with tasks queueing enabled.
446 ## [2.4.5] - 2023-04-09
450 - Use monotonic high resolution timer for worker tasks runtime.
451 - Add worker tasks median runtime to statistics.
452 - Add worker tasks queue (experimental).
454 ## [2.4.4] - 2023-04-07
458 - Add `PoolEvents` enumeration and `PoolEvent` type.
462 - Destroy worker only on alive check.
464 ## [2.4.3] - 2023-04-07
468 - Fix typedoc generation with inheritance.
470 ## [2.4.2] - 2023-04-06
474 - Add `full` event to dynamic pool.
475 - Keep worker choice strategy in memory for conditional reuse.
479 - Fix possible negative worker key at worker removal in worker choice strategies.
481 ## [2.4.1] - 2023-04-05
485 - Optimize worker choice strategy for dynamic pool.
489 - Ensure dynamic pool does not alter worker choice strategy expected behavior.
491 ## [2.4.0] - 2023-04-04
495 - Add `LESS_BUSY` worker choice strategy.
499 - Optimize worker storage in pool.
500 - Optimize worker alive status check.
501 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
502 - Optimize `LESS_USED` worker choice strategy.
503 - Update benchmarks versus external threads pools.
504 - Optimize tasks usage statistics requirements for worker choice strategy.
508 - Ensure trimmable characters are checked at pool initialization.
509 - Fix message id integer overflow.
510 - Fix pool worker removal in worker choice strategy internals.
511 - Fix package publication with pnpm.
513 ## [2.4.0-3] - 2023-04-04
517 - Add `LESS_BUSY` worker choice strategy.
521 - Optimize worker storage in pool.
522 - Optimize worker alive status check.
523 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
524 - Optimize `LESS_USED` worker choice strategy.
525 - Update benchmarks versus external threads pools.
529 - Ensure trimmable characters are checked at pool initialization.
530 - Fix message id integer overflow.
531 - Fix pool worker removal in worker choice strategy internals.
532 - Fix package publication with pnpm.
534 ## [2.4.0-2] - 2023-04-03
538 - Add `LESS_BUSY` worker choice strategy.
542 - Optimize worker storage in pool.
543 - Optimize worker alive status check.
544 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
545 - Optimize `LESS_USED` worker choice strategy.
549 - Ensure trimmable characters are checked at pool initialization.
550 - Fix message id integer overflow.
551 - Fix pool worker removal in worker choice strategy internals.
552 - Fix package publication with pnpm.
554 ## [2.4.0-1] - 2023-04-03
558 - Add `LESS_BUSY` worker choice strategy.
562 - Optimize worker storage in pool.
563 - Optimize worker alive status check.
564 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
565 - Optimize `LESS_USED` worker choice strategy.
569 - Ensure trimmable characters are checked at pool initialization.
570 - Fix message id integer overflow.
571 - Fix pool worker removal in worker choice strategy internals.
573 ## [2.4.0-0] - 2023-04-03
577 - Add `LESS_BUSY` worker choice strategy.
581 - Optimize worker storage in pool.
582 - Optimize worker alive status check.
583 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
584 - Optimize `LESS_USED` worker choice strategy.
588 - Ensure trimmable characters are checked at pool initialization.
589 - Fix message id integer overflow.
590 - Fix pool worker removal in worker choice strategy internals.
592 ## [2.3.10] - 2023-03-18
596 - Fix package.json `exports` syntax for ESM and CommonJS.
600 - Permit SemVer pre-release publication.
602 ## [2.3.10-2] - 2023-03-18
606 - Fix package.json `exports` syntax for ESM and CommonJS.
608 ## [2.3.10-1] - 2023-03-18
612 - Permit SemVer pre-release publication.
614 ## [2.3.10-0] - 2023-03-18
618 - Fix package.json `exports` syntax for ESM and CommonJS.
620 ## [2.3.9] - 2023-03-18
624 - Introduce ESM module support along with CommonJS one.
628 - Fix brown paper bag bug referencing the same object literal.
630 ## [2.3.8] - 2023-03-18
634 - Switch internal benchmarking code to benny.
635 - Switch to TypeScript 5.x.x.
636 - Switch rollup bundler plugins to core ones.
637 - Switch to TSDoc syntax.
638 - Enforce conventional commits.
642 - Fix random integer generator.
643 - Fix worker choice strategy pool type identification at initialization.
645 ## [2.3.7] - 2022-10-23
649 - Switch to open collective FOSS project funding platform.
650 - Switch to ts-standard linter configuration on TypeScript code.
654 - Fixed missing async on pool execute method.
655 - Fixed typing in TypeScript example.
656 - Fixed types in unit tests.
658 ## [2.3.6] - 2022-10-22
662 - Cleanup pool attributes and methods.
663 - Refine error types thrown.
667 - Fix continuous integration build on windows.
668 - Fix code coverage reporting by using c8 instead of nyc.
670 ## [2.3.5] - 2022-10-21
674 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
675 - Optimize tasks usage lookup implementation.
679 - Fix missed pool event emitter type export.
680 - Fix typedoc documentation generation.
682 ## [2.3.4] - 2022-10-17
686 - Fully automate release process with release-it.
690 - Optimize fair share task scheduling algorithm implementation.
691 - Update benchmarks versus external pools results with latest version.
693 ## [2.3.3] - 2022-10-15
697 - Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
699 ## [2.3.2] - 2022-10-14
703 - Optimize fair share worker selection strategy implementation.
707 - Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
709 ## [2.3.1] - 2022-10-13
713 - Pool worker choice strategies:
714 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
715 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
717 ## [2.2.2] - 2022-10-09
721 - Fixed `README.md` file.
723 ## [2.2.1] - 2022-10-08
727 - Dynamic worker choice strategy change at runtime.
729 ## [2.2.0] - 2022-01-05
733 - Support only Node.js version 16.x.x for cluster pool: upstream cluster API have changed on that version.
735 ## [2.1.0] - 2021-08-29
739 - Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
743 - `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
744 - `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
745 - `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
746 - `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
748 ## [2.0.2] - 2021-05-12
752 - Fix `busy` event emission on fixed pool type
754 ## [2.0.1] - 2021-03-16
758 - Check if pool options are properly set.
759 - `busy` event is emitted on all pool types.
761 ## [2.0.0] - 2021-03-01
765 - Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
769 - `FullPool` event is now renamed to `busy`.
770 - `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
771 _Find more details on our JSDoc._
773 - `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
775 - We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
777 ### Pool options types declaration merge
779 `FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
781 #### New `export` strategy
785 const DynamicThreadPool = require('poolifier/lib/dynamic')
787 const { DynamicThreadPool } = require('poolifier/lib/dynamic')
790 But you should always prefer just using
793 const { DynamicThreadPool } = require('poolifier')
796 #### New type definitions for input data and response
798 For cluster worker and worker-thread pools, you can now only send and receive structured-cloneable data.
799 _This is not a limitation by poolifier but Node.js._
801 #### Public property replacements
803 `numWorkers` property is now `numberOfWorkers`
805 #### Internal (protected) properties and methods renaming
807 These properties are not intended for end users
809 - `id` => `nextMessageId`
811 These methods are not intended for end users
813 - `_chooseWorker` => `chooseWorker`
814 - `_newWorker` => `createWorker`
815 - `_execute` => `internalExecute`
816 - `_chooseWorker` => `chooseWorker`
817 - `_checkAlive` => `checkAlive`
819 - `_runAsync` => `runAsync`
821 ## [1.1.0] - 2020-05-21
825 - ThreadWorker support async functions as option
826 - Various external library patches
828 ## [1.0.0] - 2020-01-24
832 - FixedThreadPool implementation
833 - DynamicThreadPool implementation
834 - WorkerThread implementation to improve developer experience