fix: fix worker choice strategies behavior
[poolifier.git] / CHANGELOG.md
1 # Changelog
2
3 All notable changes to this project will be documented in this file.
4
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).
7
8 ## [Unreleased]
9
10 ### Fixed
11
12 - Ensure dynamic worker node are initialized with sensible worker node usage default values to avoid worker choice strategies biased decisions.
13 - Account for tasks wait time in task execution time computation in worker choice strategies to avoid biased decisions under load with several prioritized task functions and tasks queue enabled.
14
15 ## [4.0.0] - 2024-04-30
16
17 ### Changed
18
19 - Support per task function(s) priority and worker choice strategy definition via a task function object: `{ taskFunction: (data?: Data) => Response | Promise<Response>, priority?: number, strategy?: WorkerChoiceStrategy }`.
20 - Add priority queue based tasks queueing. One priority queue is divided into prioritized buckets to avoid queued tasks starvation under load.
21 - BREAKING CHANGE: `listTaskFunctionNames()` to `listTaskFunctionsProperties()` in pool and worker API returning registered task functions properties.
22 - BREAKING CHANGE: `strategy` field in pool information renamed to `defaultStrategy`.
23
24 ### Fixed
25
26 - Ensure worker choice strategy options changes at runtime are propagated to poolifier workers.
27
28 ## [3.1.30] - 2024-04-22
29
30 ### Fixed
31
32 - Fix `transferList` argument type definition.
33
34 ## [3.1.29] - 2024-04-02
35
36 ### Fixed
37
38 - Fix possible race condition at worker node recreation on worker `error` and `exit` events.
39
40 ## [3.1.28] - 2024-04-01
41
42 ### Fixed
43
44 - Ensure the minimum number of workers on a started pool is guaranteed.
45
46 ## [3.1.27] - 2024-03-27
47
48 ### Fixed
49
50 - Fix publishing on JSR, take 4.
51
52 ## [3.1.26] - 2024-03-27
53
54 ### Fixed
55
56 - Fix publishing on JSR, take 3.
57
58 ## [3.1.25] - 2024-03-27
59
60 ### Fixed
61
62 - Fix publishing on JSR, take 2.
63
64 ## [3.1.24] - 2024-03-27
65
66 ### Fixed
67
68 - Fix publishing on JSR.
69
70 ## [3.1.23] - 2024-03-27
71
72 ### Changed
73
74 - Publish on JSR.
75
76 ## [3.1.22] - 2024-03-15
77
78 ### Fixed
79
80 - Fix pool event emitter registered callbacks removal at `destroy()`.
81
82 ## [3.1.21] - 2024-02-22
83
84 ### Fixed
85
86 - Fix null exception regression: [#1496](https://github.com/poolifier/poolifier/issues/1496).
87
88 ## [3.1.20] - 2024-02-11
89
90 ### Fixed
91
92 - Ensure `worker_threads` workers are unreferenced at termination.
93
94 ## [3.1.19] - 2024-01-16
95
96 ### Fixed
97
98 - Fix possible null exception at task finishing handling.
99
100 ### Changed
101
102 - Optimize Deque implementation to improve tasks queueing performance.
103
104 ## [3.1.18] - 2024-01-06
105
106 ### Fixed
107
108 - Fix dynamic pool with minimum number of workers set to zero: [#1748](https://github.com/poolifier/poolifier/issues/1748).
109
110 ## [3.1.17] - 2024-01-05
111
112 ### Changed
113
114 - Improve performance by clean up unneeded condition checks on hot code paths.
115
116 ## [3.1.16] - 2024-01-03
117
118 ### Fixed
119
120 - Add missing type to TS type definitions.
121
122 ## [3.1.15] - 2024-01-02
123
124 ### Fixed
125
126 - Fix CommonJS support with TypeScript: [#1821](https://github.com/poolifier/poolifier/issues/1821).
127
128 ## [3.1.15-0] - 2024-01-02
129
130 ### Fixed
131
132 - Fix CommonJS support with TypeScript: [#1821](https://github.com/poolifier/poolifier/issues/1821).
133
134 ## [3.1.14] - 2024-01-01
135
136 ### Fixed
137
138 - Properly handle dynamic pool with zero minimum size.
139
140 ## [3.1.13] - 2023-12-30
141
142 ### Changed
143
144 - Reduce branching in several hot code paths.
145 - Use faster object cloning implementation.
146
147 ## [3.1.12] - 2023-12-27
148
149 ### Fixed
150
151 - Fix tasks redistribution triggers at pool destroying.
152
153 ### Changed
154
155 - Switch TypeScript module resolution to Node16.
156
157 ## [3.1.12-0] - 2023-12-27
158
159 ### Fixed
160
161 - Fix tasks redistribution triggers at pool destroying.
162
163 ## [3.1.11] - 2023-12-24
164
165 ### Fixed
166
167 - Avoid worker node cross tasks stealing.
168 - Ensure only half the pool worker nodes can steal tasks.
169
170 ## [3.1.10] - 2023-12-23
171
172 ### Changed
173
174 - Avoid useless branching on pool type.
175
176 ## [3.1.9] - 2023-12-22
177
178 ### Changed
179
180 - Readd ThreadPoolOptions and ClusterPoolOptions TS type aliases to PoolOptions.
181
182 ## [3.1.8] - 2023-12-21
183
184 ### Fixed
185
186 - Fix default worker weight computation.
187 - Fix possible null exception at pool destroying.
188
189 ## [3.1.7] - 2023-12-20
190
191 ### Fixed
192
193 - Ensure worker choice strategies implementation wait for worker node readiness: [#1748](https://github.com/poolifier/poolifier/issues/1748).
194
195 ## [3.1.6] - 2023-12-18
196
197 ### Fixed
198
199 - Fix pool destroying with tasks queuing enabled.
200
201 ## [3.1.5] - 2023-12-18
202
203 ### Added
204
205 - Add queued tasks end timeout support to worker node termination.
206
207 ## [3.1.4] - 2023-12-18
208
209 ### Fixed
210
211 - Make more robust the fix for possible null exception at handling task execution response.
212
213 ## [3.1.3] - 2023-12-17
214
215 ### Fixed
216
217 - Fix possible null exception at handling task execution response.
218
219 ## [3.1.2] - 2023-12-17
220
221 ### Fixed
222
223 - Wait for queued tasks to end at worker node termination.
224
225 ## [3.1.1] - 2023-12-16
226
227 ### Fixed
228
229 - Fix pool options TS type definition.
230
231 ## [3.1.0] - 2023-12-16
232
233 ### Changed
234
235 - TypeScript breaking change: merge ThreadPoolOptions and ClusterPoolOptions types into PoolOptions type.
236
237 ## [3.0.14] - 2023-12-13
238
239 ### Fixed
240
241 - Fix possible null exception with worker_threads pools.
242
243 ## [3.0.13] - 2023-12-12
244
245 ### Fixed
246
247 - Ensure worker choice strategy wait for worker nodes readiness.
248
249 ### Changed
250
251 - Remove infinite retries support in worker choice strategy to avoid configuration leading to possible infinite recursion or loop.
252
253 ## [3.0.12] - 2023-12-12
254
255 ### Changed
256
257 - Add infinite retries support in worker choice strategy.
258
259 ## [3.0.11] - 2023-12-11
260
261 ### Fixed
262
263 - Ensure pool asynchronous resource properly track tasks execution.
264
265 ## [3.0.10] - 2023-12-08
266
267 ### Changed
268
269 - Add a fastpath when tasks stealing or redistribution is impossible.
270
271 ## [3.0.9] - 2023-11-26
272
273 ### Fixed
274
275 - Remove all pool events listener at pool destroying.
276 - Remove all worker node events listener at worker node destroying.
277 - Fix worker node event emitter listeners handling memory leak at pool options runtime change.
278
279 ## [3.0.8] - 2023-11-25
280
281 ### Fixed
282
283 - Ensure continuous tasks stealing on idle start at worker node idling.
284
285 ## [3.0.7] - 2023-11-24
286
287 ### Changed
288
289 - Make continuous tasks stealing start at worker node idling.
290
291 ## [3.0.6] - 2023-11-24
292
293 ### Fixed
294
295 - Ensure pool statuses are checked at initialization, `start()` or `destroy()`.
296 - Ensure pool `ready` event can be emitted after several `start()/destroy()` cycles.
297
298 ## [3.0.5] - 2023-10-27
299
300 ### Fixed
301
302 - Ensure pool `ready` event can be emitted only once.
303
304 ## [3.0.4] - 2023-10-20
305
306 ### Changed
307
308 - Switch to Bencher for benchmarking: [https://bencher.dev/perf/poolifier](https://bencher.dev/perf/poolifier).
309 - Use builtin retry mechanism in worker choice strategies instead of custom one.
310
311 ## [3.0.3] - 2023-10-19
312
313 ### Fixed
314
315 - Avoid null exception at sending message to worker.
316 - Avoid null exception at checking worker node readiness.
317
318 ## [3.0.2] - 2023-10-17
319
320 ### Fixed
321
322 - Fix race condition at dynamic worker node task assignment and scheduled removal. See issue [#1468](https://github.com/poolifier/poolifier/issues/1468) and [#1496](https://github.com/poolifier/poolifier/issues/1496).
323
324 ## [3.0.1] - 2023-10-16
325
326 ### Fixed
327
328 - Workaround possible race condition at work nodes array element removal and querying. See issue [#1468](https://github.com/poolifier/poolifier/issues/1468).
329
330 ### Changed
331
332 - Switch the worker node eventing code to `EventTarget` API.
333
334 ## [3.0.0] - 2023-10-08
335
336 ### Changed
337
338 - Remove Node.js 16.x.x (EOL) support.
339
340 ## [2.7.5] - 2023-10-03
341
342 ### Changed
343
344 - Use `EventEmitterAsyncResource` type from `@types/node` for pool event emitter. TypeScript users will need to update to latest `@types/node` version.
345
346 ## [2.7.4] - 2023-09-25
347
348 ### Fixed
349
350 - Fix source maps (bundler issue).
351
352 ## [2.7.3] - 2023-09-24
353
354 ### Changed
355
356 - Convert pool event emitter to event emitter async resource.
357
358 ## [2.7.2] - 2023-09-23
359
360 ### Changed
361
362 - Add source maps to npm package to ease debugging.
363
364 ### Added
365
366 - Continuous benchmarking versus other worker pools: [https://poolifier.github.io/benchmark](https://poolifier.github.io/benchmark).
367
368 ## [2.7.1] - 2023-09-20
369
370 ### Fixed
371
372 - Ensure worker message listener used one time are removed after usage.
373
374 ## [2.7.0] - 2023-09-19
375
376 ### Fixed
377
378 - Fix task stealing related tasks queue options handling at runtime.
379
380 ### Changed
381
382 - Rename `listTaskFunctions()` to `listTaskFunctionNames()` in pool and worker API.
383
384 ### Added
385
386 - Add `hasTaskFunction()`, `addTaskFunction()`, `removeTaskFunction()`, `setDefaultTaskFunction()` methods to pool API: [PR #1148](https://github.com/poolifier/poolifier/pull/1148).
387 - Stricter worker constructor arguments validation.
388
389 ## [2.6.45] - 2023-09-17
390
391 ### Changed
392
393 - Disable publication on GitHub packages registry on release until authentication issue is fixed.
394
395 ### Added
396
397 - Add `startWorkers` to pool options to whether start the minimum number of workers at pool initialization or not.
398 - Add `start()` method to pool API to start the minimum number of workers.
399 - Add `taskStealing` and `tasksStealingOnPressure` to tasks queue options to whether enable task stealing or not and whether enable tasks stealing under back pressure or not.
400 - Continuous internal benchmarking: [https://poolifier.github.io/benchmark-results/dev/bench](https://poolifier.github.io/benchmark-results/dev/bench).
401
402 ## [2.6.44] - 2023-09-08
403
404 ### Fixed
405
406 - Use a dedicated PAT to publish on GitHub packages registry.
407
408 ### Added
409
410 - Publish on GitHub packages registry on release.
411
412 ### Changed
413
414 - Switch from rome to biome: [PR #1128](https://github.com/poolifier/poolifier/pull/1128).
415
416 ## [2.6.43] - 2023-09-08
417
418 ### Added
419
420 - Publish on GitHub packages registry on release.
421
422 ### Changed
423
424 - Switch from rome to biome: [PR #1128](https://github.com/poolifier/poolifier/pull/1128).
425
426 ## [2.6.42] - 2023-09-06
427
428 ### Changed
429
430 - Optimize hot code paths implementation: avoid unnecessary branching, add and use optimized helpers (min, max), use reduce() array helper, ...
431
432 ## [2.6.41] - 2023-09-03
433
434 ### Changed
435
436 - Optimize worker choice strategies implementation.
437
438 ## [2.6.40] - 2023-09-01
439
440 ### Fixed
441
442 - Do not pre-choose in WRR worker choice strategy to avoid bias.
443 - Avoid array out of bound in worker choice strategies after worker node removal.
444
445 ## [2.6.39] - 2023-08-30
446
447 ### Fixed
448
449 - Fix race condition in worker choice strategies at worker node info querying while not yet initialized.
450
451 ## [2.6.38] - 2023-08-30
452
453 ### Added
454
455 - Bundle typescript types declaration into one file.
456
457 ### Changed
458
459 - Improve interleaved weighted round robin worker choice strategy implementation.
460
461 ## [2.6.37] - 2023-08-28
462
463 ### Fixed
464
465 - Ensure unused worker usage statistics are deleted at runtime.
466
467 ### Changed
468
469 - Rename worker choice strategy options `choiceRetries` to `retries`.
470 - Avoid unnecessary branching in worker choice strategies.
471
472 ## [2.6.36] - 2023-08-27
473
474 ### Fixed
475
476 - Fix pool `execute()` arguments check.
477
478 ### Changed
479
480 - Make continuous tasks stealing algorithm less aggressive.
481 - Fine tune tasks stealing algorithm under back pressure.
482
483 ## [2.6.35] - 2023-08-25
484
485 ### Fixed
486
487 - Don't account worker usage statistics for tasks that have failed.
488 - Fix pool information runtime and wait time median computation.
489
490 ### Changed
491
492 - Update simple moving average implementation to use a circular buffer.
493 - Update simple moving median implementation to use a circular buffer.
494 - Account for stolen tasks in worker usage statistics and pool information.
495
496 ### Added
497
498 - Continuous tasks stealing algorithm.
499
500 ## [2.6.34] - 2023-08-24
501
502 ### Fixes
503
504 - Avoid cascading tasks stealing under back pressure.
505
506 ### Changed
507
508 - Add fastpath to queued tasks rescheduling.
509
510 ## [2.6.33] - 2023-08-24
511
512 ### Fixed
513
514 - Fix queued tasks rescheduling.
515
516 ### Changed
517
518 - Rename tasks queue options `queueMaxSize` to `size`.
519
520 ### Added
521
522 - Task stealing scheduling algorithm if tasks queueing is enabled.
523
524 ## [2.6.32] - 2023-08-23
525
526 ### Fixed
527
528 - Ensure no task can be executed when the pool is destroyed.
529
530 ### Added
531
532 - Add `queueMaxSize` option to tasks queue options.
533 - Add O(1) deque implementation implemented with doubly linked list and use it for tasks queueing.
534 - Add tasks stealing algorithm when a worker node queue is back pressured if tasks queueing is enabled.
535
536 ## [2.6.31] - 2023-08-20
537
538 ### Fixed
539
540 - Fix worker choice strategy retries mechanism in some edge cases.
541
542 ### Changed
543
544 - Make orthogonal worker choice strategies tasks distribution and created dynamic worker usage.
545 - Remove the experimental status of the `LEAST_ELU` worker choice strategy.
546
547 ## [2.6.30] - 2023-08-19
548
549 ### Fixed
550
551 - Ensure pool event `backPressure` is emitted.
552 - Ensure pool event `full` is emitted only once.
553 - Ensure worker node cannot be instantiated without proper arguments.
554
555 ## [2.6.29] - 2023-08-18
556
557 ### Fixed
558
559 - Fix race condition between readiness and task functions worker message handling at startup.
560 - Fix duplicate task function worker usage statistics computation per task function.
561 - Update task function worker usage statistics if and only if there's at least two different task functions.
562 - Fix race condition at task function worker usage executing task computation leading to negative value.
563
564 ### Added
565
566 - Add back pressure detection on the worker node queue. Event `backPressure` is emitted when all worker node queues are full (worker node queue size >= poolMaxSize^2).
567 - Use back pressure detection in worker choice strategies.
568 - Add worker choice strategies retries mechanism if no worker is eligible.
569
570 ## [2.6.28] - 2023-08-16
571
572 ### Fixed
573
574 - Ensure pool workers are properly initialized.
575
576 ### Added
577
578 - HTTP server pool examples: express-cluster, express-hybrid.
579
580 ### Changed
581
582 - Remove now useless branching in worker hot code path.
583
584 ## [2.6.27] - 2023-08-15
585
586 ### Fixed
587
588 - Add `KillHandler` type definition to exported types.
589
590 ### Added
591
592 - Add `destroy` event to pool API.
593
594 ## [2.6.26] - 2023-08-15
595
596 ### Added
597
598 - Add kill handler to worker options allowing to execute custom code when worker is killed.
599 - Add `listTaskFunctions()` method to pool API.
600 - SMTP client pool example: nodemailer.
601
602 ## [2.6.25] - 2023-08-13
603
604 ### Added
605
606 - HTTP server pool examples: fastify-cluster, fastify-hybrid.
607 - WebSocket server pool examples: ws-cluster, ws-hybrid.
608
609 ## [2.6.24] - 2023-08-12
610
611 ### Added
612
613 - Add array of transferable objects to the `execute()` method arguments.
614 - WebSocket server pool examples: ws-worker_threads.
615
616 ## [2.6.23] - 2023-08-11
617
618 ### Fixed
619
620 - Fix pool busyness semantic when tasks queueing is enabled: the pool is busy when the number of executing tasks on each worker has reached the maximum tasks concurrency per worker.
621
622 ### Added
623
624 - HTTP client pool examples: fetch, node-fetch and axios with multiple task functions.
625 - HTTP server pool examples: express-worker_threads, fastify-worker_threads.
626
627 ## [2.6.22] - 2023-08-10
628
629 ### Fixed
630
631 - Add missing `types` field to package.json `exports`.
632
633 ### Changed
634
635 - Structure markdown documentation (PR #811).
636
637 ## [2.6.21] - 2023-08-03
638
639 ### Changed
640
641 - Improve code documentation.
642 - Code refactoring and cleanup for better maintainability and readability.
643
644 ## [2.6.20] - 2023-07-21
645
646 ### Fixed
647
648 - Fix queued tasks redistribution on error task execution starvation.
649 - Ensure tasks queueing per worker condition is untangled from the pool busyness semantic.
650
651 ### Changed
652
653 - Drastically reduce lookups by worker in the worker nodes.
654
655 ## [2.6.19] - 2023-07-20
656
657 ### Added
658
659 - Dedicated internal communication channel for worker_threads pools.
660
661 ## [2.6.18] - 2023-07-19
662
663 ### Changed
664
665 - Code refactoring and cleanup for better maintainability and readability. Bundle size is a bit smaller.
666
667 ## [2.6.17] - 2023-07-16
668
669 ### Added
670
671 - Add `listTaskFunctions()` method to worker API.
672
673 ## [2.6.16] - 2023-07-12
674
675 ### Fixed
676
677 - Fix pool startup detection.
678 - Fix worker task functions handling.
679
680 ## [2.6.15] - 2023-07-11
681
682 ### Added
683
684 - Take into account worker node readiness in worker choice strategies.
685
686 ## [2.6.14] - 2023-07-10
687
688 ### Fixed
689
690 - Fix task function statistics tracking.
691
692 ## [2.6.13] - 2023-07-10
693
694 ### Added
695
696 - Add per task function statistics tracking.
697 - Add public methods to manipulate the worker task functions at runtime.
698
699 ## [2.6.12] - 2023-07-09
700
701 ### Fixed
702
703 - Workaround import issue with `node:os` module in node 16.x.x.
704
705 ## [2.6.11] - 2023-07-09
706
707 ### Fixed
708
709 - Fix pool readiness semantic.
710
711 ## [2.6.10] - 2023-07-08
712
713 ### Fixed
714
715 - Ensure workers are not recreated on error at pool startup.
716
717 ### Added
718
719 - Add `ready` and `strategy` fields to pool information.
720 - Add pool event `ready` to notify when the number of workers created in the pool has reached the maximum size expected and are ready.
721 - Add dynamic pool sizing checks.
722
723 ## [2.6.9] - 2023-07-07
724
725 ### Fixed
726
727 - Recreate the right worker type on uncaught exception.
728
729 ### Added
730
731 - Add minimum and maximum to internal measurement statistics.
732 - Add `runTime` and `waitTime` to pool information.
733 - Check worker inactive time only on dynamic worker.
734
735 ## [2.6.8] - 2023-07-03
736
737 ### Fixed
738
739 - Brown paper bag release to fix version handling in pool information.
740
741 ## [2.6.7] - 2023-07-03
742
743 ### Fixed
744
745 - Ensure worker queued tasks at error are reassigned to other pool workers.
746
747 ### Added
748
749 - Add pool `utilization` ratio to pool information.
750 - Add `version` to pool information.
751 - Add worker information to worker nodes.
752
753 ## [2.6.6] - 2023-07-01
754
755 ### Added
756
757 - Add safe helper `availableParallelism()` to help sizing the pool.
758
759 ### Fixed
760
761 - Ensure message handler is only registered in worker.
762
763 ## [2.6.5] - 2023-06-27
764
765 ### Known issues
766
767 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
768
769 ### Fixed
770
771 - Artificial version bump to 2.6.5 to workaround publication issue.
772 - Ensure cluster pool `destroy()` gracefully shutdowns worker's server.
773 - Ensure pool event is emitted before task error promise rejection.
774 - Fix queued tasks count computation.
775
776 ### Removed
777
778 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
779
780 ## [2.6.4] - 2023-06-27
781
782 ### Known issues
783
784 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
785
786 ### Fixed
787
788 - Ensure cluster pool `destroy()` gracefully shutdowns worker's server.
789 - Ensure pool event is emitted before task error promise rejection.
790 - Fix queued tasks count computation.
791
792 ### Removed
793
794 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
795
796 ## [2.6.3] - 2023-06-19
797
798 ### Fixed
799
800 - Ensure no tasks are queued when trying to soft kill a dynamic worker.
801 - Update strategies internals after statistics computation.
802
803 ### Changed
804
805 - Optimize O(1) queue implementation.
806
807 ## [2.6.2] - 2023-06-12
808
809 ### Fixed
810
811 - Fix new worker use after creation in dynamic pool given the current worker choice strategy.
812
813 ## [2.6.1] - 2023-06-10
814
815 ### Added
816
817 - Add worker choice strategy documentation: [README.md](./docs/worker-choice-strategies.md).
818
819 ### Fixed
820
821 - Fix average statistics computation: ensure failed tasks are not accounted.
822
823 ## [2.6.0] - 2023-06-09
824
825 ### Added
826
827 - Add `LEAST_ELU` worker choice strategy (experimental).
828 - Add tasks ELU instead of runtime support to `FAIR_SHARE` worker choice strategy.
829
830 ### Changed
831
832 - Refactor pool worker node usage internals.
833 - Breaking change: refactor worker choice strategy statistics requirements: the syntax of the worker choice strategy options has changed.
834 - Breaking change: pool information `info` property object fields have been renamed.
835
836 ### Fixed
837
838 - Fix wait time accounting.
839 - Ensure worker choice strategy `LEAST_BUSY` accounts also tasks wait time.
840 - Ensure worker choice strategy `LEAST_USED` accounts also queued tasks.
841
842 ## [2.5.4] - 2023-06-07
843
844 ### Added
845
846 - Add Event Loop Utilization (ELU) statistics to worker tasks usage.
847
848 ### Changed
849
850 - Compute statistics at the worker level only if needed.
851 - Add `worker_threads` options to thread pool options.
852
853 ### Fixed
854
855 - Make the `LEAST_BUSY` strategy only relies on task runtime.
856
857 ## [2.5.3] - 2023-06-04
858
859 ### Changed
860
861 - Refine pool information content.
862 - Limit pool internals public exposure.
863
864 ## [2.5.2] - 2023-06-02
865
866 ### Added
867
868 - Add `taskError` pool event for task execution error.
869 - Add pool information `info` property to pool.
870 - Emit pool information on `busy` and `full` pool events.
871
872 ## [2.5.1] - 2023-06-01
873
874 ### Added
875
876 - Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
877 - Add `error` pool event for uncaught worker error.
878
879 ## [2.5.0] - 2023-05-31
880
881 ### Added
882
883 - Switch pool event emitter to `EventEmitterAsyncResource`.
884 - Add tasks wait time accounting in per worker tasks usage.
885 - Add interleaved weighted round robin `INTERLEAVED_WEIGHTED_ROUND_ROBIN` worker choice strategy (experimental).
886
887 ### Changed
888
889 - Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
890
891 ## [2.4.14] - 2023-05-09
892
893 ### Fixed
894
895 - Ensure no undefined task runtime can land in the tasks history.
896 - Fix median computation implementation once again.
897
898 ### Added
899
900 - Unit tests for median and queue implementations.
901
902 ## [2.4.13] - 2023-05-08
903
904 ### Fixed
905
906 - Fix worker choice strategy options validation.
907 - Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
908
909 ## [2.4.12] - 2023-05-06
910
911 ### Added
912
913 - Support multiple task functions per worker.
914 - Add custom worker weights support to worker choice strategies options.
915
916 ### Changed
917
918 - Use O(1) queue implementation for tasks queueing.
919
920 ### Fixed
921
922 - Fix median computation implementation.
923 - Fix fair share worker choice strategy internals update.
924
925 ## [2.4.11] - 2023-04-23
926
927 ### Changed
928
929 - Optimize free worker finding in worker choice strategies.
930
931 ## [2.4.10] - 2023-04-15
932
933 ### Fixed
934
935 - Fix typescript type definition for task function: ensure the input data is optional.
936 - Fix typescript type definition for pool execute(): ensure the input data is optional.
937
938 ## [2.4.9] - 2023-04-15
939
940 ### Added
941
942 - Add tasks queue enablement runtime setter to pool.
943 - Add tasks queue options runtime setter to pool.
944 - Add worker choice strategy options runtime setter to pool.
945
946 ### Changed
947
948 - Remove the tasks queuing experimental status.
949
950 ### Fixed
951
952 - Fix task function type definition and validation.
953 - Fix worker choice strategy options handling.
954
955 ## [2.4.8] - 2023-04-12
956
957 ### Fixed
958
959 - Fix message between main worker and worker type definition for tasks.
960 - Fix code documentation.
961
962 ## [2.4.7] - 2023-04-11
963
964 ### Added
965
966 - Add worker tasks queue options to pool options.
967
968 ### Fixed
969
970 - Fix missing documentation.
971
972 ## [2.4.6] - 2023-04-10
973
974 ### Fixed
975
976 - Ensure one task at a time is executed per worker with tasks queueing enabled.
977 - Properly count worker executing tasks with tasks queueing enabled.
978
979 ## [2.4.5] - 2023-04-09
980
981 ### Added
982
983 - Use monotonic high resolution timer for worker tasks runtime.
984 - Add worker tasks median runtime to statistics.
985 - Add worker tasks queue (experimental).
986
987 ## [2.4.4] - 2023-04-07
988
989 ### Added
990
991 - Add `PoolEvents` enumeration and `PoolEvent` type.
992
993 ### Fixed
994
995 - Destroy worker only on alive check.
996
997 ## [2.4.3] - 2023-04-07
998
999 ### Fixed
1000
1001 - Fix typedoc generation with inheritance.
1002
1003 ## [2.4.2] - 2023-04-06
1004
1005 ### Added
1006
1007 - Add `full` event to dynamic pool.
1008 - Keep worker choice strategy in memory for conditional reuse.
1009
1010 ### Fixed
1011
1012 - Fix possible negative worker key at worker removal in worker choice strategies.
1013
1014 ## [2.4.1] - 2023-04-05
1015
1016 ### Changed
1017
1018 - Optimize worker choice strategy for dynamic pool.
1019
1020 ### Fixed
1021
1022 - Ensure dynamic pool does not alter worker choice strategy expected behavior.
1023
1024 ## [2.4.0] - 2023-04-04
1025
1026 ### Added
1027
1028 - Add `LESS_BUSY` worker choice strategy.
1029
1030 ### Changed
1031
1032 - Optimize worker storage in pool.
1033 - Optimize worker alive status check.
1034 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
1035 - Optimize `LESS_USED` worker choice strategy.
1036 - Update benchmark versus external threads pools.
1037 - Optimize tasks usage statistics requirements for worker choice strategy.
1038
1039 ### Fixed
1040
1041 - Ensure trimmable characters are checked at pool initialization.
1042 - Fix message id integer overflow.
1043 - Fix pool worker removal in worker choice strategy internals.
1044 - Fix package publication with pnpm.
1045
1046 ## [2.4.0-3] - 2023-04-04
1047
1048 ### Added
1049
1050 - Add `LESS_BUSY` worker choice strategy.
1051
1052 ### Changed
1053
1054 - Optimize worker storage in pool.
1055 - Optimize worker alive status check.
1056 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
1057 - Optimize `LESS_USED` worker choice strategy.
1058 - Update benchmark versus external threads pools.
1059
1060 ### Fixed
1061
1062 - Ensure trimmable characters are checked at pool initialization.
1063 - Fix message id integer overflow.
1064 - Fix pool worker removal in worker choice strategy internals.
1065 - Fix package publication with pnpm.
1066
1067 ## [2.4.0-2] - 2023-04-03
1068
1069 ### Added
1070
1071 - Add `LESS_BUSY` worker choice strategy.
1072
1073 ### Changed
1074
1075 - Optimize worker storage in pool.
1076 - Optimize worker alive status check.
1077 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
1078 - Optimize `LESS_USED` worker choice strategy.
1079
1080 ### Fixed
1081
1082 - Ensure trimmable characters are checked at pool initialization.
1083 - Fix message id integer overflow.
1084 - Fix pool worker removal in worker choice strategy internals.
1085 - Fix package publication with pnpm.
1086
1087 ## [2.4.0-1] - 2023-04-03
1088
1089 ### Added
1090
1091 - Add `LESS_BUSY` worker choice strategy.
1092
1093 ### Changed
1094
1095 - Optimize worker storage in pool.
1096 - Optimize worker alive status check.
1097 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
1098 - Optimize `LESS_USED` worker choice strategy.
1099
1100 ### Fixed
1101
1102 - Ensure trimmable characters are checked at pool initialization.
1103 - Fix message id integer overflow.
1104 - Fix pool worker removal in worker choice strategy internals.
1105
1106 ## [2.4.0-0] - 2023-04-03
1107
1108 ### Added
1109
1110 - Add `LESS_BUSY` worker choice strategy.
1111
1112 ### Changed
1113
1114 - Optimize worker storage in pool.
1115 - Optimize worker alive status check.
1116 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
1117 - Optimize `LESS_USED` worker choice strategy.
1118
1119 ### Fixed
1120
1121 - Ensure trimmable characters are checked at pool initialization.
1122 - Fix message id integer overflow.
1123 - Fix pool worker removal in worker choice strategy internals.
1124
1125 ## [2.3.10] - 2023-03-18
1126
1127 ### Fixed
1128
1129 - Fix package.json `exports` syntax for ESM and CommonJS.
1130
1131 ### Changed
1132
1133 - Permit SemVer pre-release publication.
1134
1135 ## [2.3.10-2] - 2023-03-18
1136
1137 ### Fixed
1138
1139 - Fix package.json `exports` syntax for ESM and CommonJS.
1140
1141 ## [2.3.10-1] - 2023-03-18
1142
1143 ### Changed
1144
1145 - Permit SemVer pre-release publication.
1146
1147 ## [2.3.10-0] - 2023-03-18
1148
1149 ### Fixed
1150
1151 - Fix package.json `exports` syntax for ESM and CommonJS.
1152
1153 ## [2.3.9] - 2023-03-18
1154
1155 ### Changed
1156
1157 - Introduce ESM module support along with CommonJS one.
1158
1159 ### Fixed
1160
1161 - Fix brown paper bag bug referencing the same object literal.
1162
1163 ## [2.3.8] - 2023-03-18
1164
1165 ### Changed
1166
1167 - Switch internal benchmarking code to benny.
1168 - Switch to TypeScript 5.x.x.
1169 - Switch rollup bundler plugins to core ones.
1170 - Switch to TSDoc syntax.
1171 - Enforce conventional commits.
1172
1173 ### Fixed
1174
1175 - Fix random integer generator.
1176 - Fix worker choice strategy pool type identification at initialization.
1177
1178 ## [2.3.7] - 2022-10-23
1179
1180 ### Changed
1181
1182 - Switch to open collective FOSS project funding platform.
1183 - Switch to ts-standard linter configuration on TypeScript code.
1184
1185 ### Fixed
1186
1187 - Fixed missing async on pool execute method.
1188 - Fixed typing in TypeScript example.
1189 - Fixed types in unit tests.
1190
1191 ## [2.3.6] - 2022-10-22
1192
1193 ### Changed
1194
1195 - Cleanup pool attributes and methods.
1196 - Refine error types thrown.
1197
1198 ### Fixed
1199
1200 - Fix continuous integration build on windows.
1201 - Fix code coverage reporting by using c8 instead of nyc.
1202
1203 ## [2.3.5] - 2022-10-21
1204
1205 ### Changed
1206
1207 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
1208 - Optimize tasks usage lookup implementation.
1209
1210 ### Fixed
1211
1212 - Fix missed pool event emitter type export.
1213 - Fix typedoc documentation generation.
1214
1215 ## [2.3.4] - 2022-10-17
1216
1217 ### Added
1218
1219 - Fully automate release process with release-it.
1220
1221 ### Changed
1222
1223 - Optimize fair share task scheduling algorithm implementation.
1224 - Update benchmark versus external pools results with latest version.
1225
1226 ## [2.3.3] - 2022-10-15
1227
1228 ### Added
1229
1230 - Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
1231
1232 ## [2.3.2] - 2022-10-14
1233
1234 ### Changed
1235
1236 - Optimize fair share worker selection strategy implementation.
1237
1238 ### Fixed
1239
1240 - Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
1241
1242 ## [2.3.1] - 2022-10-13
1243
1244 ### Added
1245
1246 - Pool worker choice strategies:
1247 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
1248 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
1249
1250 ## [2.2.2] - 2022-10-09
1251
1252 ### Fixed
1253
1254 - Fixed `README.md` file.
1255
1256 ## [2.2.1] - 2022-10-08
1257
1258 ### Added
1259
1260 - Dynamic worker choice strategy change at runtime.
1261
1262 ## [2.2.0] - 2022-01-05
1263
1264 ### Breaking Changes
1265
1266 - Support only Node.js version 16.x.x for cluster pool: upstream cluster API have changed on that version.
1267
1268 ## [2.1.0] - 2021-08-29
1269
1270 ### Added
1271
1272 - Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
1273
1274 ### Breaking Changes
1275
1276 - `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
1277 - `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
1278 - `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
1279 - `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
1280
1281 ## [2.0.2] - 2021-05-12
1282
1283 ### Bug fixes
1284
1285 - Fix `busy` event emission on fixed pool type
1286
1287 ## [2.0.1] - 2021-03-16
1288
1289 ### Bug fixes
1290
1291 - Check if pool options are properly set.
1292 - `busy` event is emitted on all pool types.
1293
1294 ## [2.0.0] - 2021-03-01
1295
1296 ### Bug fixes
1297
1298 - Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
1299
1300 ### Breaking Changes
1301
1302 - `FullPool` event is now renamed to `busy`.
1303 - `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
1304 _Find more details on our JSDoc._
1305
1306 - `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
1307
1308 - We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
1309
1310 ### Pool options types declaration merge
1311
1312 `FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
1313
1314 #### New `export` strategy
1315
1316 ```js
1317 // Before
1318 const DynamicThreadPool = require('poolifier/lib/dynamic')
1319 // After
1320 const { DynamicThreadPool } = require('poolifier/lib/dynamic')
1321 ```
1322
1323 But you should always prefer just using
1324
1325 ```js
1326 const { DynamicThreadPool } = require('poolifier')
1327 ```
1328
1329 #### New type definitions for input data and response
1330
1331 For cluster worker and worker-thread pools, you can now only send and receive structured-cloneable data.
1332 _This is not a limitation by poolifier but Node.js._
1333
1334 #### Public property replacements
1335
1336 `numWorkers` property is now `numberOfWorkers`
1337
1338 #### Internal (protected) properties and methods renaming
1339
1340 These properties are not intended for end users
1341
1342 - `id` => `nextMessageId`
1343
1344 These methods are not intended for end users
1345
1346 - `_chooseWorker` => `chooseWorker`
1347 - `_newWorker` => `createWorker`
1348 - `_execute` => `internalExecute`
1349 - `_chooseWorker` => `chooseWorker`
1350 - `_checkAlive` => `checkAlive`
1351 - `_run` => `run`
1352 - `_runAsync` => `runAsync`
1353
1354 ## [1.1.0] - 2020-05-21
1355
1356 ### Added
1357
1358 - ThreadWorker support async functions as option
1359 - Various external library patches
1360
1361 ## [1.0.0] - 2020-01-24
1362
1363 ### Added
1364
1365 - FixedThreadPool implementation
1366 - DynamicThreadPool implementation
1367 - WorkerThread implementation to improve developer experience