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 pool startup detection.
13 - Fix worker task functions handling.
15 ## [2.6.15] - 2023-07-11
19 - Take into account worker node readiness in worker choice strategies.
21 ## [2.6.14] - 2023-07-10
25 - Fix task function statistics tracking.
27 ## [2.6.13] - 2023-07-10
31 - Add per task function statistics tracking.
32 - Add public methods to manipulate the worker task functions at runtime.
34 ## [2.6.12] - 2023-07-09
38 - Workaround import issue with `node:os` module in node 16.x.x.
40 ## [2.6.11] - 2023-07-09
44 - Fix pool readiness semantic.
46 ## [2.6.10] - 2023-07-08
50 - Ensure workers are not recreated on error at pool startup.
54 - Add `ready` and `strategy` fields to pool information.
55 - Add pool event `ready` to notify when the number of workers created in the pool has reached the maximum size expected and are ready.
56 - Add dynamic pool sizing checks.
58 ## [2.6.9] - 2023-07-07
62 - Recreate the right worker type on uncaught exception.
66 - Add minimum and maximum to internal measurement statistics.
67 - Add `runTime` and `waitTime` to pool information.
68 - Check worker inactive time only on dynamic worker.
70 ## [2.6.8] - 2023-07-03
74 - Brown paper bag release to fix version handling in pool information.
76 ## [2.6.7] - 2023-07-03
80 - Ensure worker queued tasks at error are reassigned to other pool workers.
84 - Add pool `utilization` ratio to pool information.
85 - Add `version` to pool information.
86 - Add worker information to worker nodes.
88 ## [2.6.6] - 2023-07-01
92 - Add safe helper `availableParallelism` to help sizing the pool.
96 - Ensure message handler is only registered in worker.
98 ## [2.6.5] - 2023-06-27
102 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
106 - Artificial version bump to 2.6.5 to workaround publication issue.
107 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
108 - Ensure pool event is emitted before task error promise rejection.
109 - Fix queued tasks count computation.
113 - Remove unneeded worker-threads worker `MessageChannel` internal usage for IPC.
115 ## [2.6.4] - 2023-06-27
119 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
123 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
124 - Ensure pool event is emitted before task error promise rejection.
125 - Fix queued tasks count computation.
129 - Remove unneeded worker-threads worker `MessageChannel` internal usage for IPC.
131 ## [2.6.3] - 2023-06-19
135 - Ensure no tasks are queued when trying to soft kill a dynamic worker.
136 - Update strategies internals after statistics computation.
140 - Optimize O(1) queue implementation.
142 ## [2.6.2] - 2023-06-12
146 - Fix new worker use after creation in dynamic pool given the current worker choice strategy.
148 ## [2.6.1] - 2023-06-10
152 - Add worker choice strategy documentation: [README.md](./src/pools/selection-strategies/README.md).
156 - Fix average statistics computation: ensure failed tasks are not accounted.
158 ## [2.6.0] - 2023-06-09
162 - Add `LEAST_ELU` worker choice strategy (experimental).
163 - Add tasks ELU instead of runtime support to `FAIR_SHARE` worker choice strategy.
167 - Refactor pool worker node usage internals.
168 - Breaking change: refactor worker choice strategy statistics requirements: the syntax of the worker choice strategy options has changed.
169 - Breaking change: pool information `info` property object fields have been renamed.
173 - Fix wait time accounting.
174 - Ensure worker choice strategy `LEAST_BUSY` accounts also tasks wait time.
175 - Ensure worker choice strategy `LEAST_USED` accounts also queued tasks.
177 ## [2.5.4] - 2023-06-07
181 - Add Event Loop Utilization (ELU) statistics to worker tasks usage.
185 - Compute statistics at the worker level only if needed.
186 - Add `worker-threads` options to thread pool options.
190 - Make the `LEAST_BUSY` strategy only relies on task runtime.
192 ## [2.5.3] - 2023-06-04
196 - Refine pool information content.
197 - Limit pool internals public exposure.
199 ## [2.5.2] - 2023-06-02
203 - Add `taskError` pool event for task execution error.
204 - Add pool information `info` property to pool.
205 - Emit pool information on `busy` and `full` pool events.
207 ## [2.5.1] - 2023-06-01
211 - Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
212 - Add `error` pool event for uncaught worker error.
214 ## [2.5.0] - 2023-05-31
218 - Switch pool event emitter to `EventEmitterAsyncResource`.
219 - Add tasks wait time accounting in per worker tasks usage.
220 - Add interleaved weighted round robin `INTERLEAVED_WEIGHTED_ROUND_ROBIN` worker choice strategy (experimental).
224 - Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
226 ## [2.4.14] - 2023-05-09
230 - Ensure no undefined task runtime can land in the tasks history.
231 - Fix median computation implementation once again.
235 - Unit tests for median and queue implementations.
237 ## [2.4.13] - 2023-05-08
241 - Fix worker choice strategy options validation.
242 - Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
244 ## [2.4.12] - 2023-05-06
248 - Support multiple task functions per worker.
249 - Add custom worker weights support to worker choice strategies options.
253 - Use O(1) queue implementation for tasks queueing.
257 - Fix median computation implementation.
258 - Fix fair share worker choice strategy internals update.
260 ## [2.4.11] - 2023-04-23
264 - Optimize free worker finding in worker choice strategies.
266 ## [2.4.10] - 2023-04-15
270 - Fix typescript type definition for worker function: ensure the input data is optional.
271 - Fix typescript type definition for pool execute(): ensure the input data is optional.
273 ## [2.4.9] - 2023-04-15
277 - Add tasks queue enablement runtime setter to pool.
278 - Add tasks queue options runtime setter to pool.
279 - Add worker choice strategy options runtime setter to pool.
283 - Remove the tasks queuing experimental status.
287 - Fix worker function type definition and validation.
288 - Fix worker choice strategy options handling.
290 ## [2.4.8] - 2023-04-12
294 - Fix message between main worker and worker type definition for tasks.
295 - Fix code documentation.
297 ## [2.4.7] - 2023-04-11
301 - Add worker tasks queue options to pool options.
305 - Fix missing documentation.
307 ## [2.4.6] - 2023-04-10
311 - Ensure one task at a time is executed per worker with tasks queueing enabled.
312 - Properly count worker executing tasks with tasks queueing enabled.
314 ## [2.4.5] - 2023-04-09
318 - Use monotonic high resolution timer for worker tasks runtime.
319 - Add worker tasks median runtime to statistics.
320 - Add worker tasks queue (experimental).
322 ## [2.4.4] - 2023-04-07
326 - Add `PoolEvents` enumeration and `PoolEvent` type.
330 - Destroy worker only on alive check.
332 ## [2.4.3] - 2023-04-07
336 - Fix typedoc generation with inheritance.
338 ## [2.4.2] - 2023-04-06
342 - Add `full` event to dynamic pool.
343 - Keep worker choice strategy in memory for conditional reuse.
347 - Fix possible negative worker key at worker removal in worker choice strategies.
349 ## [2.4.1] - 2023-04-05
353 - Optimize worker choice strategy for dynamic pool.
357 - Ensure dynamic pool does not alter worker choice strategy expected behavior.
359 ## [2.4.0] - 2023-04-04
363 - Add `LESS_BUSY` worker choice strategy.
367 - Optimize worker storage in pool.
368 - Optimize worker alive status check.
369 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
370 - Optimize `LESS_USED` worker choice strategy.
371 - Update benchmarks versus external threads pools.
372 - Optimize tasks usage statistics requirements for worker choice strategy.
376 - Ensure trimmable characters are checked at pool initialization.
377 - Fix message id integer overflow.
378 - Fix pool worker removal in worker choice strategy internals.
379 - Fix package publication with pnpm.
381 ## [2.4.0-3] - 2023-04-04
385 - Add `LESS_BUSY` worker choice strategy.
389 - Optimize worker storage in pool.
390 - Optimize worker alive status check.
391 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
392 - Optimize `LESS_USED` worker choice strategy.
393 - Update benchmarks versus external threads pools.
397 - Ensure trimmable characters are checked at pool initialization.
398 - Fix message id integer overflow.
399 - Fix pool worker removal in worker choice strategy internals.
400 - Fix package publication with pnpm.
402 ## [2.4.0-2] - 2023-04-03
406 - Add `LESS_BUSY` worker choice strategy.
410 - Optimize worker storage in pool.
411 - Optimize worker alive status check.
412 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
413 - Optimize `LESS_USED` worker choice strategy.
417 - Ensure trimmable characters are checked at pool initialization.
418 - Fix message id integer overflow.
419 - Fix pool worker removal in worker choice strategy internals.
420 - Fix package publication with pnpm.
422 ## [2.4.0-1] - 2023-04-03
426 - Add `LESS_BUSY` worker choice strategy.
430 - Optimize worker storage in pool.
431 - Optimize worker alive status check.
432 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
433 - Optimize `LESS_USED` worker choice strategy.
437 - Ensure trimmable characters are checked at pool initialization.
438 - Fix message id integer overflow.
439 - Fix pool worker removal in worker choice strategy internals.
441 ## [2.4.0-0] - 2023-04-03
445 - Add `LESS_BUSY` worker choice strategy.
449 - Optimize worker storage in pool.
450 - Optimize worker alive status check.
451 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
452 - Optimize `LESS_USED` worker choice strategy.
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.
460 ## [2.3.10] - 2023-03-18
464 - Fix `exports` syntax for ESM and CommonJS.
468 - Permit SemVer pre-release publication.
470 ## [2.3.10-2] - 2023-03-18
474 - Fix `exports` syntax for ESM and CommonJS.
476 ## [2.3.10-1] - 2023-03-18
480 - Permit SemVer pre-release publication.
482 ## [2.3.10-0] - 2023-03-18
486 - Fix `exports` syntax for ESM and CommonJS.
488 ## [2.3.9] - 2023-03-18
492 - Introduce ESM module support along with CommonJS one.
496 - Fix brown paper bag bug referencing the same object literal.
498 ## [2.3.8] - 2023-03-18
502 - Switch internal benchmarking code to benny.
503 - Switch to TypeScript 5.x.x.
504 - Switch rollup bundler plugins to core ones.
505 - Switch to TSDoc syntax.
506 - Enforce conventional commits.
510 - Fix random integer generator.
511 - Fix worker choice strategy pool type identification at initialization.
513 ## [2.3.7] - 2022-10-23
517 - Switch to open collective FOSS project funding platform.
518 - Switch to ts-standard linter configuration on TypeScript code.
522 - Fixed missing async on pool execute method.
523 - Fixed typing in TypeScript example.
524 - Fixed types in unit tests.
526 ## [2.3.6] - 2022-10-22
530 - Cleanup pool attributes and methods.
531 - Refine error types thrown.
535 - Fix continuous integration build on windows.
536 - Fix code coverage reporting by using c8 instead of nyc.
538 ## [2.3.5] - 2022-10-21
542 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
543 - Optimize tasks usage lookup implementation.
547 - Fix missed pool event emitter type export.
548 - Fix typedoc documentation generation.
550 ## [2.3.4] - 2022-10-17
554 - Fully automate release process with release-it.
558 - Optimize fair share task scheduling algorithm implementation.
559 - Update benchmarks versus external pools results with latest version.
561 ## [2.3.3] - 2022-10-15
565 - Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
567 ## [2.3.2] - 2022-10-14
571 - Optimize fair share worker selection strategy implementation.
575 - Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
577 ## [2.3.1] - 2022-10-13
581 - Pool worker choice strategies:
582 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
583 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
585 ## [2.2.2] - 2022-10-09
589 - Fixed `README.md` file.
591 ## [2.2.1] - 2022-10-08
595 - Dynamic worker choice strategy change at runtime.
597 ## [2.2.0] - 2022-01-05
601 - Support only NodeJS version 16.x.x for cluster pool: upstream cluster API have changed on that version.
603 ## [2.1.0] - 2021-08-29
607 - Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
611 - `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
612 - `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
613 - `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
614 - `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
616 ## [2.0.2] - 2021-05-12
620 - Fix `busy` event emission on fixed pool type
622 ## [2.0.1] - 2021-03-16
626 - Check if pool options are properly set.
627 - `busy` event is emitted on all pool types.
629 ## [2.0.0] - 2021-03-01
633 - Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
637 - `FullPool` event is now renamed to `busy`.
638 - `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
639 _Find more details on our JSDoc._
641 - `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
643 - We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
645 ### Pool options types declaration merge
647 `FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
649 #### New `export` strategy
653 const DynamicThreadPool = require('poolifier/lib/dynamic')
655 const { DynamicThreadPool } = require('poolifier/lib/dynamic')
658 But you should always prefer just using
661 const { DynamicThreadPool } = require('poolifier')
664 #### New type definitions for input data and response
666 For cluster worker and worker-thread pools, you can now only send and receive structured-cloneable data.
667 _This is not a limitation by poolifier but NodeJS._
669 #### Public property replacements
671 `numWorkers` property is now `numberOfWorkers`
673 #### Internal (protected) properties and methods renaming
675 These properties are not intended for end users
677 - `id` => `nextMessageId`
679 These methods are not intended for end users
681 - `_chooseWorker` => `chooseWorker`
682 - `_newWorker` => `createWorker`
683 - `_execute` => `internalExecute`
684 - `_chooseWorker` => `chooseWorker`
685 - `_checkAlive` => `checkAlive`
687 - `_runAsync` => `runAsync`
689 ## [1.1.0] - 2020-05-21
693 - ThreadWorker support async functions as option
694 - Various external library patches
696 ## [1.0.0] - 2020-01-24
700 - FixedThreadPool implementation
701 - DynamicThreadPool implementation
702 - WorkerThread implementation to improve developer experience