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.8] - 2023-07-03
14 - Brown paper bag release to fix version handling in pool information.
16 ## [2.6.7] - 2023-07-03
20 - Ensure worker queued tasks at error are reassigned to other pool workers.
24 - Add pool `utilization` ratio to pool information.
25 - Add `version` to pool information.
26 - Add worker information to worker nodes.
28 ## [2.6.6] - 2023-07-01
32 - Add safe helper `availableParallelism` to help sizing the pool.
36 - Ensure message handler is only registered in worker.
38 ## [2.6.5] - 2023-06-27
42 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
46 - Artificial version bump to 2.6.5 to workaround publication issue.
47 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
48 - Ensure pool event is emitted before task error promise rejection.
49 - Fix queued tasks count computation.
53 - Remove unneeded worker-threads worker `MessageChannel` internal usage for IPC.
55 ## [2.6.4] - 2023-06-27
59 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
63 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
64 - Ensure pool event is emitted before task error promise rejection.
65 - Fix queued tasks count computation.
69 - Remove unneeded worker-threads worker `MessageChannel` internal usage for IPC.
71 ## [2.6.3] - 2023-06-19
75 - Ensure no tasks are queued when trying to soft kill a dynamic worker.
76 - Update strategies internals after statistics computation.
80 - Optimize O(1) queue implementation.
82 ## [2.6.2] - 2023-06-12
86 - Fix new worker use after creation in dynamic pool given the current worker choice strategy.
88 ## [2.6.1] - 2023-06-10
92 - Add worker choice strategy documentation: [README.md](./src/pools/selection-strategies/README.md).
96 - Fix average statistics computation: ensure failed tasks are not accounted.
98 ## [2.6.0] - 2023-06-09
102 - Add `LEAST_ELU` worker choice strategy (experimental).
103 - Add tasks ELU instead of runtime support to `FAIR_SHARE` worker choice strategy.
107 - Refactor pool worker node usage internals.
108 - Breaking change: refactor worker choice strategy statistics requirements: the syntax of the worker choice strategy options has changed.
109 - Breaking change: pool information `info` property object fields have been renamed.
113 - Fix wait time accounting.
114 - Ensure worker choice strategy `LEAST_BUSY` accounts also tasks wait time.
115 - Ensure worker choice strategy `LEAST_USED` accounts also queued tasks.
117 ## [2.5.4] - 2023-06-07
121 - Add Event Loop Utilization (ELU) statistics to worker tasks usage.
125 - Compute statistics at the worker level only if needed.
126 - Add `worker-threads` options to thread pool options.
130 - Make the `LEAST_BUSY` strategy only relies on task runtime.
132 ## [2.5.3] - 2023-06-04
136 - Refine pool information content.
137 - Limit pool internals public exposure.
139 ## [2.5.2] - 2023-06-02
143 - Add `taskError` pool event for task execution error.
144 - Add pool information `info` property to pool.
145 - Emit pool information on `busy` and `full` pool events.
147 ## [2.5.1] - 2023-06-01
151 - Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
152 - Add `error` pool event for uncaught worker error.
154 ## [2.5.0] - 2023-05-31
158 - Switch pool event emitter to `EventEmitterAsyncResource`.
159 - Add tasks wait time accounting in per worker tasks usage.
160 - Add interleaved weighted round robin `INTERLEAVED_WEIGHTED_ROUND_ROBIN` worker choice strategy (experimental).
164 - Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
166 ## [2.4.14] - 2023-05-09
170 - Ensure no undefined task runtime can land in the tasks history.
171 - Fix median computation implementation once again.
175 - Unit tests for median and queue implementations.
177 ## [2.4.13] - 2023-05-08
181 - Fix worker choice strategy options validation.
182 - Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
184 ## [2.4.12] - 2023-05-06
188 - Support multiple task functions per worker.
189 - Add custom worker weights support to worker choice strategies options.
193 - Use O(1) queue implementation for tasks queueing.
197 - Fix median computation implementation.
198 - Fix fair share worker choice strategy internals update.
200 ## [2.4.11] - 2023-04-23
204 - Optimize free worker finding in worker choice strategies.
206 ## [2.4.10] - 2023-04-15
210 - Fix typescript type definition for worker function: ensure the input data is optional.
211 - Fix typescript type definition for pool execute(): ensure the input data is optional.
213 ## [2.4.9] - 2023-04-15
217 - Add tasks queue enablement runtime setter to pool.
218 - Add tasks queue options runtime setter to pool.
219 - Add worker choice strategy options runtime setter to pool.
223 - Remove the tasks queuing experimental status.
227 - Fix worker function type definition and validation.
228 - Fix worker choice strategy options handling.
230 ## [2.4.8] - 2023-04-12
234 - Fix message between main worker and worker type definition for tasks.
235 - Fix code documentation.
237 ## [2.4.7] - 2023-04-11
241 - Add worker tasks queue options to pool options.
245 - Fix missing documentation.
247 ## [2.4.6] - 2023-04-10
251 - Ensure one task at a time is executed per worker with tasks queueing enabled.
252 - Properly count worker executing tasks with tasks queueing enabled.
254 ## [2.4.5] - 2023-04-09
258 - Use monotonic high resolution timer for worker tasks runtime.
259 - Add worker tasks median runtime to statistics.
260 - Add worker tasks queue (experimental).
262 ## [2.4.4] - 2023-04-07
266 - Add `PoolEvents` enumeration and `PoolEvent` type.
270 - Destroy worker only on alive check.
272 ## [2.4.3] - 2023-04-07
276 - Fix typedoc generation with inheritance.
278 ## [2.4.2] - 2023-04-06
282 - Add `full` event to dynamic pool.
283 - Keep worker choice strategy in memory for conditional reuse.
287 - Fix possible negative worker key at worker removal in worker choice strategies.
289 ## [2.4.1] - 2023-04-05
293 - Optimize worker choice strategy for dynamic pool.
297 - Ensure dynamic pool does not alter worker choice strategy expected behavior.
299 ## [2.4.0] - 2023-04-04
303 - Add `LESS_BUSY` worker choice strategy.
307 - Optimize worker storage in pool.
308 - Optimize worker alive status check.
309 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
310 - Optimize `LESS_USED` worker choice strategy.
311 - Update benchmarks versus external threads pools.
312 - Optimize tasks usage statistics requirements for 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.
319 - Fix package publication with pnpm.
321 ## [2.4.0-3] - 2023-04-04
325 - Add `LESS_BUSY` worker choice strategy.
329 - Optimize worker storage in pool.
330 - Optimize worker alive status check.
331 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
332 - Optimize `LESS_USED` worker choice strategy.
333 - Update benchmarks versus external threads pools.
337 - Ensure trimmable characters are checked at pool initialization.
338 - Fix message id integer overflow.
339 - Fix pool worker removal in worker choice strategy internals.
340 - Fix package publication with pnpm.
342 ## [2.4.0-2] - 2023-04-03
346 - Add `LESS_BUSY` worker choice strategy.
350 - Optimize worker storage in pool.
351 - Optimize worker alive status check.
352 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
353 - Optimize `LESS_USED` worker choice strategy.
357 - Ensure trimmable characters are checked at pool initialization.
358 - Fix message id integer overflow.
359 - Fix pool worker removal in worker choice strategy internals.
360 - Fix package publication with pnpm.
362 ## [2.4.0-1] - 2023-04-03
366 - Add `LESS_BUSY` worker choice strategy.
370 - Optimize worker storage in pool.
371 - Optimize worker alive status check.
372 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
373 - Optimize `LESS_USED` worker choice strategy.
377 - Ensure trimmable characters are checked at pool initialization.
378 - Fix message id integer overflow.
379 - Fix pool worker removal in worker choice strategy internals.
381 ## [2.4.0-0] - 2023-04-03
385 - Add `LESS_BUSY` worker choice strategy.
389 - Optimize worker storage in pool.
390 - Optimize worker alive status check.
391 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
392 - Optimize `LESS_USED` worker choice strategy.
396 - Ensure trimmable characters are checked at pool initialization.
397 - Fix message id integer overflow.
398 - Fix pool worker removal in worker choice strategy internals.
400 ## [2.3.10] - 2023-03-18
404 - Fix `exports` syntax for ESM and CommonJS.
408 - Permit SemVer pre-release publication.
410 ## [2.3.10-2] - 2023-03-18
414 - Fix `exports` syntax for ESM and CommonJS.
416 ## [2.3.10-1] - 2023-03-18
420 - Permit SemVer pre-release publication.
422 ## [2.3.10-0] - 2023-03-18
426 - Fix `exports` syntax for ESM and CommonJS.
428 ## [2.3.9] - 2023-03-18
432 - Introduce ESM module support along with CommonJS one.
436 - Fix brown paper bag bug referencing the same object literal.
438 ## [2.3.8] - 2023-03-18
442 - Switch internal benchmarking code to benny.
443 - Switch to TypeScript 5.x.x.
444 - Switch rollup bundler plugins to core ones.
445 - Switch to TSDoc syntax.
446 - Enforce conventional commits.
450 - Fix random integer generator.
451 - Fix worker choice strategy pool type identification at initialization.
453 ## [2.3.7] - 2022-10-23
457 - Switch to open collective FOSS project funding platform.
458 - Switch to ts-standard linter configuration on TypeScript code.
462 - Fixed missing async on pool execute method.
463 - Fixed typing in TypeScript example.
464 - Fixed types in unit tests.
466 ## [2.3.6] - 2022-10-22
470 - Cleanup pool attributes and methods.
471 - Refine error types thrown.
475 - Fix continuous integration build on windows.
476 - Fix code coverage reporting by using c8 instead of nyc.
478 ## [2.3.5] - 2022-10-21
482 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
483 - Optimize tasks usage lookup implementation.
487 - Fix missed pool event emitter type export.
488 - Fix typedoc documentation generation.
490 ## [2.3.4] - 2022-10-17
494 - Fully automate release process with release-it.
498 - Optimize fair share task scheduling algorithm implementation.
499 - Update benchmarks versus external pools results with latest version.
501 ## [2.3.3] - 2022-10-15
505 - Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
507 ## [2.3.2] - 2022-10-14
511 - Optimize fair share worker selection strategy implementation.
515 - Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
517 ## [2.3.1] - 2022-10-13
521 - Pool worker choice strategies:
522 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
523 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
525 ## [2.2.2] - 2022-10-09
529 - Fixed `README.md` file.
531 ## [2.2.1] - 2022-10-08
535 - Dynamic worker choice strategy change at runtime.
537 ## [2.2.0] - 2022-01-05
541 - Support only NodeJS version 16.x.x for cluster pool: upstream cluster API have changed on that version.
543 ## [2.1.0] - 2021-08-29
547 - Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
551 - `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
552 - `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
553 - `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
554 - `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
556 ## [2.0.2] - 2021-05-12
560 - Fix `busy` event emission on fixed pool type
562 ## [2.0.1] - 2021-03-16
566 - Check if pool options are properly set.
567 - `busy` event is emitted on all pool types.
569 ## [2.0.0] - 2021-03-01
573 - Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
577 - `FullPool` event is now renamed to `busy`.
578 - `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
579 _Find more details on our JSDoc._
581 - `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
583 - We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
585 ### Pool options types declaration merge
587 `FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
589 #### New `export` strategy
593 const DynamicThreadPool = require('poolifier/lib/dynamic')
595 const { DynamicThreadPool } = require('poolifier/lib/dynamic')
598 But you should always prefer just using
601 const { DynamicThreadPool } = require('poolifier')
604 #### New type definitions for input data and response
606 For cluster worker and worker-thread pools, you can now only send and receive structured-cloneable data.
607 _This is not a limitation by poolifier but NodeJS._
609 #### Public property replacements
611 `numWorkers` property is now `numberOfWorkers`
613 #### Internal (protected) properties and methods renaming
615 These properties are not intended for end users
617 - `id` => `nextMessageId`
619 These methods are not intended for end users
621 - `_chooseWorker` => `chooseWorker`
622 - `_newWorker` => `createWorker`
623 - `_execute` => `internalExecute`
624 - `_chooseWorker` => `chooseWorker`
625 - `_checkAlive` => `checkAlive`
627 - `_runAsync` => `runAsync`
629 ## [1.1.0] - 2020-05-21
633 - ThreadWorker support async functions as option
634 - Various external library patches
636 ## [1.0.0] - 2020-01-24
640 - FixedThreadPool implementation
641 - DynamicThreadPool implementation
642 - WorkerThread implementation to improve developer experience