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 `LEAST_ELU` worker choice strategy (experimental).
13 - Add tasks ELU instead of runtime support to `FAIR_SHARE` worker choice strategy.
17 - Refactor pool worker node usage internals.
18 - Breaking change: refactor worker choice strategy statistics requirements: the syntax of the worker choice strategy options has changed.
19 - Breaking change: pool information `info` property object fields have been renamed and added.
23 - Fix wait time accounting.
24 - Ensure worker choice strategy `LEAST_BUSY` accounts also tasks wait time.
25 - Ensure worker choice strategy `LEAST_USED` accounts also queued tasks.
27 ## [2.5.4] - 2023-06-07
31 - Add Event Loop Utilization (ELU) statistics to worker tasks usage.
35 - Compute statistics at the worker level only if needed.
36 - Add `worker-threads` options to thread pool options.
40 - Make the `LEAST_BUSY` strategy only relies on task runtime.
42 ## [2.5.3] - 2023-06-04
46 - Refine pool information content.
47 - Limit pool internals public exposure.
49 ## [2.5.2] - 2023-06-02
53 - Add `taskError` pool event for task execution error.
54 - Add pool information `info` property to pool.
55 - Emit pool information on `busy` and `full` pool events.
57 ## [2.5.1] - 2023-06-01
61 - Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
62 - Add `error` pool event for uncaught worker error.
64 ## [2.5.0] - 2023-05-31
68 - Switch pool event emitter to `EventEmitterAsyncResource`.
69 - Add tasks wait time accounting in per worker tasks usage.
70 - Add interleaved weighted round robin `INTERLEAVED_WEIGHTED_ROUND_ROBIN` worker choice strategy (experimental).
74 - Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
76 ## [2.4.14] - 2023-05-09
80 - Ensure no undefined task runtime can land in the tasks history.
81 - Fix median computation implementation once again.
85 - Unit tests for median and queue implementations.
87 ## [2.4.13] - 2023-05-08
91 - Fix worker choice strategy options validation.
92 - Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
94 ## [2.4.12] - 2023-05-06
98 - Support multiple task functions per worker.
99 - Add custom worker weights support to worker choice strategies options.
103 - Use O(1) queue implementation for tasks queueing.
107 - Fix median computation implementation.
108 - Fix fair share worker choice strategy internals update.
110 ## [2.4.11] - 2023-04-23
114 - Optimize free worker finding in worker choice strategies.
116 ## [2.4.10] - 2023-04-15
120 - Fix typescript type definition for worker function: ensure the input data is optional.
121 - Fix typescript type definition for pool execute(): ensure the input data is optional.
123 ## [2.4.9] - 2023-04-15
127 - Add tasks queue enablement runtime setter to pool.
128 - Add tasks queue options runtime setter to pool.
129 - Add worker choice strategy options runtime setter to pool.
133 - Remove the tasks queuing experimental status.
137 - Fix worker function type definition and validation.
138 - Fix worker choice strategy options handling.
140 ## [2.4.8] - 2023-04-12
144 - Fix message between main worker and worker type definition for tasks.
145 - Fix code documentation.
147 ## [2.4.7] - 2023-04-11
151 - Add worker tasks queue options to pool options.
155 - Fix missing documentation.
157 ## [2.4.6] - 2023-04-10
161 - Ensure one task at a time is executed per worker with tasks queueing enabled.
162 - Properly count worker executing tasks with tasks queueing enabled.
164 ## [2.4.5] - 2023-04-09
168 - Use monotonic high resolution timer for worker tasks runtime.
169 - Add worker tasks median runtime to statistics.
170 - Add worker tasks queue (experimental).
172 ## [2.4.4] - 2023-04-07
176 - Add `PoolEvents` enumeration and `PoolEvent` type.
180 - Destroy worker only on alive check.
182 ## [2.4.3] - 2023-04-07
186 - Fix typedoc generation with inheritance.
188 ## [2.4.2] - 2023-04-06
192 - Add `full` event to dynamic pool.
193 - Keep worker choice strategy in memory for conditional reuse.
197 - Fix possible negative worker key at worker removal in worker choice strategies.
199 ## [2.4.1] - 2023-04-05
203 - Optimize worker choice strategy for dynamic pool.
207 - Ensure dynamic pool does not alter worker choice strategy expected behavior.
209 ## [2.4.0] - 2023-04-04
213 - Add `LESS_BUSY` worker choice strategy.
217 - Optimize worker storage in pool.
218 - Optimize worker alive status check.
219 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
220 - Optimize `LESS_USED` worker choice strategy.
221 - Update benchmarks versus external threads pools.
222 - Optimize tasks usage statistics requirements for worker choice strategy.
226 - Ensure trimmable characters are checked at pool initialization.
227 - Fix message id integer overflow.
228 - Fix pool worker removal in worker choice strategy internals.
229 - Fix package publication with pnpm.
231 ## [2.4.0-3] - 2023-04-04
235 - Add `LESS_BUSY` worker choice strategy.
239 - Optimize worker storage in pool.
240 - Optimize worker alive status check.
241 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
242 - Optimize `LESS_USED` worker choice strategy.
243 - Update benchmarks versus external threads pools.
247 - Ensure trimmable characters are checked at pool initialization.
248 - Fix message id integer overflow.
249 - Fix pool worker removal in worker choice strategy internals.
250 - Fix package publication with pnpm.
252 ## [2.4.0-2] - 2023-04-03
256 - Add `LESS_BUSY` worker choice strategy.
260 - Optimize worker storage in pool.
261 - Optimize worker alive status check.
262 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
263 - Optimize `LESS_USED` worker choice strategy.
267 - Ensure trimmable characters are checked at pool initialization.
268 - Fix message id integer overflow.
269 - Fix pool worker removal in worker choice strategy internals.
270 - Fix package publication with pnpm.
272 ## [2.4.0-1] - 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.4.0-0] - 2023-04-03
295 - Add `LESS_BUSY` worker choice strategy.
299 - Optimize worker storage in pool.
300 - Optimize worker alive status check.
301 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
302 - Optimize `LESS_USED` worker choice strategy.
306 - Ensure trimmable characters are checked at pool initialization.
307 - Fix message id integer overflow.
308 - Fix pool worker removal in worker choice strategy internals.
310 ## [2.3.10] - 2023-03-18
314 - Fix `exports` syntax for ESM and CommonJS.
318 - Permit SemVer pre-release publication.
320 ## [2.3.10-2] - 2023-03-18
324 - Fix `exports` syntax for ESM and CommonJS.
326 ## [2.3.10-1] - 2023-03-18
330 - Permit SemVer pre-release publication.
332 ## [2.3.10-0] - 2023-03-18
336 - Fix `exports` syntax for ESM and CommonJS.
338 ## [2.3.9] - 2023-03-18
342 - Introduce ESM module support along with CommonJS one.
346 - Fix brown paper bag bug referencing the same object literal.
348 ## [2.3.8] - 2023-03-18
352 - Switch internal benchmarking code to benny.
353 - Switch to TypeScript 5.x.x.
354 - Switch rollup bundler plugins to core ones.
355 - Switch to TSDoc syntax.
356 - Enforce conventional commits.
360 - Fix random integer generator.
361 - Fix worker choice strategy pool type identification at initialization.
363 ## [2.3.7] - 2022-10-23
367 - Switch to open collective FOSS project funding platform.
368 - Switch to ts-standard linter configuration on TypeScript code.
372 - Fixed missing async on pool execute method.
373 - Fixed typing in TypeScript example.
374 - Fixed types in unit tests.
376 ## [2.3.6] - 2022-10-22
380 - Cleanup pool attributes and methods.
381 - Refine error types thrown.
385 - Fix continuous integration build on windows.
386 - Fix code coverage reporting by using c8 instead of nyc.
388 ## [2.3.5] - 2022-10-21
392 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
393 - Optimize tasks usage lookup implementation.
397 - Fix missed pool event emitter type export.
398 - Fix typedoc documentation generation.
400 ## [2.3.4] - 2022-10-17
404 - Fully automate release process with release-it.
408 - Optimize fair share task scheduling algorithm implementation.
409 - Update benchmarks versus external pools results with latest version.
411 ## [2.3.3] - 2022-10-15
415 - Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
417 ## [2.3.2] - 2022-10-14
421 - Optimize fair share worker selection strategy implementation.
425 - Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
427 ## [2.3.1] - 2022-10-13
431 - Pool worker choice strategies:
432 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
433 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
435 ## [2.2.2] - 2022-10-09
439 - Fixed `README.md` file.
441 ## [2.2.1] - 2022-10-08
445 - Dynamic worker choice strategy change at runtime.
447 ## [2.2.0] - 2022-01-05
451 - Support only NodeJS version 16.x.x for cluster pool: upstream cluster API have changed on that version.
453 ## [2.1.0] - 2021-08-29
457 - Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
461 - `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
462 - `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
463 - `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
464 - `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
466 ## [2.0.2] - 2021-05-12
470 - Fix `busy` event emission on fixed pool type
472 ## [2.0.1] - 2021-03-16
476 - Check if pool options are properly set.
477 - `busy` event is emitted on all pool types.
479 ## [2.0.0] - 2021-03-01
483 - Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
487 - `FullPool` event is now renamed to `busy`.
488 - `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
489 _Find more details on our JSDoc._
491 - `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
493 - We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
495 ### Pool options types declaration merge
497 `FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
499 #### New `export` strategy
503 const DynamicThreadPool = require('poolifier/lib/dynamic')
505 const { DynamicThreadPool } = require('poolifier/lib/dynamic')
508 But you should always prefer just using
511 const { DynamicThreadPool } = require('poolifier')
514 #### New type definitions for input data and response
516 For cluster worker and worker-thread pools, you can now only send and receive serializable data.
517 _This is not a limitation by poolifier but NodeJS._
519 #### Public property replacements
521 `numWorkers` property is now `numberOfWorkers`
523 #### Internal (protected) properties and methods renaming
525 These properties are not intended for end users
527 - `id` => `nextMessageId`
529 These methods are not intended for end users
531 - `_chooseWorker` => `chooseWorker`
532 - `_newWorker` => `createWorker`
533 - `_execute` => `internalExecute`
534 - `_chooseWorker` => `chooseWorker`
535 - `_checkAlive` => `checkAlive`
537 - `_runAsync` => `runAsync`
539 ## [1.1.0] - 2020-05-21
543 - ThreadWorker support async functions as option
544 - Various external library patches
546 ## [1.0.0] - 2020-01-24
550 - FixedThreadPool implementation
551 - DynamicThreadPool implementation
552 - WorkerThread implementation to improve developer experience