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