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 - Add Event Loop Utilization (ELU) statistics to worker tasks usage.
16 - Compute statistics at the worker level only if needed.
17 - Add `worker-threads` options to thread pool options.
21 - Make the `LEAST_BUSY` strategy only relies on task runtime.
23 ## [2.5.3] - 2023-06-04
27 - Refine pool information content.
28 - Limit pool internals public exposure.
30 ## [2.5.2] - 2023-06-02
34 - Add `taskError` pool event for task execution error.
35 - Add pool information `info` property to pool.
36 - Emit pool information on `busy` and `full` pool events.
38 ## [2.5.1] - 2023-06-01
42 - Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
43 - Add `error` pool event for uncaught worker error.
45 ## [2.5.0] - 2023-05-31
49 - Switch pool event emitter to `EventEmitterAsyncResource`.
50 - Add tasks wait time accounting in per worker tasks usage.
51 - Add interleaved weighted round robin worker choice strategy (experimental).
55 - Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
57 ## [2.4.14] - 2023-05-09
61 - Ensure no undefined task runtime can land in the tasks history.
62 - Fix median computation implementation once again.
66 - Unit tests for median and queue implementations.
68 ## [2.4.13] - 2023-05-08
72 - Fix worker choice strategy options validation.
73 - Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
75 ## [2.4.12] - 2023-05-06
79 - Support multiple task functions per worker.
80 - Add custom worker weights support to worker choice strategies options.
84 - Use O(1) queue implementation for tasks queueing.
88 - Fix median computation implementation.
89 - Fix fair share worker choice strategy internals update.
91 ## [2.4.11] - 2023-04-23
95 - Optimize free worker finding in worker choice strategies.
97 ## [2.4.10] - 2023-04-15
101 - Fix typescript type definition for worker function: ensure the input data is optional.
102 - Fix typescript type definition for pool execute(): ensure the input data is optional.
104 ## [2.4.9] - 2023-04-15
108 - Add tasks queue enablement runtime setter to pool.
109 - Add tasks queue options runtime setter to pool.
110 - Add worker choice strategy options runtime setter to pool.
114 - Remove the tasks queuing experimental status.
118 - Fix worker function type definition and validation.
119 - Fix worker choice strategy options handling.
121 ## [2.4.8] - 2023-04-12
125 - Fix message between main worker and worker type definition for tasks.
126 - Fix code documentation.
128 ## [2.4.7] - 2023-04-11
132 - Add worker tasks queue options to pool options.
136 - Fix missing documentation.
138 ## [2.4.6] - 2023-04-10
142 - Ensure one task at a time is executed per worker with tasks queueing enabled.
143 - Properly count worker running tasks with tasks queueing enabled.
145 ## [2.4.5] - 2023-04-09
149 - Use monotonic high resolution timer for worker tasks runtime.
150 - Add worker tasks median runtime to statistics.
151 - Add worker tasks queue (experimental).
153 ## [2.4.4] - 2023-04-07
157 - Add `PoolEvents` enumeration and `PoolEvent` type.
161 - Destroy worker only on alive check.
163 ## [2.4.3] - 2023-04-07
167 - Fix typedoc generation with inheritance.
169 ## [2.4.2] - 2023-04-06
173 - Add `full` event to dynamic pool.
174 - Keep worker choice strategy in memory for conditional reuse.
178 - Fix possible negative worker key at worker removal in worker choice strategies.
180 ## [2.4.1] - 2023-04-05
184 - Optimize worker choice strategy for dynamic pool.
188 - Ensure dynamic pool does not alter worker choice strategy expected behavior.
190 ## [2.4.0] - 2023-04-04
194 - Add `LESS_BUSY` worker choice strategy.
198 - Optimize worker storage in pool.
199 - Optimize worker alive status check.
200 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
201 - Optimize `LESS_USED` worker choice strategy.
202 - Update benchmarks versus external threads pools.
203 - Optimize tasks usage statistics requirements for worker choice strategy.
207 - Ensure trimmable characters are checked at pool initialization.
208 - Fix message id integer overflow.
209 - Fix pool worker removal in worker choice strategy internals.
210 - Fix package publication with pnpm.
212 ## [2.4.0-3] - 2023-04-04
216 - Add `LESS_BUSY` worker choice strategy.
220 - Optimize worker storage in pool.
221 - Optimize worker alive status check.
222 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
223 - Optimize `LESS_USED` worker choice strategy.
224 - Update benchmarks versus external threads pools.
228 - Ensure trimmable characters are checked at pool initialization.
229 - Fix message id integer overflow.
230 - Fix pool worker removal in worker choice strategy internals.
231 - Fix package publication with pnpm.
233 ## [2.4.0-2] - 2023-04-03
237 - Add `LESS_BUSY` worker choice strategy.
241 - Optimize worker storage in pool.
242 - Optimize worker alive status check.
243 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
244 - Optimize `LESS_USED` worker choice strategy.
248 - Ensure trimmable characters are checked at pool initialization.
249 - Fix message id integer overflow.
250 - Fix pool worker removal in worker choice strategy internals.
251 - Fix package publication with pnpm.
253 ## [2.4.0-1] - 2023-04-03
257 - Add `LESS_BUSY` worker choice strategy.
261 - Optimize worker storage in pool.
262 - Optimize worker alive status check.
263 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
264 - Optimize `LESS_USED` worker choice strategy.
268 - Ensure trimmable characters are checked at pool initialization.
269 - Fix message id integer overflow.
270 - Fix pool worker removal in worker choice strategy internals.
272 ## [2.4.0-0] - 2023-04-03
276 - Add `LESS_BUSY` worker choice strategy.
280 - Optimize worker storage in pool.
281 - Optimize worker alive status check.
282 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
283 - Optimize `LESS_USED` worker choice strategy.
287 - Ensure trimmable characters are checked at pool initialization.
288 - Fix message id integer overflow.
289 - Fix pool worker removal in worker choice strategy internals.
291 ## [2.3.10] - 2023-03-18
295 - Fix `exports` syntax for ESM and CommonJS.
299 - Permit SemVer pre-release publication.
301 ## [2.3.10-2] - 2023-03-18
305 - Fix `exports` syntax for ESM and CommonJS.
307 ## [2.3.10-1] - 2023-03-18
311 - Permit SemVer pre-release publication.
313 ## [2.3.10-0] - 2023-03-18
317 - Fix `exports` syntax for ESM and CommonJS.
319 ## [2.3.9] - 2023-03-18
323 - Introduce ESM module support along with CommonJS one.
327 - Fix brown paper bag bug referencing the same object literal.
329 ## [2.3.8] - 2023-03-18
333 - Switch internal benchmarking code to benny.
334 - Switch to TypeScript 5.x.x.
335 - Switch rollup bundler plugins to core ones.
336 - Switch to TSDoc syntax.
337 - Enforce conventional commits.
341 - Fix random integer generator.
342 - Fix worker choice strategy pool type identification at initialization.
344 ## [2.3.7] - 2022-10-23
348 - Switch to open collective FOSS project funding platform.
349 - Switch to ts-standard linter configuration on TypeScript code.
353 - Fixed missing async on pool execute method.
354 - Fixed typing in TypeScript example.
355 - Fixed types in unit tests.
357 ## [2.3.6] - 2022-10-22
361 - Cleanup pool attributes and methods.
362 - Refine error types thrown.
366 - Fix continuous integration build on windows.
367 - Fix code coverage reporting by using c8 instead of nyc.
369 ## [2.3.5] - 2022-10-21
373 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
374 - Optimize tasks usage lookup implementation.
378 - Fix missed pool event emitter type export.
379 - Fix typedoc documentation generation.
381 ## [2.3.4] - 2022-10-17
385 - Fully automate release process with release-it.
389 - Optimize fair share task scheduling algorithm implementation.
390 - Update benchmarks versus external pools results with latest version.
392 ## [2.3.3] - 2022-10-15
396 - Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
398 ## [2.3.2] - 2022-10-14
402 - Optimize fair share worker selection strategy implementation.
406 - Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
408 ## [2.3.1] - 2022-10-13
412 - Pool worker choice strategies:
413 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
414 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
416 ## [2.2.2] - 2022-10-09
420 - Fixed `README.md` file.
422 ## [2.2.1] - 2022-10-08
426 - Dynamic worker choice strategy change at runtime.
428 ## [2.2.0] - 2022-01-05
432 - Support only NodeJS version 16.x.x for cluster pool: upstream cluster API have changed on that version.
434 ## [2.1.0] - 2021-08-29
438 - Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
442 - `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
443 - `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
444 - `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
445 - `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
447 ## [2.0.2] - 2021-05-12
451 - Fix `busy` event emission on fixed pool type
453 ## [2.0.1] - 2021-03-16
457 - Check if pool options are properly set.
458 - `busy` event is emitted on all pool types.
460 ## [2.0.0] - 2021-03-01
464 - Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
468 - `FullPool` event is now renamed to `busy`.
469 - `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
470 _Find more details on our JSDoc._
472 - `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
474 - We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
476 ### Pool options types declaration merge
478 `FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
480 #### New `export` strategy
484 const DynamicThreadPool = require('poolifier/lib/dynamic')
486 const { DynamicThreadPool } = require('poolifier/lib/dynamic')
489 But you should always prefer just using
492 const { DynamicThreadPool } = require('poolifier')
495 #### New type definitions for input data and response
497 For cluster worker and worker-thread pools, you can now only send and receive serializable data.
498 _This is not a limitation by poolifier but NodeJS._
500 #### Public property replacements
502 `numWorkers` property is now `numberOfWorkers`
504 #### Internal (protected) properties and methods renaming
506 These properties are not intended for end users
508 - `id` => `nextMessageId`
510 These methods are not intended for end users
512 - `_chooseWorker` => `chooseWorker`
513 - `_newWorker` => `createWorker`
514 - `_execute` => `internalExecute`
515 - `_chooseWorker` => `chooseWorker`
516 - `_checkAlive` => `checkAlive`
518 - `_runAsync` => `runAsync`
520 ## [1.1.0] - 2020-05-21
524 - ThreadWorker support async functions as option
525 - Various external library patches
527 ## [1.0.0] - 2020-01-24
531 - FixedThreadPool implementation
532 - DynamicThreadPool implementation
533 - WorkerThread implementation to improve developer experience