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.1] - 2023-06-10
14 - Add worker choice strategy documentation: [README.md](./src/pools/selection-strategies/README.md).
18 - Fix average statistics computation: ensure failed tasks are not accounted.
20 ## [2.6.0] - 2023-06-09
24 - Add `LEAST_ELU` worker choice strategy (experimental).
25 - Add tasks ELU instead of runtime support to `FAIR_SHARE` worker choice strategy.
29 - Refactor pool worker node usage internals.
30 - Breaking change: refactor worker choice strategy statistics requirements: the syntax of the worker choice strategy options has changed.
31 - Breaking change: pool information `info` property object fields have been renamed.
35 - Fix wait time accounting.
36 - Ensure worker choice strategy `LEAST_BUSY` accounts also tasks wait time.
37 - Ensure worker choice strategy `LEAST_USED` accounts also queued tasks.
39 ## [2.5.4] - 2023-06-07
43 - Add Event Loop Utilization (ELU) statistics to worker tasks usage.
47 - Compute statistics at the worker level only if needed.
48 - Add `worker-threads` options to thread pool options.
52 - Make the `LEAST_BUSY` strategy only relies on task runtime.
54 ## [2.5.3] - 2023-06-04
58 - Refine pool information content.
59 - Limit pool internals public exposure.
61 ## [2.5.2] - 2023-06-02
65 - Add `taskError` pool event for task execution error.
66 - Add pool information `info` property to pool.
67 - Emit pool information on `busy` and `full` pool events.
69 ## [2.5.1] - 2023-06-01
73 - Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
74 - Add `error` pool event for uncaught worker error.
76 ## [2.5.0] - 2023-05-31
80 - Switch pool event emitter to `EventEmitterAsyncResource`.
81 - Add tasks wait time accounting in per worker tasks usage.
82 - Add interleaved weighted round robin `INTERLEAVED_WEIGHTED_ROUND_ROBIN` worker choice strategy (experimental).
86 - Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
88 ## [2.4.14] - 2023-05-09
92 - Ensure no undefined task runtime can land in the tasks history.
93 - Fix median computation implementation once again.
97 - Unit tests for median and queue implementations.
99 ## [2.4.13] - 2023-05-08
103 - Fix worker choice strategy options validation.
104 - Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
106 ## [2.4.12] - 2023-05-06
110 - Support multiple task functions per worker.
111 - Add custom worker weights support to worker choice strategies options.
115 - Use O(1) queue implementation for tasks queueing.
119 - Fix median computation implementation.
120 - Fix fair share worker choice strategy internals update.
122 ## [2.4.11] - 2023-04-23
126 - Optimize free worker finding in worker choice strategies.
128 ## [2.4.10] - 2023-04-15
132 - Fix typescript type definition for worker function: ensure the input data is optional.
133 - Fix typescript type definition for pool execute(): ensure the input data is optional.
135 ## [2.4.9] - 2023-04-15
139 - Add tasks queue enablement runtime setter to pool.
140 - Add tasks queue options runtime setter to pool.
141 - Add worker choice strategy options runtime setter to pool.
145 - Remove the tasks queuing experimental status.
149 - Fix worker function type definition and validation.
150 - Fix worker choice strategy options handling.
152 ## [2.4.8] - 2023-04-12
156 - Fix message between main worker and worker type definition for tasks.
157 - Fix code documentation.
159 ## [2.4.7] - 2023-04-11
163 - Add worker tasks queue options to pool options.
167 - Fix missing documentation.
169 ## [2.4.6] - 2023-04-10
173 - Ensure one task at a time is executed per worker with tasks queueing enabled.
174 - Properly count worker executing tasks with tasks queueing enabled.
176 ## [2.4.5] - 2023-04-09
180 - Use monotonic high resolution timer for worker tasks runtime.
181 - Add worker tasks median runtime to statistics.
182 - Add worker tasks queue (experimental).
184 ## [2.4.4] - 2023-04-07
188 - Add `PoolEvents` enumeration and `PoolEvent` type.
192 - Destroy worker only on alive check.
194 ## [2.4.3] - 2023-04-07
198 - Fix typedoc generation with inheritance.
200 ## [2.4.2] - 2023-04-06
204 - Add `full` event to dynamic pool.
205 - Keep worker choice strategy in memory for conditional reuse.
209 - Fix possible negative worker key at worker removal in worker choice strategies.
211 ## [2.4.1] - 2023-04-05
215 - Optimize worker choice strategy for dynamic pool.
219 - Ensure dynamic pool does not alter worker choice strategy expected behavior.
221 ## [2.4.0] - 2023-04-04
225 - Add `LESS_BUSY` worker choice strategy.
229 - Optimize worker storage in pool.
230 - Optimize worker alive status check.
231 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
232 - Optimize `LESS_USED` worker choice strategy.
233 - Update benchmarks versus external threads pools.
234 - Optimize tasks usage statistics requirements for worker choice strategy.
238 - Ensure trimmable characters are checked at pool initialization.
239 - Fix message id integer overflow.
240 - Fix pool worker removal in worker choice strategy internals.
241 - Fix package publication with pnpm.
243 ## [2.4.0-3] - 2023-04-04
247 - Add `LESS_BUSY` worker choice strategy.
251 - Optimize worker storage in pool.
252 - Optimize worker alive status check.
253 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
254 - Optimize `LESS_USED` worker choice strategy.
255 - Update benchmarks versus external threads pools.
259 - Ensure trimmable characters are checked at pool initialization.
260 - Fix message id integer overflow.
261 - Fix pool worker removal in worker choice strategy internals.
262 - Fix package publication with pnpm.
264 ## [2.4.0-2] - 2023-04-03
268 - Add `LESS_BUSY` worker choice strategy.
272 - Optimize worker storage in pool.
273 - Optimize worker alive status check.
274 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
275 - Optimize `LESS_USED` worker choice strategy.
279 - Ensure trimmable characters are checked at pool initialization.
280 - Fix message id integer overflow.
281 - Fix pool worker removal in worker choice strategy internals.
282 - Fix package publication with pnpm.
284 ## [2.4.0-1] - 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.4.0-0] - 2023-04-03
307 - Add `LESS_BUSY` worker choice strategy.
311 - Optimize worker storage in pool.
312 - Optimize worker alive status check.
313 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
314 - Optimize `LESS_USED` worker choice strategy.
318 - Ensure trimmable characters are checked at pool initialization.
319 - Fix message id integer overflow.
320 - Fix pool worker removal in worker choice strategy internals.
322 ## [2.3.10] - 2023-03-18
326 - Fix `exports` syntax for ESM and CommonJS.
330 - Permit SemVer pre-release publication.
332 ## [2.3.10-2] - 2023-03-18
336 - Fix `exports` syntax for ESM and CommonJS.
338 ## [2.3.10-1] - 2023-03-18
342 - Permit SemVer pre-release publication.
344 ## [2.3.10-0] - 2023-03-18
348 - Fix `exports` syntax for ESM and CommonJS.
350 ## [2.3.9] - 2023-03-18
354 - Introduce ESM module support along with CommonJS one.
358 - Fix brown paper bag bug referencing the same object literal.
360 ## [2.3.8] - 2023-03-18
364 - Switch internal benchmarking code to benny.
365 - Switch to TypeScript 5.x.x.
366 - Switch rollup bundler plugins to core ones.
367 - Switch to TSDoc syntax.
368 - Enforce conventional commits.
372 - Fix random integer generator.
373 - Fix worker choice strategy pool type identification at initialization.
375 ## [2.3.7] - 2022-10-23
379 - Switch to open collective FOSS project funding platform.
380 - Switch to ts-standard linter configuration on TypeScript code.
384 - Fixed missing async on pool execute method.
385 - Fixed typing in TypeScript example.
386 - Fixed types in unit tests.
388 ## [2.3.6] - 2022-10-22
392 - Cleanup pool attributes and methods.
393 - Refine error types thrown.
397 - Fix continuous integration build on windows.
398 - Fix code coverage reporting by using c8 instead of nyc.
400 ## [2.3.5] - 2022-10-21
404 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
405 - Optimize tasks usage lookup implementation.
409 - Fix missed pool event emitter type export.
410 - Fix typedoc documentation generation.
412 ## [2.3.4] - 2022-10-17
416 - Fully automate release process with release-it.
420 - Optimize fair share task scheduling algorithm implementation.
421 - Update benchmarks versus external pools results with latest version.
423 ## [2.3.3] - 2022-10-15
427 - Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
429 ## [2.3.2] - 2022-10-14
433 - Optimize fair share worker selection strategy implementation.
437 - Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
439 ## [2.3.1] - 2022-10-13
443 - Pool worker choice strategies:
444 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
445 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
447 ## [2.2.2] - 2022-10-09
451 - Fixed `README.md` file.
453 ## [2.2.1] - 2022-10-08
457 - Dynamic worker choice strategy change at runtime.
459 ## [2.2.0] - 2022-01-05
463 - Support only NodeJS version 16.x.x for cluster pool: upstream cluster API have changed on that version.
465 ## [2.1.0] - 2021-08-29
469 - Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
473 - `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
474 - `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
475 - `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
476 - `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
478 ## [2.0.2] - 2021-05-12
482 - Fix `busy` event emission on fixed pool type
484 ## [2.0.1] - 2021-03-16
488 - Check if pool options are properly set.
489 - `busy` event is emitted on all pool types.
491 ## [2.0.0] - 2021-03-01
495 - Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
499 - `FullPool` event is now renamed to `busy`.
500 - `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
501 _Find more details on our JSDoc._
503 - `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
505 - We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
507 ### Pool options types declaration merge
509 `FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
511 #### New `export` strategy
515 const DynamicThreadPool = require('poolifier/lib/dynamic')
517 const { DynamicThreadPool } = require('poolifier/lib/dynamic')
520 But you should always prefer just using
523 const { DynamicThreadPool } = require('poolifier')
526 #### New type definitions for input data and response
528 For cluster worker and worker-thread pools, you can now only send and receive serializable data.
529 _This is not a limitation by poolifier but NodeJS._
531 #### Public property replacements
533 `numWorkers` property is now `numberOfWorkers`
535 #### Internal (protected) properties and methods renaming
537 These properties are not intended for end users
539 - `id` => `nextMessageId`
541 These methods are not intended for end users
543 - `_chooseWorker` => `chooseWorker`
544 - `_newWorker` => `createWorker`
545 - `_execute` => `internalExecute`
546 - `_chooseWorker` => `chooseWorker`
547 - `_checkAlive` => `checkAlive`
549 - `_runAsync` => `runAsync`
551 ## [1.1.0] - 2020-05-21
555 - ThreadWorker support async functions as option
556 - Various external library patches
558 ## [1.0.0] - 2020-01-24
562 - FixedThreadPool implementation
563 - DynamicThreadPool implementation
564 - WorkerThread implementation to improve developer experience