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 - Brown paper bag release to fix version handling in pool information.
14 ## [2.6.7] - 2023-07-03
18 - Ensure worker queued tasks at error are reassigned to other pool workers.
22 - Add pool `utilization` ratio to pool information.
23 - Add `version` to pool information.
24 - Add worker information to worker nodes.
26 ## [2.6.6] - 2023-07-01
30 - Add safe helper `availableParallelism` to help sizing the pool.
34 - Ensure message handler is only registered in worker.
36 ## [2.6.5] - 2023-06-27
40 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
44 - Artificial version bump to 2.6.5 to workaround publication issue.
45 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
46 - Ensure pool event is emitted before task error promise rejection.
47 - Fix queued tasks count computation.
51 - Remove unneeded worker-threads worker `MessageChannel` internal usage for IPC.
53 ## [2.6.4] - 2023-06-27
57 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
61 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
62 - Ensure pool event is emitted before task error promise rejection.
63 - Fix queued tasks count computation.
67 - Remove unneeded worker-threads worker `MessageChannel` internal usage for IPC.
69 ## [2.6.3] - 2023-06-19
73 - Ensure no tasks are queued when trying to soft kill a dynamic worker.
74 - Update strategies internals after statistics computation.
78 - Optimize O(1) queue implementation.
80 ## [2.6.2] - 2023-06-12
84 - Fix new worker use after creation in dynamic pool given the current worker choice strategy.
86 ## [2.6.1] - 2023-06-10
90 - Add worker choice strategy documentation: [README.md](./src/pools/selection-strategies/README.md).
94 - Fix average statistics computation: ensure failed tasks are not accounted.
96 ## [2.6.0] - 2023-06-09
100 - Add `LEAST_ELU` worker choice strategy (experimental).
101 - Add tasks ELU instead of runtime support to `FAIR_SHARE` worker choice strategy.
105 - Refactor pool worker node usage internals.
106 - Breaking change: refactor worker choice strategy statistics requirements: the syntax of the worker choice strategy options has changed.
107 - Breaking change: pool information `info` property object fields have been renamed.
111 - Fix wait time accounting.
112 - Ensure worker choice strategy `LEAST_BUSY` accounts also tasks wait time.
113 - Ensure worker choice strategy `LEAST_USED` accounts also queued tasks.
115 ## [2.5.4] - 2023-06-07
119 - Add Event Loop Utilization (ELU) statistics to worker tasks usage.
123 - Compute statistics at the worker level only if needed.
124 - Add `worker-threads` options to thread pool options.
128 - Make the `LEAST_BUSY` strategy only relies on task runtime.
130 ## [2.5.3] - 2023-06-04
134 - Refine pool information content.
135 - Limit pool internals public exposure.
137 ## [2.5.2] - 2023-06-02
141 - Add `taskError` pool event for task execution error.
142 - Add pool information `info` property to pool.
143 - Emit pool information on `busy` and `full` pool events.
145 ## [2.5.1] - 2023-06-01
149 - Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
150 - Add `error` pool event for uncaught worker error.
152 ## [2.5.0] - 2023-05-31
156 - Switch pool event emitter to `EventEmitterAsyncResource`.
157 - Add tasks wait time accounting in per worker tasks usage.
158 - Add interleaved weighted round robin `INTERLEAVED_WEIGHTED_ROUND_ROBIN` worker choice strategy (experimental).
162 - Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
164 ## [2.4.14] - 2023-05-09
168 - Ensure no undefined task runtime can land in the tasks history.
169 - Fix median computation implementation once again.
173 - Unit tests for median and queue implementations.
175 ## [2.4.13] - 2023-05-08
179 - Fix worker choice strategy options validation.
180 - Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
182 ## [2.4.12] - 2023-05-06
186 - Support multiple task functions per worker.
187 - Add custom worker weights support to worker choice strategies options.
191 - Use O(1) queue implementation for tasks queueing.
195 - Fix median computation implementation.
196 - Fix fair share worker choice strategy internals update.
198 ## [2.4.11] - 2023-04-23
202 - Optimize free worker finding in worker choice strategies.
204 ## [2.4.10] - 2023-04-15
208 - Fix typescript type definition for worker function: ensure the input data is optional.
209 - Fix typescript type definition for pool execute(): ensure the input data is optional.
211 ## [2.4.9] - 2023-04-15
215 - Add tasks queue enablement runtime setter to pool.
216 - Add tasks queue options runtime setter to pool.
217 - Add worker choice strategy options runtime setter to pool.
221 - Remove the tasks queuing experimental status.
225 - Fix worker function type definition and validation.
226 - Fix worker choice strategy options handling.
228 ## [2.4.8] - 2023-04-12
232 - Fix message between main worker and worker type definition for tasks.
233 - Fix code documentation.
235 ## [2.4.7] - 2023-04-11
239 - Add worker tasks queue options to pool options.
243 - Fix missing documentation.
245 ## [2.4.6] - 2023-04-10
249 - Ensure one task at a time is executed per worker with tasks queueing enabled.
250 - Properly count worker executing tasks with tasks queueing enabled.
252 ## [2.4.5] - 2023-04-09
256 - Use monotonic high resolution timer for worker tasks runtime.
257 - Add worker tasks median runtime to statistics.
258 - Add worker tasks queue (experimental).
260 ## [2.4.4] - 2023-04-07
264 - Add `PoolEvents` enumeration and `PoolEvent` type.
268 - Destroy worker only on alive check.
270 ## [2.4.3] - 2023-04-07
274 - Fix typedoc generation with inheritance.
276 ## [2.4.2] - 2023-04-06
280 - Add `full` event to dynamic pool.
281 - Keep worker choice strategy in memory for conditional reuse.
285 - Fix possible negative worker key at worker removal in worker choice strategies.
287 ## [2.4.1] - 2023-04-05
291 - Optimize worker choice strategy for dynamic pool.
295 - Ensure dynamic pool does not alter worker choice strategy expected behavior.
297 ## [2.4.0] - 2023-04-04
301 - Add `LESS_BUSY` worker choice strategy.
305 - Optimize worker storage in pool.
306 - Optimize worker alive status check.
307 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
308 - Optimize `LESS_USED` worker choice strategy.
309 - Update benchmarks versus external threads pools.
310 - Optimize tasks usage statistics requirements for worker choice strategy.
314 - Ensure trimmable characters are checked at pool initialization.
315 - Fix message id integer overflow.
316 - Fix pool worker removal in worker choice strategy internals.
317 - Fix package publication with pnpm.
319 ## [2.4.0-3] - 2023-04-04
323 - Add `LESS_BUSY` worker choice strategy.
327 - Optimize worker storage in pool.
328 - Optimize worker alive status check.
329 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
330 - Optimize `LESS_USED` worker choice strategy.
331 - Update benchmarks versus external threads pools.
335 - Ensure trimmable characters are checked at pool initialization.
336 - Fix message id integer overflow.
337 - Fix pool worker removal in worker choice strategy internals.
338 - Fix package publication with pnpm.
340 ## [2.4.0-2] - 2023-04-03
344 - Add `LESS_BUSY` worker choice strategy.
348 - Optimize worker storage in pool.
349 - Optimize worker alive status check.
350 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
351 - Optimize `LESS_USED` worker choice strategy.
355 - Ensure trimmable characters are checked at pool initialization.
356 - Fix message id integer overflow.
357 - Fix pool worker removal in worker choice strategy internals.
358 - Fix package publication with pnpm.
360 ## [2.4.0-1] - 2023-04-03
364 - Add `LESS_BUSY` worker choice strategy.
368 - Optimize worker storage in pool.
369 - Optimize worker alive status check.
370 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
371 - Optimize `LESS_USED` worker choice strategy.
375 - Ensure trimmable characters are checked at pool initialization.
376 - Fix message id integer overflow.
377 - Fix pool worker removal in worker choice strategy internals.
379 ## [2.4.0-0] - 2023-04-03
383 - Add `LESS_BUSY` worker choice strategy.
387 - Optimize worker storage in pool.
388 - Optimize worker alive status check.
389 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
390 - Optimize `LESS_USED` worker choice strategy.
394 - Ensure trimmable characters are checked at pool initialization.
395 - Fix message id integer overflow.
396 - Fix pool worker removal in worker choice strategy internals.
398 ## [2.3.10] - 2023-03-18
402 - Fix `exports` syntax for ESM and CommonJS.
406 - Permit SemVer pre-release publication.
408 ## [2.3.10-2] - 2023-03-18
412 - Fix `exports` syntax for ESM and CommonJS.
414 ## [2.3.10-1] - 2023-03-18
418 - Permit SemVer pre-release publication.
420 ## [2.3.10-0] - 2023-03-18
424 - Fix `exports` syntax for ESM and CommonJS.
426 ## [2.3.9] - 2023-03-18
430 - Introduce ESM module support along with CommonJS one.
434 - Fix brown paper bag bug referencing the same object literal.
436 ## [2.3.8] - 2023-03-18
440 - Switch internal benchmarking code to benny.
441 - Switch to TypeScript 5.x.x.
442 - Switch rollup bundler plugins to core ones.
443 - Switch to TSDoc syntax.
444 - Enforce conventional commits.
448 - Fix random integer generator.
449 - Fix worker choice strategy pool type identification at initialization.
451 ## [2.3.7] - 2022-10-23
455 - Switch to open collective FOSS project funding platform.
456 - Switch to ts-standard linter configuration on TypeScript code.
460 - Fixed missing async on pool execute method.
461 - Fixed typing in TypeScript example.
462 - Fixed types in unit tests.
464 ## [2.3.6] - 2022-10-22
468 - Cleanup pool attributes and methods.
469 - Refine error types thrown.
473 - Fix continuous integration build on windows.
474 - Fix code coverage reporting by using c8 instead of nyc.
476 ## [2.3.5] - 2022-10-21
480 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
481 - Optimize tasks usage lookup implementation.
485 - Fix missed pool event emitter type export.
486 - Fix typedoc documentation generation.
488 ## [2.3.4] - 2022-10-17
492 - Fully automate release process with release-it.
496 - Optimize fair share task scheduling algorithm implementation.
497 - Update benchmarks versus external pools results with latest version.
499 ## [2.3.3] - 2022-10-15
503 - Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
505 ## [2.3.2] - 2022-10-14
509 - Optimize fair share worker selection strategy implementation.
513 - Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
515 ## [2.3.1] - 2022-10-13
519 - Pool worker choice strategies:
520 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
521 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
523 ## [2.2.2] - 2022-10-09
527 - Fixed `README.md` file.
529 ## [2.2.1] - 2022-10-08
533 - Dynamic worker choice strategy change at runtime.
535 ## [2.2.0] - 2022-01-05
539 - Support only NodeJS version 16.x.x for cluster pool: upstream cluster API have changed on that version.
541 ## [2.1.0] - 2021-08-29
545 - Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
549 - `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
550 - `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
551 - `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
552 - `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
554 ## [2.0.2] - 2021-05-12
558 - Fix `busy` event emission on fixed pool type
560 ## [2.0.1] - 2021-03-16
564 - Check if pool options are properly set.
565 - `busy` event is emitted on all pool types.
567 ## [2.0.0] - 2021-03-01
571 - Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
575 - `FullPool` event is now renamed to `busy`.
576 - `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
577 _Find more details on our JSDoc._
579 - `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
581 - We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
583 ### Pool options types declaration merge
585 `FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
587 #### New `export` strategy
591 const DynamicThreadPool = require('poolifier/lib/dynamic')
593 const { DynamicThreadPool } = require('poolifier/lib/dynamic')
596 But you should always prefer just using
599 const { DynamicThreadPool } = require('poolifier')
602 #### New type definitions for input data and response
604 For cluster worker and worker-thread pools, you can now only send and receive structured-cloneable data.
605 _This is not a limitation by poolifier but NodeJS._
607 #### Public property replacements
609 `numWorkers` property is now `numberOfWorkers`
611 #### Internal (protected) properties and methods renaming
613 These properties are not intended for end users
615 - `id` => `nextMessageId`
617 These methods are not intended for end users
619 - `_chooseWorker` => `chooseWorker`
620 - `_newWorker` => `createWorker`
621 - `_execute` => `internalExecute`
622 - `_chooseWorker` => `chooseWorker`
623 - `_checkAlive` => `checkAlive`
625 - `_runAsync` => `runAsync`
627 ## [1.1.0] - 2020-05-21
631 - ThreadWorker support async functions as option
632 - Various external library patches
634 ## [1.0.0] - 2020-01-24
638 - FixedThreadPool implementation
639 - DynamicThreadPool implementation
640 - WorkerThread implementation to improve developer experience