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