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