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