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