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 - Ensure workers are not recreated on error at pool startup.
16 - Add `ready` and `strategy` fields to pool information.
17 - Add pool event `ready` to notify when the number of workers created in the pool has reached the maximum size expected and are ready.
18 - Add dynamic pool sizes checks.
20 ## [2.6.9] - 2023-07-07
24 - Recreate the right worker type on uncaught exception.
28 - Add minimum and maximum to internal measurement statistics.
29 - Add `runTime` and `waitTime` to pool information.
30 - Check worker inactive time only on dynamic worker.
32 ## [2.6.8] - 2023-07-03
36 - Brown paper bag release to fix version handling in pool information.
38 ## [2.6.7] - 2023-07-03
42 - Ensure worker queued tasks at error are reassigned to other pool workers.
46 - Add pool `utilization` ratio to pool information.
47 - Add `version` to pool information.
48 - Add worker information to worker nodes.
50 ## [2.6.6] - 2023-07-01
54 - Add safe helper `availableParallelism` to help sizing the pool.
58 - Ensure message handler is only registered in worker.
60 ## [2.6.5] - 2023-06-27
64 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
68 - Artificial version bump to 2.6.5 to workaround publication issue.
69 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
70 - Ensure pool event is emitted before task error promise rejection.
71 - Fix queued tasks count computation.
75 - Remove unneeded worker-threads worker `MessageChannel` internal usage for IPC.
77 ## [2.6.4] - 2023-06-27
81 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
85 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
86 - Ensure pool event is emitted before task error promise rejection.
87 - Fix queued tasks count computation.
91 - Remove unneeded worker-threads worker `MessageChannel` internal usage for IPC.
93 ## [2.6.3] - 2023-06-19
97 - Ensure no tasks are queued when trying to soft kill a dynamic worker.
98 - Update strategies internals after statistics computation.
102 - Optimize O(1) queue implementation.
104 ## [2.6.2] - 2023-06-12
108 - Fix new worker use after creation in dynamic pool given the current worker choice strategy.
110 ## [2.6.1] - 2023-06-10
114 - Add worker choice strategy documentation: [README.md](./src/pools/selection-strategies/README.md).
118 - Fix average statistics computation: ensure failed tasks are not accounted.
120 ## [2.6.0] - 2023-06-09
124 - Add `LEAST_ELU` worker choice strategy (experimental).
125 - Add tasks ELU instead of runtime support to `FAIR_SHARE` worker choice strategy.
129 - Refactor pool worker node usage internals.
130 - Breaking change: refactor worker choice strategy statistics requirements: the syntax of the worker choice strategy options has changed.
131 - Breaking change: pool information `info` property object fields have been renamed.
135 - Fix wait time accounting.
136 - Ensure worker choice strategy `LEAST_BUSY` accounts also tasks wait time.
137 - Ensure worker choice strategy `LEAST_USED` accounts also queued tasks.
139 ## [2.5.4] - 2023-06-07
143 - Add Event Loop Utilization (ELU) statistics to worker tasks usage.
147 - Compute statistics at the worker level only if needed.
148 - Add `worker-threads` options to thread pool options.
152 - Make the `LEAST_BUSY` strategy only relies on task runtime.
154 ## [2.5.3] - 2023-06-04
158 - Refine pool information content.
159 - Limit pool internals public exposure.
161 ## [2.5.2] - 2023-06-02
165 - Add `taskError` pool event for task execution error.
166 - Add pool information `info` property to pool.
167 - Emit pool information on `busy` and `full` pool events.
169 ## [2.5.1] - 2023-06-01
173 - Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
174 - Add `error` pool event for uncaught worker error.
176 ## [2.5.0] - 2023-05-31
180 - Switch pool event emitter to `EventEmitterAsyncResource`.
181 - Add tasks wait time accounting in per worker tasks usage.
182 - Add interleaved weighted round robin `INTERLEAVED_WEIGHTED_ROUND_ROBIN` worker choice strategy (experimental).
186 - Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
188 ## [2.4.14] - 2023-05-09
192 - Ensure no undefined task runtime can land in the tasks history.
193 - Fix median computation implementation once again.
197 - Unit tests for median and queue implementations.
199 ## [2.4.13] - 2023-05-08
203 - Fix worker choice strategy options validation.
204 - Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
206 ## [2.4.12] - 2023-05-06
210 - Support multiple task functions per worker.
211 - Add custom worker weights support to worker choice strategies options.
215 - Use O(1) queue implementation for tasks queueing.
219 - Fix median computation implementation.
220 - Fix fair share worker choice strategy internals update.
222 ## [2.4.11] - 2023-04-23
226 - Optimize free worker finding in worker choice strategies.
228 ## [2.4.10] - 2023-04-15
232 - Fix typescript type definition for worker function: ensure the input data is optional.
233 - Fix typescript type definition for pool execute(): ensure the input data is optional.
235 ## [2.4.9] - 2023-04-15
239 - Add tasks queue enablement runtime setter to pool.
240 - Add tasks queue options runtime setter to pool.
241 - Add worker choice strategy options runtime setter to pool.
245 - Remove the tasks queuing experimental status.
249 - Fix worker function type definition and validation.
250 - Fix worker choice strategy options handling.
252 ## [2.4.8] - 2023-04-12
256 - Fix message between main worker and worker type definition for tasks.
257 - Fix code documentation.
259 ## [2.4.7] - 2023-04-11
263 - Add worker tasks queue options to pool options.
267 - Fix missing documentation.
269 ## [2.4.6] - 2023-04-10
273 - Ensure one task at a time is executed per worker with tasks queueing enabled.
274 - Properly count worker executing tasks with tasks queueing enabled.
276 ## [2.4.5] - 2023-04-09
280 - Use monotonic high resolution timer for worker tasks runtime.
281 - Add worker tasks median runtime to statistics.
282 - Add worker tasks queue (experimental).
284 ## [2.4.4] - 2023-04-07
288 - Add `PoolEvents` enumeration and `PoolEvent` type.
292 - Destroy worker only on alive check.
294 ## [2.4.3] - 2023-04-07
298 - Fix typedoc generation with inheritance.
300 ## [2.4.2] - 2023-04-06
304 - Add `full` event to dynamic pool.
305 - Keep worker choice strategy in memory for conditional reuse.
309 - Fix possible negative worker key at worker removal in worker choice strategies.
311 ## [2.4.1] - 2023-04-05
315 - Optimize worker choice strategy for dynamic pool.
319 - Ensure dynamic pool does not alter worker choice strategy expected behavior.
321 ## [2.4.0] - 2023-04-04
325 - Add `LESS_BUSY` worker choice strategy.
329 - Optimize worker storage in pool.
330 - Optimize worker alive status check.
331 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
332 - Optimize `LESS_USED` worker choice strategy.
333 - Update benchmarks versus external threads pools.
334 - Optimize tasks usage statistics requirements for worker choice strategy.
338 - Ensure trimmable characters are checked at pool initialization.
339 - Fix message id integer overflow.
340 - Fix pool worker removal in worker choice strategy internals.
341 - Fix package publication with pnpm.
343 ## [2.4.0-3] - 2023-04-04
347 - Add `LESS_BUSY` worker choice strategy.
351 - Optimize worker storage in pool.
352 - Optimize worker alive status check.
353 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
354 - Optimize `LESS_USED` worker choice strategy.
355 - Update benchmarks versus external threads pools.
359 - Ensure trimmable characters are checked at pool initialization.
360 - Fix message id integer overflow.
361 - Fix pool worker removal in worker choice strategy internals.
362 - Fix package publication with pnpm.
364 ## [2.4.0-2] - 2023-04-03
368 - Add `LESS_BUSY` worker choice strategy.
372 - Optimize worker storage in pool.
373 - Optimize worker alive status check.
374 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
375 - Optimize `LESS_USED` worker choice strategy.
379 - Ensure trimmable characters are checked at pool initialization.
380 - Fix message id integer overflow.
381 - Fix pool worker removal in worker choice strategy internals.
382 - Fix package publication with pnpm.
384 ## [2.4.0-1] - 2023-04-03
388 - Add `LESS_BUSY` worker choice strategy.
392 - Optimize worker storage in pool.
393 - Optimize worker alive status check.
394 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
395 - Optimize `LESS_USED` worker choice strategy.
399 - Ensure trimmable characters are checked at pool initialization.
400 - Fix message id integer overflow.
401 - Fix pool worker removal in worker choice strategy internals.
403 ## [2.4.0-0] - 2023-04-03
407 - Add `LESS_BUSY` worker choice strategy.
411 - Optimize worker storage in pool.
412 - Optimize worker alive status check.
413 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
414 - Optimize `LESS_USED` worker choice strategy.
418 - Ensure trimmable characters are checked at pool initialization.
419 - Fix message id integer overflow.
420 - Fix pool worker removal in worker choice strategy internals.
422 ## [2.3.10] - 2023-03-18
426 - Fix `exports` syntax for ESM and CommonJS.
430 - Permit SemVer pre-release publication.
432 ## [2.3.10-2] - 2023-03-18
436 - Fix `exports` syntax for ESM and CommonJS.
438 ## [2.3.10-1] - 2023-03-18
442 - Permit SemVer pre-release publication.
444 ## [2.3.10-0] - 2023-03-18
448 - Fix `exports` syntax for ESM and CommonJS.
450 ## [2.3.9] - 2023-03-18
454 - Introduce ESM module support along with CommonJS one.
458 - Fix brown paper bag bug referencing the same object literal.
460 ## [2.3.8] - 2023-03-18
464 - Switch internal benchmarking code to benny.
465 - Switch to TypeScript 5.x.x.
466 - Switch rollup bundler plugins to core ones.
467 - Switch to TSDoc syntax.
468 - Enforce conventional commits.
472 - Fix random integer generator.
473 - Fix worker choice strategy pool type identification at initialization.
475 ## [2.3.7] - 2022-10-23
479 - Switch to open collective FOSS project funding platform.
480 - Switch to ts-standard linter configuration on TypeScript code.
484 - Fixed missing async on pool execute method.
485 - Fixed typing in TypeScript example.
486 - Fixed types in unit tests.
488 ## [2.3.6] - 2022-10-22
492 - Cleanup pool attributes and methods.
493 - Refine error types thrown.
497 - Fix continuous integration build on windows.
498 - Fix code coverage reporting by using c8 instead of nyc.
500 ## [2.3.5] - 2022-10-21
504 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
505 - Optimize tasks usage lookup implementation.
509 - Fix missed pool event emitter type export.
510 - Fix typedoc documentation generation.
512 ## [2.3.4] - 2022-10-17
516 - Fully automate release process with release-it.
520 - Optimize fair share task scheduling algorithm implementation.
521 - Update benchmarks versus external pools results with latest version.
523 ## [2.3.3] - 2022-10-15
527 - Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
529 ## [2.3.2] - 2022-10-14
533 - Optimize fair share worker selection strategy implementation.
537 - Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
539 ## [2.3.1] - 2022-10-13
543 - Pool worker choice strategies:
544 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
545 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
547 ## [2.2.2] - 2022-10-09
551 - Fixed `README.md` file.
553 ## [2.2.1] - 2022-10-08
557 - Dynamic worker choice strategy change at runtime.
559 ## [2.2.0] - 2022-01-05
563 - Support only NodeJS version 16.x.x for cluster pool: upstream cluster API have changed on that version.
565 ## [2.1.0] - 2021-08-29
569 - Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
573 - `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
574 - `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
575 - `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
576 - `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
578 ## [2.0.2] - 2021-05-12
582 - Fix `busy` event emission on fixed pool type
584 ## [2.0.1] - 2021-03-16
588 - Check if pool options are properly set.
589 - `busy` event is emitted on all pool types.
591 ## [2.0.0] - 2021-03-01
595 - Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
599 - `FullPool` event is now renamed to `busy`.
600 - `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
601 _Find more details on our JSDoc._
603 - `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
605 - We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
607 ### Pool options types declaration merge
609 `FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
611 #### New `export` strategy
615 const DynamicThreadPool = require('poolifier/lib/dynamic')
617 const { DynamicThreadPool } = require('poolifier/lib/dynamic')
620 But you should always prefer just using
623 const { DynamicThreadPool } = require('poolifier')
626 #### New type definitions for input data and response
628 For cluster worker and worker-thread pools, you can now only send and receive structured-cloneable data.
629 _This is not a limitation by poolifier but NodeJS._
631 #### Public property replacements
633 `numWorkers` property is now `numberOfWorkers`
635 #### Internal (protected) properties and methods renaming
637 These properties are not intended for end users
639 - `id` => `nextMessageId`
641 These methods are not intended for end users
643 - `_chooseWorker` => `chooseWorker`
644 - `_newWorker` => `createWorker`
645 - `_execute` => `internalExecute`
646 - `_chooseWorker` => `chooseWorker`
647 - `_checkAlive` => `checkAlive`
649 - `_runAsync` => `runAsync`
651 ## [1.1.0] - 2020-05-21
655 - ThreadWorker support async functions as option
656 - Various external library patches
658 ## [1.0.0] - 2020-01-24
662 - FixedThreadPool implementation
663 - DynamicThreadPool implementation
664 - WorkerThread implementation to improve developer experience