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 race condition between ready and task functions worker message handling at startup.
13 - Fix duplicate task usage statistics computation per task function.
15 ## [2.6.28] - 2023-08-16
19 - Ensure pool workers are properly initialized.
23 - HTTP server pool examples: express-cluster, express-hybrid.
27 - Remove now useless branching in worker hot code path.
29 ## [2.6.27] - 2023-08-15
33 - Add `KillHandler` type definition to exported types.
37 - Add `destroy` event to pool API.
39 ## [2.6.26] - 2023-08-15
43 - Add kill handler to worker options allowing to execute custom code when worker is killed.
44 - Add `listTaskFunctions()` method to pool API.
45 - SMTP server pool example: nodemailer.
47 ## [2.6.25] - 2023-08-13
51 - HTTP server pool examples: fastify-cluster, fastify-hybrid.
52 - WebSocket server pool examples: ws-cluster, ws-hybrid.
54 ## [2.6.24] - 2023-08-12
58 - Add array of transferable objects to the `execute()` method arguments.
59 - WebSocket server pool examples: ws-worker_threads.
61 ## [2.6.23] - 2023-08-11
65 - 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.
69 - HTTP client pool examples: fetch, node-fetch and axios with multiple task functions.
70 - HTTP server pool examples: express-worker_threads, fastify-worker_threads.
72 ## [2.6.22] - 2023-08-10
76 - Add missing `types` field to package.json `exports`.
80 - Structure markdown documentation (PR #811).
82 ## [2.6.21] - 2023-08-03
86 - Improve code documentation.
87 - Code refactoring and cleanup for better maintainability and readability.
89 ## [2.6.20] - 2023-07-21
93 - Fix queued tasks redistribution on error task execution starvation.
94 - Ensure task queueing per worker condition is untangled from the pool busyness semantic.
98 - Drastically reduce lookups by worker in the worker nodes.
100 ## [2.6.19] - 2023-07-20
104 - Dedicated internal communication channel for worker_threads pools.
106 ## [2.6.18] - 2023-07-19
110 - Code refactoring and cleanup for better maintainability and readability. Bundle size is a bit smaller.
112 ## [2.6.17] - 2023-07-16
116 - Add `listTaskFunctions()` method to worker API.
118 ## [2.6.16] - 2023-07-12
122 - Fix pool startup detection.
123 - Fix worker task functions handling.
125 ## [2.6.15] - 2023-07-11
129 - Take into account worker node readiness in worker choice strategies.
131 ## [2.6.14] - 2023-07-10
135 - Fix task function statistics tracking.
137 ## [2.6.13] - 2023-07-10
141 - Add per task function statistics tracking.
142 - Add public methods to manipulate the worker task functions at runtime.
144 ## [2.6.12] - 2023-07-09
148 - Workaround import issue with `node:os` module in node 16.x.x.
150 ## [2.6.11] - 2023-07-09
154 - Fix pool readiness semantic.
156 ## [2.6.10] - 2023-07-08
160 - Ensure workers are not recreated on error at pool startup.
164 - Add `ready` and `strategy` fields to pool information.
165 - Add pool event `ready` to notify when the number of workers created in the pool has reached the maximum size expected and are ready.
166 - Add dynamic pool sizing checks.
168 ## [2.6.9] - 2023-07-07
172 - Recreate the right worker type on uncaught exception.
176 - Add minimum and maximum to internal measurement statistics.
177 - Add `runTime` and `waitTime` to pool information.
178 - Check worker inactive time only on dynamic worker.
180 ## [2.6.8] - 2023-07-03
184 - Brown paper bag release to fix version handling in pool information.
186 ## [2.6.7] - 2023-07-03
190 - Ensure worker queued tasks at error are reassigned to other pool workers.
194 - Add pool `utilization` ratio to pool information.
195 - Add `version` to pool information.
196 - Add worker information to worker nodes.
198 ## [2.6.6] - 2023-07-01
202 - Add safe helper `availableParallelism` to help sizing the pool.
206 - Ensure message handler is only registered in worker.
208 ## [2.6.5] - 2023-06-27
212 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
216 - Artificial version bump to 2.6.5 to workaround publication issue.
217 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
218 - Ensure pool event is emitted before task error promise rejection.
219 - Fix queued tasks count computation.
223 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
225 ## [2.6.4] - 2023-06-27
229 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
233 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
234 - Ensure pool event is emitted before task error promise rejection.
235 - Fix queued tasks count computation.
239 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
241 ## [2.6.3] - 2023-06-19
245 - Ensure no tasks are queued when trying to soft kill a dynamic worker.
246 - Update strategies internals after statistics computation.
250 - Optimize O(1) queue implementation.
252 ## [2.6.2] - 2023-06-12
256 - Fix new worker use after creation in dynamic pool given the current worker choice strategy.
258 ## [2.6.1] - 2023-06-10
262 - Add worker choice strategy documentation: [README.md](./docs/worker-choice-strategies.md).
266 - Fix average statistics computation: ensure failed tasks are not accounted.
268 ## [2.6.0] - 2023-06-09
272 - Add `LEAST_ELU` worker choice strategy (experimental).
273 - Add tasks ELU instead of runtime support to `FAIR_SHARE` worker choice strategy.
277 - Refactor pool worker node usage internals.
278 - Breaking change: refactor worker choice strategy statistics requirements: the syntax of the worker choice strategy options has changed.
279 - Breaking change: pool information `info` property object fields have been renamed.
283 - Fix wait time accounting.
284 - Ensure worker choice strategy `LEAST_BUSY` accounts also tasks wait time.
285 - Ensure worker choice strategy `LEAST_USED` accounts also queued tasks.
287 ## [2.5.4] - 2023-06-07
291 - Add Event Loop Utilization (ELU) statistics to worker tasks usage.
295 - Compute statistics at the worker level only if needed.
296 - Add `worker_threads` options to thread pool options.
300 - Make the `LEAST_BUSY` strategy only relies on task runtime.
302 ## [2.5.3] - 2023-06-04
306 - Refine pool information content.
307 - Limit pool internals public exposure.
309 ## [2.5.2] - 2023-06-02
313 - Add `taskError` pool event for task execution error.
314 - Add pool information `info` property to pool.
315 - Emit pool information on `busy` and `full` pool events.
317 ## [2.5.1] - 2023-06-01
321 - Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
322 - Add `error` pool event for uncaught worker error.
324 ## [2.5.0] - 2023-05-31
328 - Switch pool event emitter to `EventEmitterAsyncResource`.
329 - Add tasks wait time accounting in per worker tasks usage.
330 - Add interleaved weighted round robin `INTERLEAVED_WEIGHTED_ROUND_ROBIN` worker choice strategy (experimental).
334 - Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
336 ## [2.4.14] - 2023-05-09
340 - Ensure no undefined task runtime can land in the tasks history.
341 - Fix median computation implementation once again.
345 - Unit tests for median and queue implementations.
347 ## [2.4.13] - 2023-05-08
351 - Fix worker choice strategy options validation.
352 - Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
354 ## [2.4.12] - 2023-05-06
358 - Support multiple task functions per worker.
359 - Add custom worker weights support to worker choice strategies options.
363 - Use O(1) queue implementation for tasks queueing.
367 - Fix median computation implementation.
368 - Fix fair share worker choice strategy internals update.
370 ## [2.4.11] - 2023-04-23
374 - Optimize free worker finding in worker choice strategies.
376 ## [2.4.10] - 2023-04-15
380 - Fix typescript type definition for task function: ensure the input data is optional.
381 - Fix typescript type definition for pool execute(): ensure the input data is optional.
383 ## [2.4.9] - 2023-04-15
387 - Add tasks queue enablement runtime setter to pool.
388 - Add tasks queue options runtime setter to pool.
389 - Add worker choice strategy options runtime setter to pool.
393 - Remove the tasks queuing experimental status.
397 - Fix task function type definition and validation.
398 - Fix worker choice strategy options handling.
400 ## [2.4.8] - 2023-04-12
404 - Fix message between main worker and worker type definition for tasks.
405 - Fix code documentation.
407 ## [2.4.7] - 2023-04-11
411 - Add worker tasks queue options to pool options.
415 - Fix missing documentation.
417 ## [2.4.6] - 2023-04-10
421 - Ensure one task at a time is executed per worker with tasks queueing enabled.
422 - Properly count worker executing tasks with tasks queueing enabled.
424 ## [2.4.5] - 2023-04-09
428 - Use monotonic high resolution timer for worker tasks runtime.
429 - Add worker tasks median runtime to statistics.
430 - Add worker tasks queue (experimental).
432 ## [2.4.4] - 2023-04-07
436 - Add `PoolEvents` enumeration and `PoolEvent` type.
440 - Destroy worker only on alive check.
442 ## [2.4.3] - 2023-04-07
446 - Fix typedoc generation with inheritance.
448 ## [2.4.2] - 2023-04-06
452 - Add `full` event to dynamic pool.
453 - Keep worker choice strategy in memory for conditional reuse.
457 - Fix possible negative worker key at worker removal in worker choice strategies.
459 ## [2.4.1] - 2023-04-05
463 - Optimize worker choice strategy for dynamic pool.
467 - Ensure dynamic pool does not alter worker choice strategy expected behavior.
469 ## [2.4.0] - 2023-04-04
473 - Add `LESS_BUSY` worker choice strategy.
477 - Optimize worker storage in pool.
478 - Optimize worker alive status check.
479 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
480 - Optimize `LESS_USED` worker choice strategy.
481 - Update benchmarks versus external threads pools.
482 - Optimize tasks usage statistics requirements for worker choice strategy.
486 - Ensure trimmable characters are checked at pool initialization.
487 - Fix message id integer overflow.
488 - Fix pool worker removal in worker choice strategy internals.
489 - Fix package publication with pnpm.
491 ## [2.4.0-3] - 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.
507 - Ensure trimmable characters are checked at pool initialization.
508 - Fix message id integer overflow.
509 - Fix pool worker removal in worker choice strategy internals.
510 - Fix package publication with pnpm.
512 ## [2.4.0-2] - 2023-04-03
516 - Add `LESS_BUSY` worker choice strategy.
520 - Optimize worker storage in pool.
521 - Optimize worker alive status check.
522 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
523 - Optimize `LESS_USED` worker choice strategy.
527 - Ensure trimmable characters are checked at pool initialization.
528 - Fix message id integer overflow.
529 - Fix pool worker removal in worker choice strategy internals.
530 - Fix package publication with pnpm.
532 ## [2.4.0-1] - 2023-04-03
536 - Add `LESS_BUSY` worker choice strategy.
540 - Optimize worker storage in pool.
541 - Optimize worker alive status check.
542 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
543 - Optimize `LESS_USED` worker choice strategy.
547 - Ensure trimmable characters are checked at pool initialization.
548 - Fix message id integer overflow.
549 - Fix pool worker removal in worker choice strategy internals.
551 ## [2.4.0-0] - 2023-04-03
555 - Add `LESS_BUSY` worker choice strategy.
559 - Optimize worker storage in pool.
560 - Optimize worker alive status check.
561 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
562 - Optimize `LESS_USED` worker choice strategy.
566 - Ensure trimmable characters are checked at pool initialization.
567 - Fix message id integer overflow.
568 - Fix pool worker removal in worker choice strategy internals.
570 ## [2.3.10] - 2023-03-18
574 - Fix package.json `exports` syntax for ESM and CommonJS.
578 - Permit SemVer pre-release publication.
580 ## [2.3.10-2] - 2023-03-18
584 - Fix package.json `exports` syntax for ESM and CommonJS.
586 ## [2.3.10-1] - 2023-03-18
590 - Permit SemVer pre-release publication.
592 ## [2.3.10-0] - 2023-03-18
596 - Fix package.json `exports` syntax for ESM and CommonJS.
598 ## [2.3.9] - 2023-03-18
602 - Introduce ESM module support along with CommonJS one.
606 - Fix brown paper bag bug referencing the same object literal.
608 ## [2.3.8] - 2023-03-18
612 - Switch internal benchmarking code to benny.
613 - Switch to TypeScript 5.x.x.
614 - Switch rollup bundler plugins to core ones.
615 - Switch to TSDoc syntax.
616 - Enforce conventional commits.
620 - Fix random integer generator.
621 - Fix worker choice strategy pool type identification at initialization.
623 ## [2.3.7] - 2022-10-23
627 - Switch to open collective FOSS project funding platform.
628 - Switch to ts-standard linter configuration on TypeScript code.
632 - Fixed missing async on pool execute method.
633 - Fixed typing in TypeScript example.
634 - Fixed types in unit tests.
636 ## [2.3.6] - 2022-10-22
640 - Cleanup pool attributes and methods.
641 - Refine error types thrown.
645 - Fix continuous integration build on windows.
646 - Fix code coverage reporting by using c8 instead of nyc.
648 ## [2.3.5] - 2022-10-21
652 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
653 - Optimize tasks usage lookup implementation.
657 - Fix missed pool event emitter type export.
658 - Fix typedoc documentation generation.
660 ## [2.3.4] - 2022-10-17
664 - Fully automate release process with release-it.
668 - Optimize fair share task scheduling algorithm implementation.
669 - Update benchmarks versus external pools results with latest version.
671 ## [2.3.3] - 2022-10-15
675 - Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
677 ## [2.3.2] - 2022-10-14
681 - Optimize fair share worker selection strategy implementation.
685 - Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
687 ## [2.3.1] - 2022-10-13
691 - Pool worker choice strategies:
692 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
693 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
695 ## [2.2.2] - 2022-10-09
699 - Fixed `README.md` file.
701 ## [2.2.1] - 2022-10-08
705 - Dynamic worker choice strategy change at runtime.
707 ## [2.2.0] - 2022-01-05
711 - Support only Node.js version 16.x.x for cluster pool: upstream cluster API have changed on that version.
713 ## [2.1.0] - 2021-08-29
717 - Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
721 - `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
722 - `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
723 - `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
724 - `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
726 ## [2.0.2] - 2021-05-12
730 - Fix `busy` event emission on fixed pool type
732 ## [2.0.1] - 2021-03-16
736 - Check if pool options are properly set.
737 - `busy` event is emitted on all pool types.
739 ## [2.0.0] - 2021-03-01
743 - Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
747 - `FullPool` event is now renamed to `busy`.
748 - `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
749 _Find more details on our JSDoc._
751 - `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
753 - We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
755 ### Pool options types declaration merge
757 `FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
759 #### New `export` strategy
763 const DynamicThreadPool = require('poolifier/lib/dynamic')
765 const { DynamicThreadPool } = require('poolifier/lib/dynamic')
768 But you should always prefer just using
771 const { DynamicThreadPool } = require('poolifier')
774 #### New type definitions for input data and response
776 For cluster worker and worker-thread pools, you can now only send and receive structured-cloneable data.
777 _This is not a limitation by poolifier but Node.js._
779 #### Public property replacements
781 `numWorkers` property is now `numberOfWorkers`
783 #### Internal (protected) properties and methods renaming
785 These properties are not intended for end users
787 - `id` => `nextMessageId`
789 These methods are not intended for end users
791 - `_chooseWorker` => `chooseWorker`
792 - `_newWorker` => `createWorker`
793 - `_execute` => `internalExecute`
794 - `_chooseWorker` => `chooseWorker`
795 - `_checkAlive` => `checkAlive`
797 - `_runAsync` => `runAsync`
799 ## [1.1.0] - 2020-05-21
803 - ThreadWorker support async functions as option
804 - Various external library patches
806 ## [1.0.0] - 2020-01-24
810 - FixedThreadPool implementation
811 - DynamicThreadPool implementation
812 - WorkerThread implementation to improve developer experience