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).
10 ## [2.6.12] - 2023-07-09
14 - Workaround import issue with `node:os` module in node 16.x.x.
16 ## [2.6.11] - 2023-07-09
20 - Fix pool readiness semantic.
22 ## [2.6.10] - 2023-07-08
26 - Ensure workers are not recreated on error at pool startup.
30 - Add `ready` and `strategy` fields to pool information.
31 - Add pool event `ready` to notify when the number of workers created in the pool has reached the maximum size expected and are ready.
32 - Add dynamic pool sizing checks.
34 ## [2.6.9] - 2023-07-07
38 - Recreate the right worker type on uncaught exception.
42 - Add minimum and maximum to internal measurement statistics.
43 - Add `runTime` and `waitTime` to pool information.
44 - Check worker inactive time only on dynamic worker.
46 ## [2.6.8] - 2023-07-03
50 - Brown paper bag release to fix version handling in pool information.
52 ## [2.6.7] - 2023-07-03
56 - Ensure worker queued tasks at error are reassigned to other pool workers.
60 - Add pool `utilization` ratio to pool information.
61 - Add `version` to pool information.
62 - Add worker information to worker nodes.
64 ## [2.6.6] - 2023-07-01
68 - Add safe helper `availableParallelism` to help sizing the pool.
72 - Ensure message handler is only registered in worker.
74 ## [2.6.5] - 2023-06-27
78 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
82 - Artificial version bump to 2.6.5 to workaround publication issue.
83 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
84 - Ensure pool event is emitted before task error promise rejection.
85 - Fix queued tasks count computation.
89 - Remove unneeded worker-threads worker `MessageChannel` internal usage for IPC.
91 ## [2.6.4] - 2023-06-27
95 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
99 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
100 - Ensure pool event is emitted before task error promise rejection.
101 - Fix queued tasks count computation.
105 - Remove unneeded worker-threads worker `MessageChannel` internal usage for IPC.
107 ## [2.6.3] - 2023-06-19
111 - Ensure no tasks are queued when trying to soft kill a dynamic worker.
112 - Update strategies internals after statistics computation.
116 - Optimize O(1) queue implementation.
118 ## [2.6.2] - 2023-06-12
122 - Fix new worker use after creation in dynamic pool given the current worker choice strategy.
124 ## [2.6.1] - 2023-06-10
128 - Add worker choice strategy documentation: [README.md](./src/pools/selection-strategies/README.md).
132 - Fix average statistics computation: ensure failed tasks are not accounted.
134 ## [2.6.0] - 2023-06-09
138 - Add `LEAST_ELU` worker choice strategy (experimental).
139 - Add tasks ELU instead of runtime support to `FAIR_SHARE` worker choice strategy.
143 - Refactor pool worker node usage internals.
144 - Breaking change: refactor worker choice strategy statistics requirements: the syntax of the worker choice strategy options has changed.
145 - Breaking change: pool information `info` property object fields have been renamed.
149 - Fix wait time accounting.
150 - Ensure worker choice strategy `LEAST_BUSY` accounts also tasks wait time.
151 - Ensure worker choice strategy `LEAST_USED` accounts also queued tasks.
153 ## [2.5.4] - 2023-06-07
157 - Add Event Loop Utilization (ELU) statistics to worker tasks usage.
161 - Compute statistics at the worker level only if needed.
162 - Add `worker-threads` options to thread pool options.
166 - Make the `LEAST_BUSY` strategy only relies on task runtime.
168 ## [2.5.3] - 2023-06-04
172 - Refine pool information content.
173 - Limit pool internals public exposure.
175 ## [2.5.2] - 2023-06-02
179 - Add `taskError` pool event for task execution error.
180 - Add pool information `info` property to pool.
181 - Emit pool information on `busy` and `full` pool events.
183 ## [2.5.1] - 2023-06-01
187 - Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
188 - Add `error` pool event for uncaught worker error.
190 ## [2.5.0] - 2023-05-31
194 - Switch pool event emitter to `EventEmitterAsyncResource`.
195 - Add tasks wait time accounting in per worker tasks usage.
196 - Add interleaved weighted round robin `INTERLEAVED_WEIGHTED_ROUND_ROBIN` worker choice strategy (experimental).
200 - Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
202 ## [2.4.14] - 2023-05-09
206 - Ensure no undefined task runtime can land in the tasks history.
207 - Fix median computation implementation once again.
211 - Unit tests for median and queue implementations.
213 ## [2.4.13] - 2023-05-08
217 - Fix worker choice strategy options validation.
218 - Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
220 ## [2.4.12] - 2023-05-06
224 - Support multiple task functions per worker.
225 - Add custom worker weights support to worker choice strategies options.
229 - Use O(1) queue implementation for tasks queueing.
233 - Fix median computation implementation.
234 - Fix fair share worker choice strategy internals update.
236 ## [2.4.11] - 2023-04-23
240 - Optimize free worker finding in worker choice strategies.
242 ## [2.4.10] - 2023-04-15
246 - Fix typescript type definition for worker function: ensure the input data is optional.
247 - Fix typescript type definition for pool execute(): ensure the input data is optional.
249 ## [2.4.9] - 2023-04-15
253 - Add tasks queue enablement runtime setter to pool.
254 - Add tasks queue options runtime setter to pool.
255 - Add worker choice strategy options runtime setter to pool.
259 - Remove the tasks queuing experimental status.
263 - Fix worker function type definition and validation.
264 - Fix worker choice strategy options handling.
266 ## [2.4.8] - 2023-04-12
270 - Fix message between main worker and worker type definition for tasks.
271 - Fix code documentation.
273 ## [2.4.7] - 2023-04-11
277 - Add worker tasks queue options to pool options.
281 - Fix missing documentation.
283 ## [2.4.6] - 2023-04-10
287 - Ensure one task at a time is executed per worker with tasks queueing enabled.
288 - Properly count worker executing tasks with tasks queueing enabled.
290 ## [2.4.5] - 2023-04-09
294 - Use monotonic high resolution timer for worker tasks runtime.
295 - Add worker tasks median runtime to statistics.
296 - Add worker tasks queue (experimental).
298 ## [2.4.4] - 2023-04-07
302 - Add `PoolEvents` enumeration and `PoolEvent` type.
306 - Destroy worker only on alive check.
308 ## [2.4.3] - 2023-04-07
312 - Fix typedoc generation with inheritance.
314 ## [2.4.2] - 2023-04-06
318 - Add `full` event to dynamic pool.
319 - Keep worker choice strategy in memory for conditional reuse.
323 - Fix possible negative worker key at worker removal in worker choice strategies.
325 ## [2.4.1] - 2023-04-05
329 - Optimize worker choice strategy for dynamic pool.
333 - Ensure dynamic pool does not alter worker choice strategy expected behavior.
335 ## [2.4.0] - 2023-04-04
339 - Add `LESS_BUSY` worker choice strategy.
343 - Optimize worker storage in pool.
344 - Optimize worker alive status check.
345 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
346 - Optimize `LESS_USED` worker choice strategy.
347 - Update benchmarks versus external threads pools.
348 - Optimize tasks usage statistics requirements for worker choice strategy.
352 - Ensure trimmable characters are checked at pool initialization.
353 - Fix message id integer overflow.
354 - Fix pool worker removal in worker choice strategy internals.
355 - Fix package publication with pnpm.
357 ## [2.4.0-3] - 2023-04-04
361 - Add `LESS_BUSY` worker choice strategy.
365 - Optimize worker storage in pool.
366 - Optimize worker alive status check.
367 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
368 - Optimize `LESS_USED` worker choice strategy.
369 - Update benchmarks versus external threads pools.
373 - Ensure trimmable characters are checked at pool initialization.
374 - Fix message id integer overflow.
375 - Fix pool worker removal in worker choice strategy internals.
376 - Fix package publication with pnpm.
378 ## [2.4.0-2] - 2023-04-03
382 - Add `LESS_BUSY` worker choice strategy.
386 - Optimize worker storage in pool.
387 - Optimize worker alive status check.
388 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
389 - Optimize `LESS_USED` worker choice strategy.
393 - Ensure trimmable characters are checked at pool initialization.
394 - Fix message id integer overflow.
395 - Fix pool worker removal in worker choice strategy internals.
396 - Fix package publication with pnpm.
398 ## [2.4.0-1] - 2023-04-03
402 - Add `LESS_BUSY` worker choice strategy.
406 - Optimize worker storage in pool.
407 - Optimize worker alive status check.
408 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
409 - Optimize `LESS_USED` worker choice strategy.
413 - Ensure trimmable characters are checked at pool initialization.
414 - Fix message id integer overflow.
415 - Fix pool worker removal in worker choice strategy internals.
417 ## [2.4.0-0] - 2023-04-03
421 - Add `LESS_BUSY` worker choice strategy.
425 - Optimize worker storage in pool.
426 - Optimize worker alive status check.
427 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
428 - Optimize `LESS_USED` worker choice strategy.
432 - Ensure trimmable characters are checked at pool initialization.
433 - Fix message id integer overflow.
434 - Fix pool worker removal in worker choice strategy internals.
436 ## [2.3.10] - 2023-03-18
440 - Fix `exports` syntax for ESM and CommonJS.
444 - Permit SemVer pre-release publication.
446 ## [2.3.10-2] - 2023-03-18
450 - Fix `exports` syntax for ESM and CommonJS.
452 ## [2.3.10-1] - 2023-03-18
456 - Permit SemVer pre-release publication.
458 ## [2.3.10-0] - 2023-03-18
462 - Fix `exports` syntax for ESM and CommonJS.
464 ## [2.3.9] - 2023-03-18
468 - Introduce ESM module support along with CommonJS one.
472 - Fix brown paper bag bug referencing the same object literal.
474 ## [2.3.8] - 2023-03-18
478 - Switch internal benchmarking code to benny.
479 - Switch to TypeScript 5.x.x.
480 - Switch rollup bundler plugins to core ones.
481 - Switch to TSDoc syntax.
482 - Enforce conventional commits.
486 - Fix random integer generator.
487 - Fix worker choice strategy pool type identification at initialization.
489 ## [2.3.7] - 2022-10-23
493 - Switch to open collective FOSS project funding platform.
494 - Switch to ts-standard linter configuration on TypeScript code.
498 - Fixed missing async on pool execute method.
499 - Fixed typing in TypeScript example.
500 - Fixed types in unit tests.
502 ## [2.3.6] - 2022-10-22
506 - Cleanup pool attributes and methods.
507 - Refine error types thrown.
511 - Fix continuous integration build on windows.
512 - Fix code coverage reporting by using c8 instead of nyc.
514 ## [2.3.5] - 2022-10-21
518 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
519 - Optimize tasks usage lookup implementation.
523 - Fix missed pool event emitter type export.
524 - Fix typedoc documentation generation.
526 ## [2.3.4] - 2022-10-17
530 - Fully automate release process with release-it.
534 - Optimize fair share task scheduling algorithm implementation.
535 - Update benchmarks versus external pools results with latest version.
537 ## [2.3.3] - 2022-10-15
541 - Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
543 ## [2.3.2] - 2022-10-14
547 - Optimize fair share worker selection strategy implementation.
551 - Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
553 ## [2.3.1] - 2022-10-13
557 - Pool worker choice strategies:
558 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
559 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
561 ## [2.2.2] - 2022-10-09
565 - Fixed `README.md` file.
567 ## [2.2.1] - 2022-10-08
571 - Dynamic worker choice strategy change at runtime.
573 ## [2.2.0] - 2022-01-05
577 - Support only NodeJS version 16.x.x for cluster pool: upstream cluster API have changed on that version.
579 ## [2.1.0] - 2021-08-29
583 - Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
587 - `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
588 - `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
589 - `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
590 - `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
592 ## [2.0.2] - 2021-05-12
596 - Fix `busy` event emission on fixed pool type
598 ## [2.0.1] - 2021-03-16
602 - Check if pool options are properly set.
603 - `busy` event is emitted on all pool types.
605 ## [2.0.0] - 2021-03-01
609 - Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
613 - `FullPool` event is now renamed to `busy`.
614 - `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
615 _Find more details on our JSDoc._
617 - `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
619 - We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
621 ### Pool options types declaration merge
623 `FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
625 #### New `export` strategy
629 const DynamicThreadPool = require('poolifier/lib/dynamic')
631 const { DynamicThreadPool } = require('poolifier/lib/dynamic')
634 But you should always prefer just using
637 const { DynamicThreadPool } = require('poolifier')
640 #### New type definitions for input data and response
642 For cluster worker and worker-thread pools, you can now only send and receive structured-cloneable data.
643 _This is not a limitation by poolifier but NodeJS._
645 #### Public property replacements
647 `numWorkers` property is now `numberOfWorkers`
649 #### Internal (protected) properties and methods renaming
651 These properties are not intended for end users
653 - `id` => `nextMessageId`
655 These methods are not intended for end users
657 - `_chooseWorker` => `chooseWorker`
658 - `_newWorker` => `createWorker`
659 - `_execute` => `internalExecute`
660 - `_chooseWorker` => `chooseWorker`
661 - `_checkAlive` => `checkAlive`
663 - `_runAsync` => `runAsync`
665 ## [1.1.0] - 2020-05-21
669 - ThreadWorker support async functions as option
670 - Various external library patches
672 ## [1.0.0] - 2020-01-24
676 - FixedThreadPool implementation
677 - DynamicThreadPool implementation
678 - WorkerThread implementation to improve developer experience