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 - Refactor pool worker node usage internals.
16 - Fix wait time accounting.
17 - Ensure worker choice strategy `LEAST_BUSY` accounts also tasks wait time.
18 - Ensure worker choice strategy `LEAST_USED` accounts also queued tasks.
20 ## [2.5.4] - 2023-06-07
24 - Add Event Loop Utilization (ELU) statistics to worker tasks usage.
28 - Compute statistics at the worker level only if needed.
29 - Add `worker-threads` options to thread pool options.
33 - Make the `LEAST_BUSY` strategy only relies on task runtime.
35 ## [2.5.3] - 2023-06-04
39 - Refine pool information content.
40 - Limit pool internals public exposure.
42 ## [2.5.2] - 2023-06-02
46 - Add `taskError` pool event for task execution error.
47 - Add pool information `info` property to pool.
48 - Emit pool information on `busy` and `full` pool events.
50 ## [2.5.1] - 2023-06-01
54 - Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
55 - Add `error` pool event for uncaught worker error.
57 ## [2.5.0] - 2023-05-31
61 - Switch pool event emitter to `EventEmitterAsyncResource`.
62 - Add tasks wait time accounting in per worker tasks usage.
63 - Add interleaved weighted round robin worker choice strategy (experimental).
67 - Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
69 ## [2.4.14] - 2023-05-09
73 - Ensure no undefined task runtime can land in the tasks history.
74 - Fix median computation implementation once again.
78 - Unit tests for median and queue implementations.
80 ## [2.4.13] - 2023-05-08
84 - Fix worker choice strategy options validation.
85 - Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
87 ## [2.4.12] - 2023-05-06
91 - Support multiple task functions per worker.
92 - Add custom worker weights support to worker choice strategies options.
96 - Use O(1) queue implementation for tasks queueing.
100 - Fix median computation implementation.
101 - Fix fair share worker choice strategy internals update.
103 ## [2.4.11] - 2023-04-23
107 - Optimize free worker finding in worker choice strategies.
109 ## [2.4.10] - 2023-04-15
113 - Fix typescript type definition for worker function: ensure the input data is optional.
114 - Fix typescript type definition for pool execute(): ensure the input data is optional.
116 ## [2.4.9] - 2023-04-15
120 - Add tasks queue enablement runtime setter to pool.
121 - Add tasks queue options runtime setter to pool.
122 - Add worker choice strategy options runtime setter to pool.
126 - Remove the tasks queuing experimental status.
130 - Fix worker function type definition and validation.
131 - Fix worker choice strategy options handling.
133 ## [2.4.8] - 2023-04-12
137 - Fix message between main worker and worker type definition for tasks.
138 - Fix code documentation.
140 ## [2.4.7] - 2023-04-11
144 - Add worker tasks queue options to pool options.
148 - Fix missing documentation.
150 ## [2.4.6] - 2023-04-10
154 - Ensure one task at a time is executed per worker with tasks queueing enabled.
155 - Properly count worker executing tasks with tasks queueing enabled.
157 ## [2.4.5] - 2023-04-09
161 - Use monotonic high resolution timer for worker tasks runtime.
162 - Add worker tasks median runtime to statistics.
163 - Add worker tasks queue (experimental).
165 ## [2.4.4] - 2023-04-07
169 - Add `PoolEvents` enumeration and `PoolEvent` type.
173 - Destroy worker only on alive check.
175 ## [2.4.3] - 2023-04-07
179 - Fix typedoc generation with inheritance.
181 ## [2.4.2] - 2023-04-06
185 - Add `full` event to dynamic pool.
186 - Keep worker choice strategy in memory for conditional reuse.
190 - Fix possible negative worker key at worker removal in worker choice strategies.
192 ## [2.4.1] - 2023-04-05
196 - Optimize worker choice strategy for dynamic pool.
200 - Ensure dynamic pool does not alter worker choice strategy expected behavior.
202 ## [2.4.0] - 2023-04-04
206 - Add `LESS_BUSY` worker choice strategy.
210 - Optimize worker storage in pool.
211 - Optimize worker alive status check.
212 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
213 - Optimize `LESS_USED` worker choice strategy.
214 - Update benchmarks versus external threads pools.
215 - Optimize tasks usage statistics requirements for worker choice strategy.
219 - Ensure trimmable characters are checked at pool initialization.
220 - Fix message id integer overflow.
221 - Fix pool worker removal in worker choice strategy internals.
222 - Fix package publication with pnpm.
224 ## [2.4.0-3] - 2023-04-04
228 - Add `LESS_BUSY` worker choice strategy.
232 - Optimize worker storage in pool.
233 - Optimize worker alive status check.
234 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
235 - Optimize `LESS_USED` worker choice strategy.
236 - Update benchmarks versus external threads pools.
240 - Ensure trimmable characters are checked at pool initialization.
241 - Fix message id integer overflow.
242 - Fix pool worker removal in worker choice strategy internals.
243 - Fix package publication with pnpm.
245 ## [2.4.0-2] - 2023-04-03
249 - Add `LESS_BUSY` worker choice strategy.
253 - Optimize worker storage in pool.
254 - Optimize worker alive status check.
255 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
256 - Optimize `LESS_USED` worker choice strategy.
260 - Ensure trimmable characters are checked at pool initialization.
261 - Fix message id integer overflow.
262 - Fix pool worker removal in worker choice strategy internals.
263 - Fix package publication with pnpm.
265 ## [2.4.0-1] - 2023-04-03
269 - Add `LESS_BUSY` worker choice strategy.
273 - Optimize worker storage in pool.
274 - Optimize worker alive status check.
275 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
276 - Optimize `LESS_USED` worker choice strategy.
280 - Ensure trimmable characters are checked at pool initialization.
281 - Fix message id integer overflow.
282 - Fix pool worker removal in worker choice strategy internals.
284 ## [2.4.0-0] - 2023-04-03
288 - Add `LESS_BUSY` worker choice strategy.
292 - Optimize worker storage in pool.
293 - Optimize worker alive status check.
294 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
295 - Optimize `LESS_USED` worker choice strategy.
299 - Ensure trimmable characters are checked at pool initialization.
300 - Fix message id integer overflow.
301 - Fix pool worker removal in worker choice strategy internals.
303 ## [2.3.10] - 2023-03-18
307 - Fix `exports` syntax for ESM and CommonJS.
311 - Permit SemVer pre-release publication.
313 ## [2.3.10-2] - 2023-03-18
317 - Fix `exports` syntax for ESM and CommonJS.
319 ## [2.3.10-1] - 2023-03-18
323 - Permit SemVer pre-release publication.
325 ## [2.3.10-0] - 2023-03-18
329 - Fix `exports` syntax for ESM and CommonJS.
331 ## [2.3.9] - 2023-03-18
335 - Introduce ESM module support along with CommonJS one.
339 - Fix brown paper bag bug referencing the same object literal.
341 ## [2.3.8] - 2023-03-18
345 - Switch internal benchmarking code to benny.
346 - Switch to TypeScript 5.x.x.
347 - Switch rollup bundler plugins to core ones.
348 - Switch to TSDoc syntax.
349 - Enforce conventional commits.
353 - Fix random integer generator.
354 - Fix worker choice strategy pool type identification at initialization.
356 ## [2.3.7] - 2022-10-23
360 - Switch to open collective FOSS project funding platform.
361 - Switch to ts-standard linter configuration on TypeScript code.
365 - Fixed missing async on pool execute method.
366 - Fixed typing in TypeScript example.
367 - Fixed types in unit tests.
369 ## [2.3.6] - 2022-10-22
373 - Cleanup pool attributes and methods.
374 - Refine error types thrown.
378 - Fix continuous integration build on windows.
379 - Fix code coverage reporting by using c8 instead of nyc.
381 ## [2.3.5] - 2022-10-21
385 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
386 - Optimize tasks usage lookup implementation.
390 - Fix missed pool event emitter type export.
391 - Fix typedoc documentation generation.
393 ## [2.3.4] - 2022-10-17
397 - Fully automate release process with release-it.
401 - Optimize fair share task scheduling algorithm implementation.
402 - Update benchmarks versus external pools results with latest version.
404 ## [2.3.3] - 2022-10-15
408 - Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
410 ## [2.3.2] - 2022-10-14
414 - Optimize fair share worker selection strategy implementation.
418 - Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
420 ## [2.3.1] - 2022-10-13
424 - Pool worker choice strategies:
425 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
426 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
428 ## [2.2.2] - 2022-10-09
432 - Fixed `README.md` file.
434 ## [2.2.1] - 2022-10-08
438 - Dynamic worker choice strategy change at runtime.
440 ## [2.2.0] - 2022-01-05
444 - Support only NodeJS version 16.x.x for cluster pool: upstream cluster API have changed on that version.
446 ## [2.1.0] - 2021-08-29
450 - Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
454 - `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
455 - `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
456 - `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
457 - `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
459 ## [2.0.2] - 2021-05-12
463 - Fix `busy` event emission on fixed pool type
465 ## [2.0.1] - 2021-03-16
469 - Check if pool options are properly set.
470 - `busy` event is emitted on all pool types.
472 ## [2.0.0] - 2021-03-01
476 - Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
480 - `FullPool` event is now renamed to `busy`.
481 - `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
482 _Find more details on our JSDoc._
484 - `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
486 - We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
488 ### Pool options types declaration merge
490 `FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
492 #### New `export` strategy
496 const DynamicThreadPool = require('poolifier/lib/dynamic')
498 const { DynamicThreadPool } = require('poolifier/lib/dynamic')
501 But you should always prefer just using
504 const { DynamicThreadPool } = require('poolifier')
507 #### New type definitions for input data and response
509 For cluster worker and worker-thread pools, you can now only send and receive serializable data.
510 _This is not a limitation by poolifier but NodeJS._
512 #### Public property replacements
514 `numWorkers` property is now `numberOfWorkers`
516 #### Internal (protected) properties and methods renaming
518 These properties are not intended for end users
520 - `id` => `nextMessageId`
522 These methods are not intended for end users
524 - `_chooseWorker` => `chooseWorker`
525 - `_newWorker` => `createWorker`
526 - `_execute` => `internalExecute`
527 - `_chooseWorker` => `chooseWorker`
528 - `_checkAlive` => `checkAlive`
530 - `_runAsync` => `runAsync`
532 ## [1.1.0] - 2020-05-21
536 - ThreadWorker support async functions as option
537 - Various external library patches
539 ## [1.0.0] - 2020-01-24
543 - FixedThreadPool implementation
544 - DynamicThreadPool implementation
545 - WorkerThread implementation to improve developer experience