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