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 - Code refactoring and cleanup for better maintainability and readability. Bundle size is a bit smaller.
14 ## [2.6.17] - 2023-07-16
18 - Add `listTaskFunctions()` method to worker class.
20 ## [2.6.16] - 2023-07-12
24 - Fix pool startup detection.
25 - Fix worker task functions handling.
27 ## [2.6.15] - 2023-07-11
31 - Take into account worker node readiness in worker choice strategies.
33 ## [2.6.14] - 2023-07-10
37 - Fix task function statistics tracking.
39 ## [2.6.13] - 2023-07-10
43 - Add per task function statistics tracking.
44 - Add public methods to manipulate the worker task functions at runtime.
46 ## [2.6.12] - 2023-07-09
50 - Workaround import issue with `node:os` module in node 16.x.x.
52 ## [2.6.11] - 2023-07-09
56 - Fix pool readiness semantic.
58 ## [2.6.10] - 2023-07-08
62 - Ensure workers are not recreated on error at pool startup.
66 - Add `ready` and `strategy` fields to pool information.
67 - Add pool event `ready` to notify when the number of workers created in the pool has reached the maximum size expected and are ready.
68 - Add dynamic pool sizing checks.
70 ## [2.6.9] - 2023-07-07
74 - Recreate the right worker type on uncaught exception.
78 - Add minimum and maximum to internal measurement statistics.
79 - Add `runTime` and `waitTime` to pool information.
80 - Check worker inactive time only on dynamic worker.
82 ## [2.6.8] - 2023-07-03
86 - Brown paper bag release to fix version handling in pool information.
88 ## [2.6.7] - 2023-07-03
92 - Ensure worker queued tasks at error are reassigned to other pool workers.
96 - Add pool `utilization` ratio to pool information.
97 - Add `version` to pool information.
98 - Add worker information to worker nodes.
100 ## [2.6.6] - 2023-07-01
104 - Add safe helper `availableParallelism` to help sizing the pool.
108 - Ensure message handler is only registered in worker.
110 ## [2.6.5] - 2023-06-27
114 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
118 - Artificial version bump to 2.6.5 to workaround publication issue.
119 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
120 - Ensure pool event is emitted before task error promise rejection.
121 - Fix queued tasks count computation.
125 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
127 ## [2.6.4] - 2023-06-27
131 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
135 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
136 - Ensure pool event is emitted before task error promise rejection.
137 - Fix queued tasks count computation.
141 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
143 ## [2.6.3] - 2023-06-19
147 - Ensure no tasks are queued when trying to soft kill a dynamic worker.
148 - Update strategies internals after statistics computation.
152 - Optimize O(1) queue implementation.
154 ## [2.6.2] - 2023-06-12
158 - Fix new worker use after creation in dynamic pool given the current worker choice strategy.
160 ## [2.6.1] - 2023-06-10
164 - Add worker choice strategy documentation: [README.md](./src/pools/selection-strategies/README.md).
168 - Fix average statistics computation: ensure failed tasks are not accounted.
170 ## [2.6.0] - 2023-06-09
174 - Add `LEAST_ELU` worker choice strategy (experimental).
175 - Add tasks ELU instead of runtime support to `FAIR_SHARE` worker choice strategy.
179 - Refactor pool worker node usage internals.
180 - Breaking change: refactor worker choice strategy statistics requirements: the syntax of the worker choice strategy options has changed.
181 - Breaking change: pool information `info` property object fields have been renamed.
185 - Fix wait time accounting.
186 - Ensure worker choice strategy `LEAST_BUSY` accounts also tasks wait time.
187 - Ensure worker choice strategy `LEAST_USED` accounts also queued tasks.
189 ## [2.5.4] - 2023-06-07
193 - Add Event Loop Utilization (ELU) statistics to worker tasks usage.
197 - Compute statistics at the worker level only if needed.
198 - Add `worker_threads` options to thread pool options.
202 - Make the `LEAST_BUSY` strategy only relies on task runtime.
204 ## [2.5.3] - 2023-06-04
208 - Refine pool information content.
209 - Limit pool internals public exposure.
211 ## [2.5.2] - 2023-06-02
215 - Add `taskError` pool event for task execution error.
216 - Add pool information `info` property to pool.
217 - Emit pool information on `busy` and `full` pool events.
219 ## [2.5.1] - 2023-06-01
223 - Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
224 - Add `error` pool event for uncaught worker error.
226 ## [2.5.0] - 2023-05-31
230 - Switch pool event emitter to `EventEmitterAsyncResource`.
231 - Add tasks wait time accounting in per worker tasks usage.
232 - Add interleaved weighted round robin `INTERLEAVED_WEIGHTED_ROUND_ROBIN` worker choice strategy (experimental).
236 - Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
238 ## [2.4.14] - 2023-05-09
242 - Ensure no undefined task runtime can land in the tasks history.
243 - Fix median computation implementation once again.
247 - Unit tests for median and queue implementations.
249 ## [2.4.13] - 2023-05-08
253 - Fix worker choice strategy options validation.
254 - Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
256 ## [2.4.12] - 2023-05-06
260 - Support multiple task functions per worker.
261 - Add custom worker weights support to worker choice strategies options.
265 - Use O(1) queue implementation for tasks queueing.
269 - Fix median computation implementation.
270 - Fix fair share worker choice strategy internals update.
272 ## [2.4.11] - 2023-04-23
276 - Optimize free worker finding in worker choice strategies.
278 ## [2.4.10] - 2023-04-15
282 - Fix typescript type definition for worker function: ensure the input data is optional.
283 - Fix typescript type definition for pool execute(): ensure the input data is optional.
285 ## [2.4.9] - 2023-04-15
289 - Add tasks queue enablement runtime setter to pool.
290 - Add tasks queue options runtime setter to pool.
291 - Add worker choice strategy options runtime setter to pool.
295 - Remove the tasks queuing experimental status.
299 - Fix worker function type definition and validation.
300 - Fix worker choice strategy options handling.
302 ## [2.4.8] - 2023-04-12
306 - Fix message between main worker and worker type definition for tasks.
307 - Fix code documentation.
309 ## [2.4.7] - 2023-04-11
313 - Add worker tasks queue options to pool options.
317 - Fix missing documentation.
319 ## [2.4.6] - 2023-04-10
323 - Ensure one task at a time is executed per worker with tasks queueing enabled.
324 - Properly count worker executing tasks with tasks queueing enabled.
326 ## [2.4.5] - 2023-04-09
330 - Use monotonic high resolution timer for worker tasks runtime.
331 - Add worker tasks median runtime to statistics.
332 - Add worker tasks queue (experimental).
334 ## [2.4.4] - 2023-04-07
338 - Add `PoolEvents` enumeration and `PoolEvent` type.
342 - Destroy worker only on alive check.
344 ## [2.4.3] - 2023-04-07
348 - Fix typedoc generation with inheritance.
350 ## [2.4.2] - 2023-04-06
354 - Add `full` event to dynamic pool.
355 - Keep worker choice strategy in memory for conditional reuse.
359 - Fix possible negative worker key at worker removal in worker choice strategies.
361 ## [2.4.1] - 2023-04-05
365 - Optimize worker choice strategy for dynamic pool.
369 - Ensure dynamic pool does not alter worker choice strategy expected behavior.
371 ## [2.4.0] - 2023-04-04
375 - Add `LESS_BUSY` worker choice strategy.
379 - Optimize worker storage in pool.
380 - Optimize worker alive status check.
381 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
382 - Optimize `LESS_USED` worker choice strategy.
383 - Update benchmarks versus external threads pools.
384 - Optimize tasks usage statistics requirements for worker choice strategy.
388 - Ensure trimmable characters are checked at pool initialization.
389 - Fix message id integer overflow.
390 - Fix pool worker removal in worker choice strategy internals.
391 - Fix package publication with pnpm.
393 ## [2.4.0-3] - 2023-04-04
397 - Add `LESS_BUSY` worker choice strategy.
401 - Optimize worker storage in pool.
402 - Optimize worker alive status check.
403 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
404 - Optimize `LESS_USED` worker choice strategy.
405 - Update benchmarks versus external threads pools.
409 - Ensure trimmable characters are checked at pool initialization.
410 - Fix message id integer overflow.
411 - Fix pool worker removal in worker choice strategy internals.
412 - Fix package publication with pnpm.
414 ## [2.4.0-2] - 2023-04-03
418 - Add `LESS_BUSY` worker choice strategy.
422 - Optimize worker storage in pool.
423 - Optimize worker alive status check.
424 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
425 - Optimize `LESS_USED` worker choice strategy.
429 - Ensure trimmable characters are checked at pool initialization.
430 - Fix message id integer overflow.
431 - Fix pool worker removal in worker choice strategy internals.
432 - Fix package publication with pnpm.
434 ## [2.4.0-1] - 2023-04-03
438 - Add `LESS_BUSY` worker choice strategy.
442 - Optimize worker storage in pool.
443 - Optimize worker alive status check.
444 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
445 - Optimize `LESS_USED` worker choice strategy.
449 - Ensure trimmable characters are checked at pool initialization.
450 - Fix message id integer overflow.
451 - Fix pool worker removal in worker choice strategy internals.
453 ## [2.4.0-0] - 2023-04-03
457 - Add `LESS_BUSY` worker choice strategy.
461 - Optimize worker storage in pool.
462 - Optimize worker alive status check.
463 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
464 - Optimize `LESS_USED` worker choice strategy.
468 - Ensure trimmable characters are checked at pool initialization.
469 - Fix message id integer overflow.
470 - Fix pool worker removal in worker choice strategy internals.
472 ## [2.3.10] - 2023-03-18
476 - Fix `exports` syntax for ESM and CommonJS.
480 - Permit SemVer pre-release publication.
482 ## [2.3.10-2] - 2023-03-18
486 - Fix `exports` syntax for ESM and CommonJS.
488 ## [2.3.10-1] - 2023-03-18
492 - Permit SemVer pre-release publication.
494 ## [2.3.10-0] - 2023-03-18
498 - Fix `exports` syntax for ESM and CommonJS.
500 ## [2.3.9] - 2023-03-18
504 - Introduce ESM module support along with CommonJS one.
508 - Fix brown paper bag bug referencing the same object literal.
510 ## [2.3.8] - 2023-03-18
514 - Switch internal benchmarking code to benny.
515 - Switch to TypeScript 5.x.x.
516 - Switch rollup bundler plugins to core ones.
517 - Switch to TSDoc syntax.
518 - Enforce conventional commits.
522 - Fix random integer generator.
523 - Fix worker choice strategy pool type identification at initialization.
525 ## [2.3.7] - 2022-10-23
529 - Switch to open collective FOSS project funding platform.
530 - Switch to ts-standard linter configuration on TypeScript code.
534 - Fixed missing async on pool execute method.
535 - Fixed typing in TypeScript example.
536 - Fixed types in unit tests.
538 ## [2.3.6] - 2022-10-22
542 - Cleanup pool attributes and methods.
543 - Refine error types thrown.
547 - Fix continuous integration build on windows.
548 - Fix code coverage reporting by using c8 instead of nyc.
550 ## [2.3.5] - 2022-10-21
554 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
555 - Optimize tasks usage lookup implementation.
559 - Fix missed pool event emitter type export.
560 - Fix typedoc documentation generation.
562 ## [2.3.4] - 2022-10-17
566 - Fully automate release process with release-it.
570 - Optimize fair share task scheduling algorithm implementation.
571 - Update benchmarks versus external pools results with latest version.
573 ## [2.3.3] - 2022-10-15
577 - Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
579 ## [2.3.2] - 2022-10-14
583 - Optimize fair share worker selection strategy implementation.
587 - Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
589 ## [2.3.1] - 2022-10-13
593 - Pool worker choice strategies:
594 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
595 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
597 ## [2.2.2] - 2022-10-09
601 - Fixed `README.md` file.
603 ## [2.2.1] - 2022-10-08
607 - Dynamic worker choice strategy change at runtime.
609 ## [2.2.0] - 2022-01-05
613 - Support only NodeJS version 16.x.x for cluster pool: upstream cluster API have changed on that version.
615 ## [2.1.0] - 2021-08-29
619 - Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
623 - `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
624 - `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
625 - `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
626 - `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
628 ## [2.0.2] - 2021-05-12
632 - Fix `busy` event emission on fixed pool type
634 ## [2.0.1] - 2021-03-16
638 - Check if pool options are properly set.
639 - `busy` event is emitted on all pool types.
641 ## [2.0.0] - 2021-03-01
645 - Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
649 - `FullPool` event is now renamed to `busy`.
650 - `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
651 _Find more details on our JSDoc._
653 - `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
655 - We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
657 ### Pool options types declaration merge
659 `FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
661 #### New `export` strategy
665 const DynamicThreadPool = require('poolifier/lib/dynamic')
667 const { DynamicThreadPool } = require('poolifier/lib/dynamic')
670 But you should always prefer just using
673 const { DynamicThreadPool } = require('poolifier')
676 #### New type definitions for input data and response
678 For cluster worker and worker-thread pools, you can now only send and receive structured-cloneable data.
679 _This is not a limitation by poolifier but NodeJS._
681 #### Public property replacements
683 `numWorkers` property is now `numberOfWorkers`
685 #### Internal (protected) properties and methods renaming
687 These properties are not intended for end users
689 - `id` => `nextMessageId`
691 These methods are not intended for end users
693 - `_chooseWorker` => `chooseWorker`
694 - `_newWorker` => `createWorker`
695 - `_execute` => `internalExecute`
696 - `_chooseWorker` => `chooseWorker`
697 - `_checkAlive` => `checkAlive`
699 - `_runAsync` => `runAsync`
701 ## [1.1.0] - 2020-05-21
705 - ThreadWorker support async functions as option
706 - Various external library patches
708 ## [1.0.0] - 2020-01-24
712 - FixedThreadPool implementation
713 - DynamicThreadPool implementation
714 - WorkerThread implementation to improve developer experience