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 - Workaround import issue with `node:os` module in node 16.x.x.
14 ## [2.6.11] - 2023-07-09
18 - Fix pool readiness semantic.
20 ## [2.6.10] - 2023-07-08
24 - Ensure workers are not recreated on error at pool startup.
28 - Add `ready` and `strategy` fields to pool information.
29 - Add pool event `ready` to notify when the number of workers created in the pool has reached the maximum size expected and are ready.
30 - Add dynamic pool sizing checks.
32 ## [2.6.9] - 2023-07-07
36 - Recreate the right worker type on uncaught exception.
40 - Add minimum and maximum to internal measurement statistics.
41 - Add `runTime` and `waitTime` to pool information.
42 - Check worker inactive time only on dynamic worker.
44 ## [2.6.8] - 2023-07-03
48 - Brown paper bag release to fix version handling in pool information.
50 ## [2.6.7] - 2023-07-03
54 - Ensure worker queued tasks at error are reassigned to other pool workers.
58 - Add pool `utilization` ratio to pool information.
59 - Add `version` to pool information.
60 - Add worker information to worker nodes.
62 ## [2.6.6] - 2023-07-01
66 - Add safe helper `availableParallelism` to help sizing the pool.
70 - Ensure message handler is only registered in worker.
72 ## [2.6.5] - 2023-06-27
76 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
80 - Artificial version bump to 2.6.5 to workaround publication issue.
81 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
82 - Ensure pool event is emitted before task error promise rejection.
83 - Fix queued tasks count computation.
87 - Remove unneeded worker-threads worker `MessageChannel` internal usage for IPC.
89 ## [2.6.4] - 2023-06-27
93 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
97 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
98 - Ensure pool event is emitted before task error promise rejection.
99 - Fix queued tasks count computation.
103 - Remove unneeded worker-threads worker `MessageChannel` internal usage for IPC.
105 ## [2.6.3] - 2023-06-19
109 - Ensure no tasks are queued when trying to soft kill a dynamic worker.
110 - Update strategies internals after statistics computation.
114 - Optimize O(1) queue implementation.
116 ## [2.6.2] - 2023-06-12
120 - Fix new worker use after creation in dynamic pool given the current worker choice strategy.
122 ## [2.6.1] - 2023-06-10
126 - Add worker choice strategy documentation: [README.md](./src/pools/selection-strategies/README.md).
130 - Fix average statistics computation: ensure failed tasks are not accounted.
132 ## [2.6.0] - 2023-06-09
136 - Add `LEAST_ELU` worker choice strategy (experimental).
137 - Add tasks ELU instead of runtime support to `FAIR_SHARE` worker choice strategy.
141 - Refactor pool worker node usage internals.
142 - Breaking change: refactor worker choice strategy statistics requirements: the syntax of the worker choice strategy options has changed.
143 - Breaking change: pool information `info` property object fields have been renamed.
147 - Fix wait time accounting.
148 - Ensure worker choice strategy `LEAST_BUSY` accounts also tasks wait time.
149 - Ensure worker choice strategy `LEAST_USED` accounts also queued tasks.
151 ## [2.5.4] - 2023-06-07
155 - Add Event Loop Utilization (ELU) statistics to worker tasks usage.
159 - Compute statistics at the worker level only if needed.
160 - Add `worker-threads` options to thread pool options.
164 - Make the `LEAST_BUSY` strategy only relies on task runtime.
166 ## [2.5.3] - 2023-06-04
170 - Refine pool information content.
171 - Limit pool internals public exposure.
173 ## [2.5.2] - 2023-06-02
177 - Add `taskError` pool event for task execution error.
178 - Add pool information `info` property to pool.
179 - Emit pool information on `busy` and `full` pool events.
181 ## [2.5.1] - 2023-06-01
185 - Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
186 - Add `error` pool event for uncaught worker error.
188 ## [2.5.0] - 2023-05-31
192 - Switch pool event emitter to `EventEmitterAsyncResource`.
193 - Add tasks wait time accounting in per worker tasks usage.
194 - Add interleaved weighted round robin `INTERLEAVED_WEIGHTED_ROUND_ROBIN` worker choice strategy (experimental).
198 - Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
200 ## [2.4.14] - 2023-05-09
204 - Ensure no undefined task runtime can land in the tasks history.
205 - Fix median computation implementation once again.
209 - Unit tests for median and queue implementations.
211 ## [2.4.13] - 2023-05-08
215 - Fix worker choice strategy options validation.
216 - Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
218 ## [2.4.12] - 2023-05-06
222 - Support multiple task functions per worker.
223 - Add custom worker weights support to worker choice strategies options.
227 - Use O(1) queue implementation for tasks queueing.
231 - Fix median computation implementation.
232 - Fix fair share worker choice strategy internals update.
234 ## [2.4.11] - 2023-04-23
238 - Optimize free worker finding in worker choice strategies.
240 ## [2.4.10] - 2023-04-15
244 - Fix typescript type definition for worker function: ensure the input data is optional.
245 - Fix typescript type definition for pool execute(): ensure the input data is optional.
247 ## [2.4.9] - 2023-04-15
251 - Add tasks queue enablement runtime setter to pool.
252 - Add tasks queue options runtime setter to pool.
253 - Add worker choice strategy options runtime setter to pool.
257 - Remove the tasks queuing experimental status.
261 - Fix worker function type definition and validation.
262 - Fix worker choice strategy options handling.
264 ## [2.4.8] - 2023-04-12
268 - Fix message between main worker and worker type definition for tasks.
269 - Fix code documentation.
271 ## [2.4.7] - 2023-04-11
275 - Add worker tasks queue options to pool options.
279 - Fix missing documentation.
281 ## [2.4.6] - 2023-04-10
285 - Ensure one task at a time is executed per worker with tasks queueing enabled.
286 - Properly count worker executing tasks with tasks queueing enabled.
288 ## [2.4.5] - 2023-04-09
292 - Use monotonic high resolution timer for worker tasks runtime.
293 - Add worker tasks median runtime to statistics.
294 - Add worker tasks queue (experimental).
296 ## [2.4.4] - 2023-04-07
300 - Add `PoolEvents` enumeration and `PoolEvent` type.
304 - Destroy worker only on alive check.
306 ## [2.4.3] - 2023-04-07
310 - Fix typedoc generation with inheritance.
312 ## [2.4.2] - 2023-04-06
316 - Add `full` event to dynamic pool.
317 - Keep worker choice strategy in memory for conditional reuse.
321 - Fix possible negative worker key at worker removal in worker choice strategies.
323 ## [2.4.1] - 2023-04-05
327 - Optimize worker choice strategy for dynamic pool.
331 - Ensure dynamic pool does not alter worker choice strategy expected behavior.
333 ## [2.4.0] - 2023-04-04
337 - Add `LESS_BUSY` worker choice strategy.
341 - Optimize worker storage in pool.
342 - Optimize worker alive status check.
343 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
344 - Optimize `LESS_USED` worker choice strategy.
345 - Update benchmarks versus external threads pools.
346 - Optimize tasks usage statistics requirements for worker choice strategy.
350 - Ensure trimmable characters are checked at pool initialization.
351 - Fix message id integer overflow.
352 - Fix pool worker removal in worker choice strategy internals.
353 - Fix package publication with pnpm.
355 ## [2.4.0-3] - 2023-04-04
359 - Add `LESS_BUSY` worker choice strategy.
363 - Optimize worker storage in pool.
364 - Optimize worker alive status check.
365 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
366 - Optimize `LESS_USED` worker choice strategy.
367 - Update benchmarks versus external threads pools.
371 - Ensure trimmable characters are checked at pool initialization.
372 - Fix message id integer overflow.
373 - Fix pool worker removal in worker choice strategy internals.
374 - Fix package publication with pnpm.
376 ## [2.4.0-2] - 2023-04-03
380 - Add `LESS_BUSY` worker choice strategy.
384 - Optimize worker storage in pool.
385 - Optimize worker alive status check.
386 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
387 - Optimize `LESS_USED` worker choice strategy.
391 - Ensure trimmable characters are checked at pool initialization.
392 - Fix message id integer overflow.
393 - Fix pool worker removal in worker choice strategy internals.
394 - Fix package publication with pnpm.
396 ## [2.4.0-1] - 2023-04-03
400 - Add `LESS_BUSY` worker choice strategy.
404 - Optimize worker storage in pool.
405 - Optimize worker alive status check.
406 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
407 - Optimize `LESS_USED` worker choice strategy.
411 - Ensure trimmable characters are checked at pool initialization.
412 - Fix message id integer overflow.
413 - Fix pool worker removal in worker choice strategy internals.
415 ## [2.4.0-0] - 2023-04-03
419 - Add `LESS_BUSY` worker choice strategy.
423 - Optimize worker storage in pool.
424 - Optimize worker alive status check.
425 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
426 - Optimize `LESS_USED` worker choice strategy.
430 - Ensure trimmable characters are checked at pool initialization.
431 - Fix message id integer overflow.
432 - Fix pool worker removal in worker choice strategy internals.
434 ## [2.3.10] - 2023-03-18
438 - Fix `exports` syntax for ESM and CommonJS.
442 - Permit SemVer pre-release publication.
444 ## [2.3.10-2] - 2023-03-18
448 - Fix `exports` syntax for ESM and CommonJS.
450 ## [2.3.10-1] - 2023-03-18
454 - Permit SemVer pre-release publication.
456 ## [2.3.10-0] - 2023-03-18
460 - Fix `exports` syntax for ESM and CommonJS.
462 ## [2.3.9] - 2023-03-18
466 - Introduce ESM module support along with CommonJS one.
470 - Fix brown paper bag bug referencing the same object literal.
472 ## [2.3.8] - 2023-03-18
476 - Switch internal benchmarking code to benny.
477 - Switch to TypeScript 5.x.x.
478 - Switch rollup bundler plugins to core ones.
479 - Switch to TSDoc syntax.
480 - Enforce conventional commits.
484 - Fix random integer generator.
485 - Fix worker choice strategy pool type identification at initialization.
487 ## [2.3.7] - 2022-10-23
491 - Switch to open collective FOSS project funding platform.
492 - Switch to ts-standard linter configuration on TypeScript code.
496 - Fixed missing async on pool execute method.
497 - Fixed typing in TypeScript example.
498 - Fixed types in unit tests.
500 ## [2.3.6] - 2022-10-22
504 - Cleanup pool attributes and methods.
505 - Refine error types thrown.
509 - Fix continuous integration build on windows.
510 - Fix code coverage reporting by using c8 instead of nyc.
512 ## [2.3.5] - 2022-10-21
516 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
517 - Optimize tasks usage lookup implementation.
521 - Fix missed pool event emitter type export.
522 - Fix typedoc documentation generation.
524 ## [2.3.4] - 2022-10-17
528 - Fully automate release process with release-it.
532 - Optimize fair share task scheduling algorithm implementation.
533 - Update benchmarks versus external pools results with latest version.
535 ## [2.3.3] - 2022-10-15
539 - Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
541 ## [2.3.2] - 2022-10-14
545 - Optimize fair share worker selection strategy implementation.
549 - Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
551 ## [2.3.1] - 2022-10-13
555 - Pool worker choice strategies:
556 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
557 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
559 ## [2.2.2] - 2022-10-09
563 - Fixed `README.md` file.
565 ## [2.2.1] - 2022-10-08
569 - Dynamic worker choice strategy change at runtime.
571 ## [2.2.0] - 2022-01-05
575 - Support only NodeJS version 16.x.x for cluster pool: upstream cluster API have changed on that version.
577 ## [2.1.0] - 2021-08-29
581 - Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
585 - `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
586 - `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
587 - `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
588 - `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
590 ## [2.0.2] - 2021-05-12
594 - Fix `busy` event emission on fixed pool type
596 ## [2.0.1] - 2021-03-16
600 - Check if pool options are properly set.
601 - `busy` event is emitted on all pool types.
603 ## [2.0.0] - 2021-03-01
607 - Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
611 - `FullPool` event is now renamed to `busy`.
612 - `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
613 _Find more details on our JSDoc._
615 - `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
617 - We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
619 ### Pool options types declaration merge
621 `FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
623 #### New `export` strategy
627 const DynamicThreadPool = require('poolifier/lib/dynamic')
629 const { DynamicThreadPool } = require('poolifier/lib/dynamic')
632 But you should always prefer just using
635 const { DynamicThreadPool } = require('poolifier')
638 #### New type definitions for input data and response
640 For cluster worker and worker-thread pools, you can now only send and receive structured-cloneable data.
641 _This is not a limitation by poolifier but NodeJS._
643 #### Public property replacements
645 `numWorkers` property is now `numberOfWorkers`
647 #### Internal (protected) properties and methods renaming
649 These properties are not intended for end users
651 - `id` => `nextMessageId`
653 These methods are not intended for end users
655 - `_chooseWorker` => `chooseWorker`
656 - `_newWorker` => `createWorker`
657 - `_execute` => `internalExecute`
658 - `_chooseWorker` => `chooseWorker`
659 - `_checkAlive` => `checkAlive`
661 - `_runAsync` => `runAsync`
663 ## [1.1.0] - 2020-05-21
667 - ThreadWorker support async functions as option
668 - Various external library patches
670 ## [1.0.0] - 2020-01-24
674 - FixedThreadPool implementation
675 - DynamicThreadPool implementation
676 - WorkerThread implementation to improve developer experience