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 - Add array of transferable objects to the `execute()` method arguments.
13 - WebSocket server pool examples: ws
15 ## [2.6.23] - 2023-08-11
19 - 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.
23 - HTTP client pool examples: fetch, node-fetch and axios with multiple task functions.
24 - HTTP server pool examples: express, fastify.
26 ## [2.6.22] - 2023-08-10
30 - Add missing `types` field to package.json `exports`.
34 - Structure markdown documentation (PR #811).
36 ## [2.6.21] - 2023-08-03
40 - Improve code documentation.
41 - Code refactoring and cleanup for better maintainability and readability.
43 ## [2.6.20] - 2023-07-21
47 - Fix queued tasks redistribution on error task execution starvation.
48 - Ensure task queueing per worker condition is untangled from the pool busyness semantic.
52 - Drastically reduce lookups by worker in the worker nodes.
54 ## [2.6.19] - 2023-07-20
58 - Dedicated internal communication channel for worker_threads pools.
60 ## [2.6.18] - 2023-07-19
64 - Code refactoring and cleanup for better maintainability and readability. Bundle size is a bit smaller.
66 ## [2.6.17] - 2023-07-16
70 - Add `listTaskFunctions()` method to worker class.
72 ## [2.6.16] - 2023-07-12
76 - Fix pool startup detection.
77 - Fix worker task functions handling.
79 ## [2.6.15] - 2023-07-11
83 - Take into account worker node readiness in worker choice strategies.
85 ## [2.6.14] - 2023-07-10
89 - Fix task function statistics tracking.
91 ## [2.6.13] - 2023-07-10
95 - Add per task function statistics tracking.
96 - Add public methods to manipulate the worker task functions at runtime.
98 ## [2.6.12] - 2023-07-09
102 - Workaround import issue with `node:os` module in node 16.x.x.
104 ## [2.6.11] - 2023-07-09
108 - Fix pool readiness semantic.
110 ## [2.6.10] - 2023-07-08
114 - Ensure workers are not recreated on error at pool startup.
118 - Add `ready` and `strategy` fields to pool information.
119 - Add pool event `ready` to notify when the number of workers created in the pool has reached the maximum size expected and are ready.
120 - Add dynamic pool sizing checks.
122 ## [2.6.9] - 2023-07-07
126 - Recreate the right worker type on uncaught exception.
130 - Add minimum and maximum to internal measurement statistics.
131 - Add `runTime` and `waitTime` to pool information.
132 - Check worker inactive time only on dynamic worker.
134 ## [2.6.8] - 2023-07-03
138 - Brown paper bag release to fix version handling in pool information.
140 ## [2.6.7] - 2023-07-03
144 - Ensure worker queued tasks at error are reassigned to other pool workers.
148 - Add pool `utilization` ratio to pool information.
149 - Add `version` to pool information.
150 - Add worker information to worker nodes.
152 ## [2.6.6] - 2023-07-01
156 - Add safe helper `availableParallelism` to help sizing the pool.
160 - Ensure message handler is only registered in worker.
162 ## [2.6.5] - 2023-06-27
166 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
170 - Artificial version bump to 2.6.5 to workaround publication issue.
171 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
172 - Ensure pool event is emitted before task error promise rejection.
173 - Fix queued tasks count computation.
177 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
179 ## [2.6.4] - 2023-06-27
183 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
187 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
188 - Ensure pool event is emitted before task error promise rejection.
189 - Fix queued tasks count computation.
193 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
195 ## [2.6.3] - 2023-06-19
199 - Ensure no tasks are queued when trying to soft kill a dynamic worker.
200 - Update strategies internals after statistics computation.
204 - Optimize O(1) queue implementation.
206 ## [2.6.2] - 2023-06-12
210 - Fix new worker use after creation in dynamic pool given the current worker choice strategy.
212 ## [2.6.1] - 2023-06-10
216 - Add worker choice strategy documentation: [README.md](./docs/worker-choice-strategies.md).
220 - Fix average statistics computation: ensure failed tasks are not accounted.
222 ## [2.6.0] - 2023-06-09
226 - Add `LEAST_ELU` worker choice strategy (experimental).
227 - Add tasks ELU instead of runtime support to `FAIR_SHARE` worker choice strategy.
231 - Refactor pool worker node usage internals.
232 - Breaking change: refactor worker choice strategy statistics requirements: the syntax of the worker choice strategy options has changed.
233 - Breaking change: pool information `info` property object fields have been renamed.
237 - Fix wait time accounting.
238 - Ensure worker choice strategy `LEAST_BUSY` accounts also tasks wait time.
239 - Ensure worker choice strategy `LEAST_USED` accounts also queued tasks.
241 ## [2.5.4] - 2023-06-07
245 - Add Event Loop Utilization (ELU) statistics to worker tasks usage.
249 - Compute statistics at the worker level only if needed.
250 - Add `worker_threads` options to thread pool options.
254 - Make the `LEAST_BUSY` strategy only relies on task runtime.
256 ## [2.5.3] - 2023-06-04
260 - Refine pool information content.
261 - Limit pool internals public exposure.
263 ## [2.5.2] - 2023-06-02
267 - Add `taskError` pool event for task execution error.
268 - Add pool information `info` property to pool.
269 - Emit pool information on `busy` and `full` pool events.
271 ## [2.5.1] - 2023-06-01
275 - Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
276 - Add `error` pool event for uncaught worker error.
278 ## [2.5.0] - 2023-05-31
282 - Switch pool event emitter to `EventEmitterAsyncResource`.
283 - Add tasks wait time accounting in per worker tasks usage.
284 - Add interleaved weighted round robin `INTERLEAVED_WEIGHTED_ROUND_ROBIN` worker choice strategy (experimental).
288 - Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
290 ## [2.4.14] - 2023-05-09
294 - Ensure no undefined task runtime can land in the tasks history.
295 - Fix median computation implementation once again.
299 - Unit tests for median and queue implementations.
301 ## [2.4.13] - 2023-05-08
305 - Fix worker choice strategy options validation.
306 - Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
308 ## [2.4.12] - 2023-05-06
312 - Support multiple task functions per worker.
313 - Add custom worker weights support to worker choice strategies options.
317 - Use O(1) queue implementation for tasks queueing.
321 - Fix median computation implementation.
322 - Fix fair share worker choice strategy internals update.
324 ## [2.4.11] - 2023-04-23
328 - Optimize free worker finding in worker choice strategies.
330 ## [2.4.10] - 2023-04-15
334 - Fix typescript type definition for task function: ensure the input data is optional.
335 - Fix typescript type definition for pool execute(): ensure the input data is optional.
337 ## [2.4.9] - 2023-04-15
341 - Add tasks queue enablement runtime setter to pool.
342 - Add tasks queue options runtime setter to pool.
343 - Add worker choice strategy options runtime setter to pool.
347 - Remove the tasks queuing experimental status.
351 - Fix task function type definition and validation.
352 - Fix worker choice strategy options handling.
354 ## [2.4.8] - 2023-04-12
358 - Fix message between main worker and worker type definition for tasks.
359 - Fix code documentation.
361 ## [2.4.7] - 2023-04-11
365 - Add worker tasks queue options to pool options.
369 - Fix missing documentation.
371 ## [2.4.6] - 2023-04-10
375 - Ensure one task at a time is executed per worker with tasks queueing enabled.
376 - Properly count worker executing tasks with tasks queueing enabled.
378 ## [2.4.5] - 2023-04-09
382 - Use monotonic high resolution timer for worker tasks runtime.
383 - Add worker tasks median runtime to statistics.
384 - Add worker tasks queue (experimental).
386 ## [2.4.4] - 2023-04-07
390 - Add `PoolEvents` enumeration and `PoolEvent` type.
394 - Destroy worker only on alive check.
396 ## [2.4.3] - 2023-04-07
400 - Fix typedoc generation with inheritance.
402 ## [2.4.2] - 2023-04-06
406 - Add `full` event to dynamic pool.
407 - Keep worker choice strategy in memory for conditional reuse.
411 - Fix possible negative worker key at worker removal in worker choice strategies.
413 ## [2.4.1] - 2023-04-05
417 - Optimize worker choice strategy for dynamic pool.
421 - Ensure dynamic pool does not alter worker choice strategy expected behavior.
423 ## [2.4.0] - 2023-04-04
427 - Add `LESS_BUSY` worker choice strategy.
431 - Optimize worker storage in pool.
432 - Optimize worker alive status check.
433 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
434 - Optimize `LESS_USED` worker choice strategy.
435 - Update benchmarks versus external threads pools.
436 - Optimize tasks usage statistics requirements for worker choice strategy.
440 - Ensure trimmable characters are checked at pool initialization.
441 - Fix message id integer overflow.
442 - Fix pool worker removal in worker choice strategy internals.
443 - Fix package publication with pnpm.
445 ## [2.4.0-3] - 2023-04-04
449 - Add `LESS_BUSY` worker choice strategy.
453 - Optimize worker storage in pool.
454 - Optimize worker alive status check.
455 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
456 - Optimize `LESS_USED` worker choice strategy.
457 - Update benchmarks versus external threads pools.
461 - Ensure trimmable characters are checked at pool initialization.
462 - Fix message id integer overflow.
463 - Fix pool worker removal in worker choice strategy internals.
464 - Fix package publication with pnpm.
466 ## [2.4.0-2] - 2023-04-03
470 - Add `LESS_BUSY` worker choice strategy.
474 - Optimize worker storage in pool.
475 - Optimize worker alive status check.
476 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
477 - Optimize `LESS_USED` worker choice strategy.
481 - Ensure trimmable characters are checked at pool initialization.
482 - Fix message id integer overflow.
483 - Fix pool worker removal in worker choice strategy internals.
484 - Fix package publication with pnpm.
486 ## [2.4.0-1] - 2023-04-03
490 - Add `LESS_BUSY` worker choice strategy.
494 - Optimize worker storage in pool.
495 - Optimize worker alive status check.
496 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
497 - Optimize `LESS_USED` worker choice strategy.
501 - Ensure trimmable characters are checked at pool initialization.
502 - Fix message id integer overflow.
503 - Fix pool worker removal in worker choice strategy internals.
505 ## [2.4.0-0] - 2023-04-03
509 - Add `LESS_BUSY` worker choice strategy.
513 - Optimize worker storage in pool.
514 - Optimize worker alive status check.
515 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
516 - Optimize `LESS_USED` worker choice strategy.
520 - Ensure trimmable characters are checked at pool initialization.
521 - Fix message id integer overflow.
522 - Fix pool worker removal in worker choice strategy internals.
524 ## [2.3.10] - 2023-03-18
528 - Fix package.json `exports` syntax for ESM and CommonJS.
532 - Permit SemVer pre-release publication.
534 ## [2.3.10-2] - 2023-03-18
538 - Fix package.json `exports` syntax for ESM and CommonJS.
540 ## [2.3.10-1] - 2023-03-18
544 - Permit SemVer pre-release publication.
546 ## [2.3.10-0] - 2023-03-18
550 - Fix package.json `exports` syntax for ESM and CommonJS.
552 ## [2.3.9] - 2023-03-18
556 - Introduce ESM module support along with CommonJS one.
560 - Fix brown paper bag bug referencing the same object literal.
562 ## [2.3.8] - 2023-03-18
566 - Switch internal benchmarking code to benny.
567 - Switch to TypeScript 5.x.x.
568 - Switch rollup bundler plugins to core ones.
569 - Switch to TSDoc syntax.
570 - Enforce conventional commits.
574 - Fix random integer generator.
575 - Fix worker choice strategy pool type identification at initialization.
577 ## [2.3.7] - 2022-10-23
581 - Switch to open collective FOSS project funding platform.
582 - Switch to ts-standard linter configuration on TypeScript code.
586 - Fixed missing async on pool execute method.
587 - Fixed typing in TypeScript example.
588 - Fixed types in unit tests.
590 ## [2.3.6] - 2022-10-22
594 - Cleanup pool attributes and methods.
595 - Refine error types thrown.
599 - Fix continuous integration build on windows.
600 - Fix code coverage reporting by using c8 instead of nyc.
602 ## [2.3.5] - 2022-10-21
606 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
607 - Optimize tasks usage lookup implementation.
611 - Fix missed pool event emitter type export.
612 - Fix typedoc documentation generation.
614 ## [2.3.4] - 2022-10-17
618 - Fully automate release process with release-it.
622 - Optimize fair share task scheduling algorithm implementation.
623 - Update benchmarks versus external pools results with latest version.
625 ## [2.3.3] - 2022-10-15
629 - Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
631 ## [2.3.2] - 2022-10-14
635 - Optimize fair share worker selection strategy implementation.
639 - Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
641 ## [2.3.1] - 2022-10-13
645 - Pool worker choice strategies:
646 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
647 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
649 ## [2.2.2] - 2022-10-09
653 - Fixed `README.md` file.
655 ## [2.2.1] - 2022-10-08
659 - Dynamic worker choice strategy change at runtime.
661 ## [2.2.0] - 2022-01-05
665 - Support only Node.js version 16.x.x for cluster pool: upstream cluster API have changed on that version.
667 ## [2.1.0] - 2021-08-29
671 - Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
675 - `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
676 - `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
677 - `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
678 - `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
680 ## [2.0.2] - 2021-05-12
684 - Fix `busy` event emission on fixed pool type
686 ## [2.0.1] - 2021-03-16
690 - Check if pool options are properly set.
691 - `busy` event is emitted on all pool types.
693 ## [2.0.0] - 2021-03-01
697 - Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
701 - `FullPool` event is now renamed to `busy`.
702 - `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
703 _Find more details on our JSDoc._
705 - `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
707 - We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
709 ### Pool options types declaration merge
711 `FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
713 #### New `export` strategy
717 const DynamicThreadPool = require('poolifier/lib/dynamic')
719 const { DynamicThreadPool } = require('poolifier/lib/dynamic')
722 But you should always prefer just using
725 const { DynamicThreadPool } = require('poolifier')
728 #### New type definitions for input data and response
730 For cluster worker and worker-thread pools, you can now only send and receive structured-cloneable data.
731 _This is not a limitation by poolifier but Node.js._
733 #### Public property replacements
735 `numWorkers` property is now `numberOfWorkers`
737 #### Internal (protected) properties and methods renaming
739 These properties are not intended for end users
741 - `id` => `nextMessageId`
743 These methods are not intended for end users
745 - `_chooseWorker` => `chooseWorker`
746 - `_newWorker` => `createWorker`
747 - `_execute` => `internalExecute`
748 - `_chooseWorker` => `chooseWorker`
749 - `_checkAlive` => `checkAlive`
751 - `_runAsync` => `runAsync`
753 ## [1.1.0] - 2020-05-21
757 - ThreadWorker support async functions as option
758 - Various external library patches
760 ## [1.0.0] - 2020-01-24
764 - FixedThreadPool implementation
765 - DynamicThreadPool implementation
766 - WorkerThread implementation to improve developer experience