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.5.4] - 2023-06-07
14 - Add Event Loop Utilization (ELU) statistics to worker tasks usage.
18 - Compute statistics at the worker level only if needed.
19 - Add `worker-threads` options to thread pool options.
23 - Make the `LEAST_BUSY` strategy only relies on task runtime.
25 ## [2.5.3] - 2023-06-04
29 - Refine pool information content.
30 - Limit pool internals public exposure.
32 ## [2.5.2] - 2023-06-02
36 - Add `taskError` pool event for task execution error.
37 - Add pool information `info` property to pool.
38 - Emit pool information on `busy` and `full` pool events.
40 ## [2.5.1] - 2023-06-01
44 - Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
45 - Add `error` pool event for uncaught worker error.
47 ## [2.5.0] - 2023-05-31
51 - Switch pool event emitter to `EventEmitterAsyncResource`.
52 - Add tasks wait time accounting in per worker tasks usage.
53 - Add interleaved weighted round robin worker choice strategy (experimental).
57 - Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
59 ## [2.4.14] - 2023-05-09
63 - Ensure no undefined task runtime can land in the tasks history.
64 - Fix median computation implementation once again.
68 - Unit tests for median and queue implementations.
70 ## [2.4.13] - 2023-05-08
74 - Fix worker choice strategy options validation.
75 - Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
77 ## [2.4.12] - 2023-05-06
81 - Support multiple task functions per worker.
82 - Add custom worker weights support to worker choice strategies options.
86 - Use O(1) queue implementation for tasks queueing.
90 - Fix median computation implementation.
91 - Fix fair share worker choice strategy internals update.
93 ## [2.4.11] - 2023-04-23
97 - Optimize free worker finding in worker choice strategies.
99 ## [2.4.10] - 2023-04-15
103 - Fix typescript type definition for worker function: ensure the input data is optional.
104 - Fix typescript type definition for pool execute(): ensure the input data is optional.
106 ## [2.4.9] - 2023-04-15
110 - Add tasks queue enablement runtime setter to pool.
111 - Add tasks queue options runtime setter to pool.
112 - Add worker choice strategy options runtime setter to pool.
116 - Remove the tasks queuing experimental status.
120 - Fix worker function type definition and validation.
121 - Fix worker choice strategy options handling.
123 ## [2.4.8] - 2023-04-12
127 - Fix message between main worker and worker type definition for tasks.
128 - Fix code documentation.
130 ## [2.4.7] - 2023-04-11
134 - Add worker tasks queue options to pool options.
138 - Fix missing documentation.
140 ## [2.4.6] - 2023-04-10
144 - Ensure one task at a time is executed per worker with tasks queueing enabled.
145 - Properly count worker running tasks with tasks queueing enabled.
147 ## [2.4.5] - 2023-04-09
151 - Use monotonic high resolution timer for worker tasks runtime.
152 - Add worker tasks median runtime to statistics.
153 - Add worker tasks queue (experimental).
155 ## [2.4.4] - 2023-04-07
159 - Add `PoolEvents` enumeration and `PoolEvent` type.
163 - Destroy worker only on alive check.
165 ## [2.4.3] - 2023-04-07
169 - Fix typedoc generation with inheritance.
171 ## [2.4.2] - 2023-04-06
175 - Add `full` event to dynamic pool.
176 - Keep worker choice strategy in memory for conditional reuse.
180 - Fix possible negative worker key at worker removal in worker choice strategies.
182 ## [2.4.1] - 2023-04-05
186 - Optimize worker choice strategy for dynamic pool.
190 - Ensure dynamic pool does not alter worker choice strategy expected behavior.
192 ## [2.4.0] - 2023-04-04
196 - Add `LESS_BUSY` worker choice strategy.
200 - Optimize worker storage in pool.
201 - Optimize worker alive status check.
202 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
203 - Optimize `LESS_USED` worker choice strategy.
204 - Update benchmarks versus external threads pools.
205 - Optimize tasks usage statistics requirements for worker choice strategy.
209 - Ensure trimmable characters are checked at pool initialization.
210 - Fix message id integer overflow.
211 - Fix pool worker removal in worker choice strategy internals.
212 - Fix package publication with pnpm.
214 ## [2.4.0-3] - 2023-04-04
218 - Add `LESS_BUSY` worker choice strategy.
222 - Optimize worker storage in pool.
223 - Optimize worker alive status check.
224 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
225 - Optimize `LESS_USED` worker choice strategy.
226 - Update benchmarks versus external threads pools.
230 - Ensure trimmable characters are checked at pool initialization.
231 - Fix message id integer overflow.
232 - Fix pool worker removal in worker choice strategy internals.
233 - Fix package publication with pnpm.
235 ## [2.4.0-2] - 2023-04-03
239 - Add `LESS_BUSY` worker choice strategy.
243 - Optimize worker storage in pool.
244 - Optimize worker alive status check.
245 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
246 - Optimize `LESS_USED` worker choice strategy.
250 - Ensure trimmable characters are checked at pool initialization.
251 - Fix message id integer overflow.
252 - Fix pool worker removal in worker choice strategy internals.
253 - Fix package publication with pnpm.
255 ## [2.4.0-1] - 2023-04-03
259 - Add `LESS_BUSY` worker choice strategy.
263 - Optimize worker storage in pool.
264 - Optimize worker alive status check.
265 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
266 - Optimize `LESS_USED` worker choice strategy.
270 - Ensure trimmable characters are checked at pool initialization.
271 - Fix message id integer overflow.
272 - Fix pool worker removal in worker choice strategy internals.
274 ## [2.4.0-0] - 2023-04-03
278 - Add `LESS_BUSY` worker choice strategy.
282 - Optimize worker storage in pool.
283 - Optimize worker alive status check.
284 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
285 - Optimize `LESS_USED` worker choice strategy.
289 - Ensure trimmable characters are checked at pool initialization.
290 - Fix message id integer overflow.
291 - Fix pool worker removal in worker choice strategy internals.
293 ## [2.3.10] - 2023-03-18
297 - Fix `exports` syntax for ESM and CommonJS.
301 - Permit SemVer pre-release publication.
303 ## [2.3.10-2] - 2023-03-18
307 - Fix `exports` syntax for ESM and CommonJS.
309 ## [2.3.10-1] - 2023-03-18
313 - Permit SemVer pre-release publication.
315 ## [2.3.10-0] - 2023-03-18
319 - Fix `exports` syntax for ESM and CommonJS.
321 ## [2.3.9] - 2023-03-18
325 - Introduce ESM module support along with CommonJS one.
329 - Fix brown paper bag bug referencing the same object literal.
331 ## [2.3.8] - 2023-03-18
335 - Switch internal benchmarking code to benny.
336 - Switch to TypeScript 5.x.x.
337 - Switch rollup bundler plugins to core ones.
338 - Switch to TSDoc syntax.
339 - Enforce conventional commits.
343 - Fix random integer generator.
344 - Fix worker choice strategy pool type identification at initialization.
346 ## [2.3.7] - 2022-10-23
350 - Switch to open collective FOSS project funding platform.
351 - Switch to ts-standard linter configuration on TypeScript code.
355 - Fixed missing async on pool execute method.
356 - Fixed typing in TypeScript example.
357 - Fixed types in unit tests.
359 ## [2.3.6] - 2022-10-22
363 - Cleanup pool attributes and methods.
364 - Refine error types thrown.
368 - Fix continuous integration build on windows.
369 - Fix code coverage reporting by using c8 instead of nyc.
371 ## [2.3.5] - 2022-10-21
375 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
376 - Optimize tasks usage lookup implementation.
380 - Fix missed pool event emitter type export.
381 - Fix typedoc documentation generation.
383 ## [2.3.4] - 2022-10-17
387 - Fully automate release process with release-it.
391 - Optimize fair share task scheduling algorithm implementation.
392 - Update benchmarks versus external pools results with latest version.
394 ## [2.3.3] - 2022-10-15
398 - Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
400 ## [2.3.2] - 2022-10-14
404 - Optimize fair share worker selection strategy implementation.
408 - Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
410 ## [2.3.1] - 2022-10-13
414 - Pool worker choice strategies:
415 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
416 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
418 ## [2.2.2] - 2022-10-09
422 - Fixed `README.md` file.
424 ## [2.2.1] - 2022-10-08
428 - Dynamic worker choice strategy change at runtime.
430 ## [2.2.0] - 2022-01-05
434 - Support only NodeJS version 16.x.x for cluster pool: upstream cluster API have changed on that version.
436 ## [2.1.0] - 2021-08-29
440 - Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
444 - `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
445 - `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
446 - `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
447 - `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
449 ## [2.0.2] - 2021-05-12
453 - Fix `busy` event emission on fixed pool type
455 ## [2.0.1] - 2021-03-16
459 - Check if pool options are properly set.
460 - `busy` event is emitted on all pool types.
462 ## [2.0.0] - 2021-03-01
466 - Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
470 - `FullPool` event is now renamed to `busy`.
471 - `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
472 _Find more details on our JSDoc._
474 - `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
476 - We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
478 ### Pool options types declaration merge
480 `FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
482 #### New `export` strategy
486 const DynamicThreadPool = require('poolifier/lib/dynamic')
488 const { DynamicThreadPool } = require('poolifier/lib/dynamic')
491 But you should always prefer just using
494 const { DynamicThreadPool } = require('poolifier')
497 #### New type definitions for input data and response
499 For cluster worker and worker-thread pools, you can now only send and receive serializable data.
500 _This is not a limitation by poolifier but NodeJS._
502 #### Public property replacements
504 `numWorkers` property is now `numberOfWorkers`
506 #### Internal (protected) properties and methods renaming
508 These properties are not intended for end users
510 - `id` => `nextMessageId`
512 These methods are not intended for end users
514 - `_chooseWorker` => `chooseWorker`
515 - `_newWorker` => `createWorker`
516 - `_execute` => `internalExecute`
517 - `_chooseWorker` => `chooseWorker`
518 - `_checkAlive` => `checkAlive`
520 - `_runAsync` => `runAsync`
522 ## [1.1.0] - 2020-05-21
526 - ThreadWorker support async functions as option
527 - Various external library patches
529 ## [1.0.0] - 2020-01-24
533 - FixedThreadPool implementation
534 - DynamicThreadPool implementation
535 - WorkerThread implementation to improve developer experience