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