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 worker choice strategy documentation: [README.md](./src/pools/selection-strategies/README.md).
16 - Fix average statistics computation: ensure failed tasks are not accounted.
18 ## [2.6.0] - 2023-06-09
22 - Add `LEAST_ELU` worker choice strategy (experimental).
23 - Add tasks ELU instead of runtime support to `FAIR_SHARE` worker choice strategy.
27 - Refactor pool worker node usage internals.
28 - Breaking change: refactor worker choice strategy statistics requirements: the syntax of the worker choice strategy options has changed.
29 - Breaking change: pool information `info` property object fields have been renamed.
33 - Fix wait time accounting.
34 - Ensure worker choice strategy `LEAST_BUSY` accounts also tasks wait time.
35 - Ensure worker choice strategy `LEAST_USED` accounts also queued tasks.
37 ## [2.5.4] - 2023-06-07
41 - Add Event Loop Utilization (ELU) statistics to worker tasks usage.
45 - Compute statistics at the worker level only if needed.
46 - Add `worker-threads` options to thread pool options.
50 - Make the `LEAST_BUSY` strategy only relies on task runtime.
52 ## [2.5.3] - 2023-06-04
56 - Refine pool information content.
57 - Limit pool internals public exposure.
59 ## [2.5.2] - 2023-06-02
63 - Add `taskError` pool event for task execution error.
64 - Add pool information `info` property to pool.
65 - Emit pool information on `busy` and `full` pool events.
67 ## [2.5.1] - 2023-06-01
71 - Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
72 - Add `error` pool event for uncaught worker error.
74 ## [2.5.0] - 2023-05-31
78 - Switch pool event emitter to `EventEmitterAsyncResource`.
79 - Add tasks wait time accounting in per worker tasks usage.
80 - Add interleaved weighted round robin `INTERLEAVED_WEIGHTED_ROUND_ROBIN` worker choice strategy (experimental).
84 - Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
86 ## [2.4.14] - 2023-05-09
90 - Ensure no undefined task runtime can land in the tasks history.
91 - Fix median computation implementation once again.
95 - Unit tests for median and queue implementations.
97 ## [2.4.13] - 2023-05-08
101 - Fix worker choice strategy options validation.
102 - Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
104 ## [2.4.12] - 2023-05-06
108 - Support multiple task functions per worker.
109 - Add custom worker weights support to worker choice strategies options.
113 - Use O(1) queue implementation for tasks queueing.
117 - Fix median computation implementation.
118 - Fix fair share worker choice strategy internals update.
120 ## [2.4.11] - 2023-04-23
124 - Optimize free worker finding in worker choice strategies.
126 ## [2.4.10] - 2023-04-15
130 - Fix typescript type definition for worker function: ensure the input data is optional.
131 - Fix typescript type definition for pool execute(): ensure the input data is optional.
133 ## [2.4.9] - 2023-04-15
137 - Add tasks queue enablement runtime setter to pool.
138 - Add tasks queue options runtime setter to pool.
139 - Add worker choice strategy options runtime setter to pool.
143 - Remove the tasks queuing experimental status.
147 - Fix worker function type definition and validation.
148 - Fix worker choice strategy options handling.
150 ## [2.4.8] - 2023-04-12
154 - Fix message between main worker and worker type definition for tasks.
155 - Fix code documentation.
157 ## [2.4.7] - 2023-04-11
161 - Add worker tasks queue options to pool options.
165 - Fix missing documentation.
167 ## [2.4.6] - 2023-04-10
171 - Ensure one task at a time is executed per worker with tasks queueing enabled.
172 - Properly count worker executing tasks with tasks queueing enabled.
174 ## [2.4.5] - 2023-04-09
178 - Use monotonic high resolution timer for worker tasks runtime.
179 - Add worker tasks median runtime to statistics.
180 - Add worker tasks queue (experimental).
182 ## [2.4.4] - 2023-04-07
186 - Add `PoolEvents` enumeration and `PoolEvent` type.
190 - Destroy worker only on alive check.
192 ## [2.4.3] - 2023-04-07
196 - Fix typedoc generation with inheritance.
198 ## [2.4.2] - 2023-04-06
202 - Add `full` event to dynamic pool.
203 - Keep worker choice strategy in memory for conditional reuse.
207 - Fix possible negative worker key at worker removal in worker choice strategies.
209 ## [2.4.1] - 2023-04-05
213 - Optimize worker choice strategy for dynamic pool.
217 - Ensure dynamic pool does not alter worker choice strategy expected behavior.
219 ## [2.4.0] - 2023-04-04
223 - Add `LESS_BUSY` worker choice strategy.
227 - Optimize worker storage in pool.
228 - Optimize worker alive status check.
229 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
230 - Optimize `LESS_USED` worker choice strategy.
231 - Update benchmarks versus external threads pools.
232 - Optimize tasks usage statistics requirements for worker choice strategy.
236 - Ensure trimmable characters are checked at pool initialization.
237 - Fix message id integer overflow.
238 - Fix pool worker removal in worker choice strategy internals.
239 - Fix package publication with pnpm.
241 ## [2.4.0-3] - 2023-04-04
245 - Add `LESS_BUSY` worker choice strategy.
249 - Optimize worker storage in pool.
250 - Optimize worker alive status check.
251 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
252 - Optimize `LESS_USED` worker choice strategy.
253 - Update benchmarks versus external threads pools.
257 - Ensure trimmable characters are checked at pool initialization.
258 - Fix message id integer overflow.
259 - Fix pool worker removal in worker choice strategy internals.
260 - Fix package publication with pnpm.
262 ## [2.4.0-2] - 2023-04-03
266 - Add `LESS_BUSY` worker choice strategy.
270 - Optimize worker storage in pool.
271 - Optimize worker alive status check.
272 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
273 - Optimize `LESS_USED` worker choice strategy.
277 - Ensure trimmable characters are checked at pool initialization.
278 - Fix message id integer overflow.
279 - Fix pool worker removal in worker choice strategy internals.
280 - Fix package publication with pnpm.
282 ## [2.4.0-1] - 2023-04-03
286 - Add `LESS_BUSY` worker choice strategy.
290 - Optimize worker storage in pool.
291 - Optimize worker alive status check.
292 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
293 - Optimize `LESS_USED` worker choice strategy.
297 - Ensure trimmable characters are checked at pool initialization.
298 - Fix message id integer overflow.
299 - Fix pool worker removal in worker choice strategy internals.
301 ## [2.4.0-0] - 2023-04-03
305 - Add `LESS_BUSY` worker choice strategy.
309 - Optimize worker storage in pool.
310 - Optimize worker alive status check.
311 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
312 - Optimize `LESS_USED` worker choice strategy.
316 - Ensure trimmable characters are checked at pool initialization.
317 - Fix message id integer overflow.
318 - Fix pool worker removal in worker choice strategy internals.
320 ## [2.3.10] - 2023-03-18
324 - Fix `exports` syntax for ESM and CommonJS.
328 - Permit SemVer pre-release publication.
330 ## [2.3.10-2] - 2023-03-18
334 - Fix `exports` syntax for ESM and CommonJS.
336 ## [2.3.10-1] - 2023-03-18
340 - Permit SemVer pre-release publication.
342 ## [2.3.10-0] - 2023-03-18
346 - Fix `exports` syntax for ESM and CommonJS.
348 ## [2.3.9] - 2023-03-18
352 - Introduce ESM module support along with CommonJS one.
356 - Fix brown paper bag bug referencing the same object literal.
358 ## [2.3.8] - 2023-03-18
362 - Switch internal benchmarking code to benny.
363 - Switch to TypeScript 5.x.x.
364 - Switch rollup bundler plugins to core ones.
365 - Switch to TSDoc syntax.
366 - Enforce conventional commits.
370 - Fix random integer generator.
371 - Fix worker choice strategy pool type identification at initialization.
373 ## [2.3.7] - 2022-10-23
377 - Switch to open collective FOSS project funding platform.
378 - Switch to ts-standard linter configuration on TypeScript code.
382 - Fixed missing async on pool execute method.
383 - Fixed typing in TypeScript example.
384 - Fixed types in unit tests.
386 ## [2.3.6] - 2022-10-22
390 - Cleanup pool attributes and methods.
391 - Refine error types thrown.
395 - Fix continuous integration build on windows.
396 - Fix code coverage reporting by using c8 instead of nyc.
398 ## [2.3.5] - 2022-10-21
402 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
403 - Optimize tasks usage lookup implementation.
407 - Fix missed pool event emitter type export.
408 - Fix typedoc documentation generation.
410 ## [2.3.4] - 2022-10-17
414 - Fully automate release process with release-it.
418 - Optimize fair share task scheduling algorithm implementation.
419 - Update benchmarks versus external pools results with latest version.
421 ## [2.3.3] - 2022-10-15
425 - Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
427 ## [2.3.2] - 2022-10-14
431 - Optimize fair share worker selection strategy implementation.
435 - Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
437 ## [2.3.1] - 2022-10-13
441 - Pool worker choice strategies:
442 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
443 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
445 ## [2.2.2] - 2022-10-09
449 - Fixed `README.md` file.
451 ## [2.2.1] - 2022-10-08
455 - Dynamic worker choice strategy change at runtime.
457 ## [2.2.0] - 2022-01-05
461 - Support only NodeJS version 16.x.x for cluster pool: upstream cluster API have changed on that version.
463 ## [2.1.0] - 2021-08-29
467 - Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
471 - `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
472 - `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
473 - `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
474 - `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
476 ## [2.0.2] - 2021-05-12
480 - Fix `busy` event emission on fixed pool type
482 ## [2.0.1] - 2021-03-16
486 - Check if pool options are properly set.
487 - `busy` event is emitted on all pool types.
489 ## [2.0.0] - 2021-03-01
493 - Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
497 - `FullPool` event is now renamed to `busy`.
498 - `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
499 _Find more details on our JSDoc._
501 - `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
503 - We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
505 ### Pool options types declaration merge
507 `FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
509 #### New `export` strategy
513 const DynamicThreadPool = require('poolifier/lib/dynamic')
515 const { DynamicThreadPool } = require('poolifier/lib/dynamic')
518 But you should always prefer just using
521 const { DynamicThreadPool } = require('poolifier')
524 #### New type definitions for input data and response
526 For cluster worker and worker-thread pools, you can now only send and receive serializable data.
527 _This is not a limitation by poolifier but NodeJS._
529 #### Public property replacements
531 `numWorkers` property is now `numberOfWorkers`
533 #### Internal (protected) properties and methods renaming
535 These properties are not intended for end users
537 - `id` => `nextMessageId`
539 These methods are not intended for end users
541 - `_chooseWorker` => `chooseWorker`
542 - `_newWorker` => `createWorker`
543 - `_execute` => `internalExecute`
544 - `_chooseWorker` => `chooseWorker`
545 - `_checkAlive` => `checkAlive`
547 - `_runAsync` => `runAsync`
549 ## [1.1.0] - 2020-05-21
553 - ThreadWorker support async functions as option
554 - Various external library patches
556 ## [1.0.0] - 2020-01-24
560 - FixedThreadPool implementation
561 - DynamicThreadPool implementation
562 - WorkerThread implementation to improve developer experience