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 - Take into account worker node readiness in worker choice strategies.
14 ## [2.6.14] - 2023-07-10
18 - Fix task function statistics tracking.
20 ## [2.6.13] - 2023-07-10
24 - Add per task function statistics tracking.
25 - Add public methods to manipulate the worker task functions at runtime.
27 ## [2.6.12] - 2023-07-09
31 - Workaround import issue with `node:os` module in node 16.x.x.
33 ## [2.6.11] - 2023-07-09
37 - Fix pool readiness semantic.
39 ## [2.6.10] - 2023-07-08
43 - Ensure workers are not recreated on error at pool startup.
47 - Add `ready` and `strategy` fields to pool information.
48 - Add pool event `ready` to notify when the number of workers created in the pool has reached the maximum size expected and are ready.
49 - Add dynamic pool sizing checks.
51 ## [2.6.9] - 2023-07-07
55 - Recreate the right worker type on uncaught exception.
59 - Add minimum and maximum to internal measurement statistics.
60 - Add `runTime` and `waitTime` to pool information.
61 - Check worker inactive time only on dynamic worker.
63 ## [2.6.8] - 2023-07-03
67 - Brown paper bag release to fix version handling in pool information.
69 ## [2.6.7] - 2023-07-03
73 - Ensure worker queued tasks at error are reassigned to other pool workers.
77 - Add pool `utilization` ratio to pool information.
78 - Add `version` to pool information.
79 - Add worker information to worker nodes.
81 ## [2.6.6] - 2023-07-01
85 - Add safe helper `availableParallelism` to help sizing the pool.
89 - Ensure message handler is only registered in worker.
91 ## [2.6.5] - 2023-06-27
95 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
99 - Artificial version bump to 2.6.5 to workaround publication issue.
100 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
101 - Ensure pool event is emitted before task error promise rejection.
102 - Fix queued tasks count computation.
106 - Remove unneeded worker-threads worker `MessageChannel` internal usage for IPC.
108 ## [2.6.4] - 2023-06-27
112 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
116 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
117 - Ensure pool event is emitted before task error promise rejection.
118 - Fix queued tasks count computation.
122 - Remove unneeded worker-threads worker `MessageChannel` internal usage for IPC.
124 ## [2.6.3] - 2023-06-19
128 - Ensure no tasks are queued when trying to soft kill a dynamic worker.
129 - Update strategies internals after statistics computation.
133 - Optimize O(1) queue implementation.
135 ## [2.6.2] - 2023-06-12
139 - Fix new worker use after creation in dynamic pool given the current worker choice strategy.
141 ## [2.6.1] - 2023-06-10
145 - Add worker choice strategy documentation: [README.md](./src/pools/selection-strategies/README.md).
149 - Fix average statistics computation: ensure failed tasks are not accounted.
151 ## [2.6.0] - 2023-06-09
155 - Add `LEAST_ELU` worker choice strategy (experimental).
156 - Add tasks ELU instead of runtime support to `FAIR_SHARE` worker choice strategy.
160 - Refactor pool worker node usage internals.
161 - Breaking change: refactor worker choice strategy statistics requirements: the syntax of the worker choice strategy options has changed.
162 - Breaking change: pool information `info` property object fields have been renamed.
166 - Fix wait time accounting.
167 - Ensure worker choice strategy `LEAST_BUSY` accounts also tasks wait time.
168 - Ensure worker choice strategy `LEAST_USED` accounts also queued tasks.
170 ## [2.5.4] - 2023-06-07
174 - Add Event Loop Utilization (ELU) statistics to worker tasks usage.
178 - Compute statistics at the worker level only if needed.
179 - Add `worker-threads` options to thread pool options.
183 - Make the `LEAST_BUSY` strategy only relies on task runtime.
185 ## [2.5.3] - 2023-06-04
189 - Refine pool information content.
190 - Limit pool internals public exposure.
192 ## [2.5.2] - 2023-06-02
196 - Add `taskError` pool event for task execution error.
197 - Add pool information `info` property to pool.
198 - Emit pool information on `busy` and `full` pool events.
200 ## [2.5.1] - 2023-06-01
204 - Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
205 - Add `error` pool event for uncaught worker error.
207 ## [2.5.0] - 2023-05-31
211 - Switch pool event emitter to `EventEmitterAsyncResource`.
212 - Add tasks wait time accounting in per worker tasks usage.
213 - Add interleaved weighted round robin `INTERLEAVED_WEIGHTED_ROUND_ROBIN` worker choice strategy (experimental).
217 - Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
219 ## [2.4.14] - 2023-05-09
223 - Ensure no undefined task runtime can land in the tasks history.
224 - Fix median computation implementation once again.
228 - Unit tests for median and queue implementations.
230 ## [2.4.13] - 2023-05-08
234 - Fix worker choice strategy options validation.
235 - Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
237 ## [2.4.12] - 2023-05-06
241 - Support multiple task functions per worker.
242 - Add custom worker weights support to worker choice strategies options.
246 - Use O(1) queue implementation for tasks queueing.
250 - Fix median computation implementation.
251 - Fix fair share worker choice strategy internals update.
253 ## [2.4.11] - 2023-04-23
257 - Optimize free worker finding in worker choice strategies.
259 ## [2.4.10] - 2023-04-15
263 - Fix typescript type definition for worker function: ensure the input data is optional.
264 - Fix typescript type definition for pool execute(): ensure the input data is optional.
266 ## [2.4.9] - 2023-04-15
270 - Add tasks queue enablement runtime setter to pool.
271 - Add tasks queue options runtime setter to pool.
272 - Add worker choice strategy options runtime setter to pool.
276 - Remove the tasks queuing experimental status.
280 - Fix worker function type definition and validation.
281 - Fix worker choice strategy options handling.
283 ## [2.4.8] - 2023-04-12
287 - Fix message between main worker and worker type definition for tasks.
288 - Fix code documentation.
290 ## [2.4.7] - 2023-04-11
294 - Add worker tasks queue options to pool options.
298 - Fix missing documentation.
300 ## [2.4.6] - 2023-04-10
304 - Ensure one task at a time is executed per worker with tasks queueing enabled.
305 - Properly count worker executing tasks with tasks queueing enabled.
307 ## [2.4.5] - 2023-04-09
311 - Use monotonic high resolution timer for worker tasks runtime.
312 - Add worker tasks median runtime to statistics.
313 - Add worker tasks queue (experimental).
315 ## [2.4.4] - 2023-04-07
319 - Add `PoolEvents` enumeration and `PoolEvent` type.
323 - Destroy worker only on alive check.
325 ## [2.4.3] - 2023-04-07
329 - Fix typedoc generation with inheritance.
331 ## [2.4.2] - 2023-04-06
335 - Add `full` event to dynamic pool.
336 - Keep worker choice strategy in memory for conditional reuse.
340 - Fix possible negative worker key at worker removal in worker choice strategies.
342 ## [2.4.1] - 2023-04-05
346 - Optimize worker choice strategy for dynamic pool.
350 - Ensure dynamic pool does not alter worker choice strategy expected behavior.
352 ## [2.4.0] - 2023-04-04
356 - Add `LESS_BUSY` worker choice strategy.
360 - Optimize worker storage in pool.
361 - Optimize worker alive status check.
362 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
363 - Optimize `LESS_USED` worker choice strategy.
364 - Update benchmarks versus external threads pools.
365 - Optimize tasks usage statistics requirements for worker choice strategy.
369 - Ensure trimmable characters are checked at pool initialization.
370 - Fix message id integer overflow.
371 - Fix pool worker removal in worker choice strategy internals.
372 - Fix package publication with pnpm.
374 ## [2.4.0-3] - 2023-04-04
378 - Add `LESS_BUSY` worker choice strategy.
382 - Optimize worker storage in pool.
383 - Optimize worker alive status check.
384 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
385 - Optimize `LESS_USED` worker choice strategy.
386 - Update benchmarks versus external threads pools.
390 - Ensure trimmable characters are checked at pool initialization.
391 - Fix message id integer overflow.
392 - Fix pool worker removal in worker choice strategy internals.
393 - Fix package publication with pnpm.
395 ## [2.4.0-2] - 2023-04-03
399 - Add `LESS_BUSY` worker choice strategy.
403 - Optimize worker storage in pool.
404 - Optimize worker alive status check.
405 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
406 - Optimize `LESS_USED` worker choice strategy.
410 - Ensure trimmable characters are checked at pool initialization.
411 - Fix message id integer overflow.
412 - Fix pool worker removal in worker choice strategy internals.
413 - Fix package publication with pnpm.
415 ## [2.4.0-1] - 2023-04-03
419 - Add `LESS_BUSY` worker choice strategy.
423 - Optimize worker storage in pool.
424 - Optimize worker alive status check.
425 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
426 - Optimize `LESS_USED` worker choice strategy.
430 - Ensure trimmable characters are checked at pool initialization.
431 - Fix message id integer overflow.
432 - Fix pool worker removal in worker choice strategy internals.
434 ## [2.4.0-0] - 2023-04-03
438 - Add `LESS_BUSY` worker choice strategy.
442 - Optimize worker storage in pool.
443 - Optimize worker alive status check.
444 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
445 - Optimize `LESS_USED` worker choice strategy.
449 - Ensure trimmable characters are checked at pool initialization.
450 - Fix message id integer overflow.
451 - Fix pool worker removal in worker choice strategy internals.
453 ## [2.3.10] - 2023-03-18
457 - Fix `exports` syntax for ESM and CommonJS.
461 - Permit SemVer pre-release publication.
463 ## [2.3.10-2] - 2023-03-18
467 - Fix `exports` syntax for ESM and CommonJS.
469 ## [2.3.10-1] - 2023-03-18
473 - Permit SemVer pre-release publication.
475 ## [2.3.10-0] - 2023-03-18
479 - Fix `exports` syntax for ESM and CommonJS.
481 ## [2.3.9] - 2023-03-18
485 - Introduce ESM module support along with CommonJS one.
489 - Fix brown paper bag bug referencing the same object literal.
491 ## [2.3.8] - 2023-03-18
495 - Switch internal benchmarking code to benny.
496 - Switch to TypeScript 5.x.x.
497 - Switch rollup bundler plugins to core ones.
498 - Switch to TSDoc syntax.
499 - Enforce conventional commits.
503 - Fix random integer generator.
504 - Fix worker choice strategy pool type identification at initialization.
506 ## [2.3.7] - 2022-10-23
510 - Switch to open collective FOSS project funding platform.
511 - Switch to ts-standard linter configuration on TypeScript code.
515 - Fixed missing async on pool execute method.
516 - Fixed typing in TypeScript example.
517 - Fixed types in unit tests.
519 ## [2.3.6] - 2022-10-22
523 - Cleanup pool attributes and methods.
524 - Refine error types thrown.
528 - Fix continuous integration build on windows.
529 - Fix code coverage reporting by using c8 instead of nyc.
531 ## [2.3.5] - 2022-10-21
535 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
536 - Optimize tasks usage lookup implementation.
540 - Fix missed pool event emitter type export.
541 - Fix typedoc documentation generation.
543 ## [2.3.4] - 2022-10-17
547 - Fully automate release process with release-it.
551 - Optimize fair share task scheduling algorithm implementation.
552 - Update benchmarks versus external pools results with latest version.
554 ## [2.3.3] - 2022-10-15
558 - Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
560 ## [2.3.2] - 2022-10-14
564 - Optimize fair share worker selection strategy implementation.
568 - Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
570 ## [2.3.1] - 2022-10-13
574 - Pool worker choice strategies:
575 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
576 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
578 ## [2.2.2] - 2022-10-09
582 - Fixed `README.md` file.
584 ## [2.2.1] - 2022-10-08
588 - Dynamic worker choice strategy change at runtime.
590 ## [2.2.0] - 2022-01-05
594 - Support only NodeJS version 16.x.x for cluster pool: upstream cluster API have changed on that version.
596 ## [2.1.0] - 2021-08-29
600 - Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
604 - `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
605 - `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
606 - `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
607 - `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
609 ## [2.0.2] - 2021-05-12
613 - Fix `busy` event emission on fixed pool type
615 ## [2.0.1] - 2021-03-16
619 - Check if pool options are properly set.
620 - `busy` event is emitted on all pool types.
622 ## [2.0.0] - 2021-03-01
626 - Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
630 - `FullPool` event is now renamed to `busy`.
631 - `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
632 _Find more details on our JSDoc._
634 - `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
636 - We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
638 ### Pool options types declaration merge
640 `FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
642 #### New `export` strategy
646 const DynamicThreadPool = require('poolifier/lib/dynamic')
648 const { DynamicThreadPool } = require('poolifier/lib/dynamic')
651 But you should always prefer just using
654 const { DynamicThreadPool } = require('poolifier')
657 #### New type definitions for input data and response
659 For cluster worker and worker-thread pools, you can now only send and receive structured-cloneable data.
660 _This is not a limitation by poolifier but NodeJS._
662 #### Public property replacements
664 `numWorkers` property is now `numberOfWorkers`
666 #### Internal (protected) properties and methods renaming
668 These properties are not intended for end users
670 - `id` => `nextMessageId`
672 These methods are not intended for end users
674 - `_chooseWorker` => `chooseWorker`
675 - `_newWorker` => `createWorker`
676 - `_execute` => `internalExecute`
677 - `_chooseWorker` => `chooseWorker`
678 - `_checkAlive` => `checkAlive`
680 - `_runAsync` => `runAsync`
682 ## [1.1.0] - 2020-05-21
686 - ThreadWorker support async functions as option
687 - Various external library patches
689 ## [1.0.0] - 2020-01-24
693 - FixedThreadPool implementation
694 - DynamicThreadPool implementation
695 - WorkerThread implementation to improve developer experience