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 - Fix new worker use after creation in dynamic pool given the current worker choice strategy.
14 ## [2.6.1] - 2023-06-10
18 - Add worker choice strategy documentation: [README.md](./src/pools/selection-strategies/README.md).
22 - Fix average statistics computation: ensure failed tasks are not accounted.
24 ## [2.6.0] - 2023-06-09
28 - Add `LEAST_ELU` worker choice strategy (experimental).
29 - Add tasks ELU instead of runtime support to `FAIR_SHARE` worker choice strategy.
33 - Refactor pool worker node usage internals.
34 - Breaking change: refactor worker choice strategy statistics requirements: the syntax of the worker choice strategy options has changed.
35 - Breaking change: pool information `info` property object fields have been renamed.
39 - Fix wait time accounting.
40 - Ensure worker choice strategy `LEAST_BUSY` accounts also tasks wait time.
41 - Ensure worker choice strategy `LEAST_USED` accounts also queued tasks.
43 ## [2.5.4] - 2023-06-07
47 - Add Event Loop Utilization (ELU) statistics to worker tasks usage.
51 - Compute statistics at the worker level only if needed.
52 - Add `worker-threads` options to thread pool options.
56 - Make the `LEAST_BUSY` strategy only relies on task runtime.
58 ## [2.5.3] - 2023-06-04
62 - Refine pool information content.
63 - Limit pool internals public exposure.
65 ## [2.5.2] - 2023-06-02
69 - Add `taskError` pool event for task execution error.
70 - Add pool information `info` property to pool.
71 - Emit pool information on `busy` and `full` pool events.
73 ## [2.5.1] - 2023-06-01
77 - Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
78 - Add `error` pool event for uncaught worker error.
80 ## [2.5.0] - 2023-05-31
84 - Switch pool event emitter to `EventEmitterAsyncResource`.
85 - Add tasks wait time accounting in per worker tasks usage.
86 - Add interleaved weighted round robin `INTERLEAVED_WEIGHTED_ROUND_ROBIN` worker choice strategy (experimental).
90 - Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
92 ## [2.4.14] - 2023-05-09
96 - Ensure no undefined task runtime can land in the tasks history.
97 - Fix median computation implementation once again.
101 - Unit tests for median and queue implementations.
103 ## [2.4.13] - 2023-05-08
107 - Fix worker choice strategy options validation.
108 - Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
110 ## [2.4.12] - 2023-05-06
114 - Support multiple task functions per worker.
115 - Add custom worker weights support to worker choice strategies options.
119 - Use O(1) queue implementation for tasks queueing.
123 - Fix median computation implementation.
124 - Fix fair share worker choice strategy internals update.
126 ## [2.4.11] - 2023-04-23
130 - Optimize free worker finding in worker choice strategies.
132 ## [2.4.10] - 2023-04-15
136 - Fix typescript type definition for worker function: ensure the input data is optional.
137 - Fix typescript type definition for pool execute(): ensure the input data is optional.
139 ## [2.4.9] - 2023-04-15
143 - Add tasks queue enablement runtime setter to pool.
144 - Add tasks queue options runtime setter to pool.
145 - Add worker choice strategy options runtime setter to pool.
149 - Remove the tasks queuing experimental status.
153 - Fix worker function type definition and validation.
154 - Fix worker choice strategy options handling.
156 ## [2.4.8] - 2023-04-12
160 - Fix message between main worker and worker type definition for tasks.
161 - Fix code documentation.
163 ## [2.4.7] - 2023-04-11
167 - Add worker tasks queue options to pool options.
171 - Fix missing documentation.
173 ## [2.4.6] - 2023-04-10
177 - Ensure one task at a time is executed per worker with tasks queueing enabled.
178 - Properly count worker executing tasks with tasks queueing enabled.
180 ## [2.4.5] - 2023-04-09
184 - Use monotonic high resolution timer for worker tasks runtime.
185 - Add worker tasks median runtime to statistics.
186 - Add worker tasks queue (experimental).
188 ## [2.4.4] - 2023-04-07
192 - Add `PoolEvents` enumeration and `PoolEvent` type.
196 - Destroy worker only on alive check.
198 ## [2.4.3] - 2023-04-07
202 - Fix typedoc generation with inheritance.
204 ## [2.4.2] - 2023-04-06
208 - Add `full` event to dynamic pool.
209 - Keep worker choice strategy in memory for conditional reuse.
213 - Fix possible negative worker key at worker removal in worker choice strategies.
215 ## [2.4.1] - 2023-04-05
219 - Optimize worker choice strategy for dynamic pool.
223 - Ensure dynamic pool does not alter worker choice strategy expected behavior.
225 ## [2.4.0] - 2023-04-04
229 - Add `LESS_BUSY` worker choice strategy.
233 - Optimize worker storage in pool.
234 - Optimize worker alive status check.
235 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
236 - Optimize `LESS_USED` worker choice strategy.
237 - Update benchmarks versus external threads pools.
238 - Optimize tasks usage statistics requirements for worker choice strategy.
242 - Ensure trimmable characters are checked at pool initialization.
243 - Fix message id integer overflow.
244 - Fix pool worker removal in worker choice strategy internals.
245 - Fix package publication with pnpm.
247 ## [2.4.0-3] - 2023-04-04
251 - Add `LESS_BUSY` worker choice strategy.
255 - Optimize worker storage in pool.
256 - Optimize worker alive status check.
257 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
258 - Optimize `LESS_USED` worker choice strategy.
259 - Update benchmarks versus external threads pools.
263 - Ensure trimmable characters are checked at pool initialization.
264 - Fix message id integer overflow.
265 - Fix pool worker removal in worker choice strategy internals.
266 - Fix package publication with pnpm.
268 ## [2.4.0-2] - 2023-04-03
272 - Add `LESS_BUSY` worker choice strategy.
276 - Optimize worker storage in pool.
277 - Optimize worker alive status check.
278 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
279 - Optimize `LESS_USED` worker choice strategy.
283 - Ensure trimmable characters are checked at pool initialization.
284 - Fix message id integer overflow.
285 - Fix pool worker removal in worker choice strategy internals.
286 - Fix package publication with pnpm.
288 ## [2.4.0-1] - 2023-04-03
292 - Add `LESS_BUSY` worker choice strategy.
296 - Optimize worker storage in pool.
297 - Optimize worker alive status check.
298 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
299 - Optimize `LESS_USED` worker choice strategy.
303 - Ensure trimmable characters are checked at pool initialization.
304 - Fix message id integer overflow.
305 - Fix pool worker removal in worker choice strategy internals.
307 ## [2.4.0-0] - 2023-04-03
311 - Add `LESS_BUSY` worker choice strategy.
315 - Optimize worker storage in pool.
316 - Optimize worker alive status check.
317 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
318 - Optimize `LESS_USED` worker choice strategy.
322 - Ensure trimmable characters are checked at pool initialization.
323 - Fix message id integer overflow.
324 - Fix pool worker removal in worker choice strategy internals.
326 ## [2.3.10] - 2023-03-18
330 - Fix `exports` syntax for ESM and CommonJS.
334 - Permit SemVer pre-release publication.
336 ## [2.3.10-2] - 2023-03-18
340 - Fix `exports` syntax for ESM and CommonJS.
342 ## [2.3.10-1] - 2023-03-18
346 - Permit SemVer pre-release publication.
348 ## [2.3.10-0] - 2023-03-18
352 - Fix `exports` syntax for ESM and CommonJS.
354 ## [2.3.9] - 2023-03-18
358 - Introduce ESM module support along with CommonJS one.
362 - Fix brown paper bag bug referencing the same object literal.
364 ## [2.3.8] - 2023-03-18
368 - Switch internal benchmarking code to benny.
369 - Switch to TypeScript 5.x.x.
370 - Switch rollup bundler plugins to core ones.
371 - Switch to TSDoc syntax.
372 - Enforce conventional commits.
376 - Fix random integer generator.
377 - Fix worker choice strategy pool type identification at initialization.
379 ## [2.3.7] - 2022-10-23
383 - Switch to open collective FOSS project funding platform.
384 - Switch to ts-standard linter configuration on TypeScript code.
388 - Fixed missing async on pool execute method.
389 - Fixed typing in TypeScript example.
390 - Fixed types in unit tests.
392 ## [2.3.6] - 2022-10-22
396 - Cleanup pool attributes and methods.
397 - Refine error types thrown.
401 - Fix continuous integration build on windows.
402 - Fix code coverage reporting by using c8 instead of nyc.
404 ## [2.3.5] - 2022-10-21
408 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
409 - Optimize tasks usage lookup implementation.
413 - Fix missed pool event emitter type export.
414 - Fix typedoc documentation generation.
416 ## [2.3.4] - 2022-10-17
420 - Fully automate release process with release-it.
424 - Optimize fair share task scheduling algorithm implementation.
425 - Update benchmarks versus external pools results with latest version.
427 ## [2.3.3] - 2022-10-15
431 - Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
433 ## [2.3.2] - 2022-10-14
437 - Optimize fair share worker selection strategy implementation.
441 - Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
443 ## [2.3.1] - 2022-10-13
447 - Pool worker choice strategies:
448 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
449 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
451 ## [2.2.2] - 2022-10-09
455 - Fixed `README.md` file.
457 ## [2.2.1] - 2022-10-08
461 - Dynamic worker choice strategy change at runtime.
463 ## [2.2.0] - 2022-01-05
467 - Support only NodeJS version 16.x.x for cluster pool: upstream cluster API have changed on that version.
469 ## [2.1.0] - 2021-08-29
473 - Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
477 - `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
478 - `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
479 - `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
480 - `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
482 ## [2.0.2] - 2021-05-12
486 - Fix `busy` event emission on fixed pool type
488 ## [2.0.1] - 2021-03-16
492 - Check if pool options are properly set.
493 - `busy` event is emitted on all pool types.
495 ## [2.0.0] - 2021-03-01
499 - Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
503 - `FullPool` event is now renamed to `busy`.
504 - `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
505 _Find more details on our JSDoc._
507 - `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
509 - We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
511 ### Pool options types declaration merge
513 `FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
515 #### New `export` strategy
519 const DynamicThreadPool = require('poolifier/lib/dynamic')
521 const { DynamicThreadPool } = require('poolifier/lib/dynamic')
524 But you should always prefer just using
527 const { DynamicThreadPool } = require('poolifier')
530 #### New type definitions for input data and response
532 For cluster worker and worker-thread pools, you can now only send and receive serializable data.
533 _This is not a limitation by poolifier but NodeJS._
535 #### Public property replacements
537 `numWorkers` property is now `numberOfWorkers`
539 #### Internal (protected) properties and methods renaming
541 These properties are not intended for end users
543 - `id` => `nextMessageId`
545 These methods are not intended for end users
547 - `_chooseWorker` => `chooseWorker`
548 - `_newWorker` => `createWorker`
549 - `_execute` => `internalExecute`
550 - `_chooseWorker` => `chooseWorker`
551 - `_checkAlive` => `checkAlive`
553 - `_runAsync` => `runAsync`
555 ## [1.1.0] - 2020-05-21
559 - ThreadWorker support async functions as option
560 - Various external library patches
562 ## [1.0.0] - 2020-01-24
566 - FixedThreadPool implementation
567 - DynamicThreadPool implementation
568 - WorkerThread implementation to improve developer experience