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