feat: worker node readiness aware worker choice strategies
[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
JB
8## [Unreleased]
9
19dbc45b
JB
10### Added
11
12- Take into account worker node readiness in worker choice strategies.
13
4a0db581
JB
14## [2.6.14] - 2023-07-10
15
87e44747
JB
16### Fixed
17
18- Fix task function statistics tracking.
19
0265272f
JB
20## [2.6.13] - 2023-07-10
21
968a2e8c
JB
22### Added
23
24- Add per task function statistics tracking.
782299f8 25- Add public methods to manipulate the worker task functions at runtime.
968a2e8c 26
44c8c00f
JB
27## [2.6.12] - 2023-07-09
28
aa4bf4b2
JB
29### Fixed
30
31- Workaround import issue with `node:os` module in node 16.x.x.
32
b7cfced1
JB
33## [2.6.11] - 2023-07-09
34
d5024c00
JB
35### Fixed
36
37- Fix pool readiness semantic.
38
f313a208
JB
39## [2.6.10] - 2023-07-08
40
2431bdb4
JB
41### Fixed
42
43- Ensure workers are not recreated on error at pool startup.
44
45### Added
46
47- Add `ready` and `strategy` fields to pool information.
48- 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 49- Add dynamic pool sizing checks.
2431bdb4 50
369d0a51
JB
51## [2.6.9] - 2023-07-07
52
2845f2a5
JB
53### Fixed
54
55- Recreate the right worker type on uncaught exception.
56
57### Added
58
59- Add minimum and maximum to internal measurement statistics.
1dcf8b7b 60- Add `runTime` and `waitTime` to pool information.
75d3401a 61- Check worker inactive time only on dynamic worker.
2845f2a5 62
fc97d613
JB
63## [2.6.8] - 2023-07-03
64
92b1feaa
JB
65### Fixed
66
67- Brown paper bag release to fix version handling in pool information.
68
52d54060
JB
69## [2.6.7] - 2023-07-03
70
5bc91f3e
JB
71### Fixed
72
73- Ensure worker queued tasks at error are reassigned to other pool workers.
74
afe0d5bf
JB
75### Added
76
77- Add pool `utilization` ratio to pool information.
23ccf9d7 78- Add `version` to pool information.
e5b3047d 79- Add worker information to worker nodes.
afe0d5bf 80
f42c583f
JB
81## [2.6.6] - 2023-07-01
82
6961ca9a
JB
83### Added
84
85- Add safe helper `availableParallelism` to help sizing the pool.
86
3749facb
JB
87### Fixed
88
89- Ensure message handler is only registered in worker.
90
6fed2513
JB
91## [2.6.5] - 2023-06-27
92
c72f6987
JB
93### Known issues
94
70726c28 95- Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
c72f6987
JB
96
97### Fixed
98
99- Artificial version bump to 2.6.5 to workaround publication issue.
100- Ensure cluster pool destroy() gracefully shutdowns worker's server.
101- Ensure pool event is emitted before task error promise rejection.
102- Fix queued tasks count computation.
103
104### Removed
105
106- Remove unneeded worker-threads worker `MessageChannel` internal usage for IPC.
107
6426631b
JB
108## [2.6.4] - 2023-06-27
109
941f9a7c
JB
110### Known issues
111
70726c28 112- Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
941f9a7c 113
2c039e43
JB
114### Fixed
115
116- Ensure cluster pool destroy() gracefully shutdowns worker's server.
117- Ensure pool event is emitted before task error promise rejection.
9c16fb4b 118- Fix queued tasks count computation.
2c039e43 119
941f9a7c
JB
120### Removed
121
122- Remove unneeded worker-threads worker `MessageChannel` internal usage for IPC.
123
bc1b0765
JB
124## [2.6.3] - 2023-06-19
125
a6a2dc4c
JB
126### Fixed
127
128- Ensure no tasks are queued when trying to soft kill a dynamic worker.
f0d7f803 129- Update strategies internals after statistics computation.
a6a2dc4c 130
7b56f532
JB
131### Changed
132
133- Optimize O(1) queue implementation.
134
b628596c
JB
135## [2.6.2] - 2023-06-12
136
a9e89d00
JB
137### Fixed
138
139- Fix new worker use after creation in dynamic pool given the current worker choice strategy.
140
4368a898
JB
141## [2.6.1] - 2023-06-10
142
931d43e2
JB
143### Added
144
145- Add worker choice strategy documentation: [README.md](./src/pools/selection-strategies/README.md).
146
f1c06930
JB
147### Fixed
148
149- Fix average statistics computation: ensure failed tasks are not accounted.
150
16671b07
JB
151## [2.6.0] - 2023-06-09
152
a1347286
JB
153### Added
154
5af9c0f7 155- Add `LEAST_ELU` worker choice strategy (experimental).
9adcefab 156- Add tasks ELU instead of runtime support to `FAIR_SHARE` worker choice strategy.
a1347286 157
1c6fe997
JB
158### Changed
159
160- Refactor pool worker node usage internals.
477f48e7 161- Breaking change: refactor worker choice strategy statistics requirements: the syntax of the worker choice strategy options has changed.
f63a9dda 162- Breaking change: pool information `info` property object fields have been renamed.
1c6fe997
JB
163
164### Fixed
165
166- Fix wait time accounting.
167- Ensure worker choice strategy `LEAST_BUSY` accounts also tasks wait time.
168- Ensure worker choice strategy `LEAST_USED` accounts also queued tasks.
169
aa07d6ee
JB
170## [2.5.4] - 2023-06-07
171
b6b32453
JB
172### Added
173
174- Add Event Loop Utilization (ELU) statistics to worker tasks usage.
175
176### Changed
177
178- Compute statistics at the worker level only if needed.
90082c8c 179- Add `worker-threads` options to thread pool options.
b6b32453 180
272d4d8f
JB
181### Fixed
182
183- Make the `LEAST_BUSY` strategy only relies on task runtime.
184
ed47fb3d
JB
185## [2.5.3] - 2023-06-04
186
89a4abfd
JB
187### Changed
188
189- Refine pool information content.
b4213b7f 190- Limit pool internals public exposure.
89a4abfd 191
8a9febf5
JB
192## [2.5.2] - 2023-06-02
193
91ee39ed
JB
194### Added
195
196- Add `taskError` pool event for task execution error.
6b27d407 197- Add pool information `info` property to pool.
91ee39ed
JB
198- Emit pool information on `busy` and `full` pool events.
199
8babb151
JB
200## [2.5.1] - 2023-06-01
201
0e05c4dc
JB
202### Added
203
1f68cede 204- Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
91ee39ed 205- Add `error` pool event for uncaught worker error.
0e05c4dc 206
a8766181
JB
207## [2.5.0] - 2023-05-31
208
e4543b14
JB
209### Added
210
211- Switch pool event emitter to `EventEmitterAsyncResource`.
6da80d38 212- Add tasks wait time accounting in per worker tasks usage.
5af9c0f7 213- Add interleaved weighted round robin `INTERLEAVED_WEIGHTED_ROUND_ROBIN` worker choice strategy (experimental).
e4543b14
JB
214
215### Changed
216
217- Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
218
570efb11
JB
219## [2.4.14] - 2023-05-09
220
b0f28bad
JB
221### Fixed
222
223- Ensure no undefined task runtime can land in the tasks history.
224- Fix median computation implementation once again.
225
110b6d13
JB
226### Added
227
228- Unit tests for median and queue implementations.
229
72584880
JB
230## [2.4.13] - 2023-05-08
231
b0d6ed8f
JB
232### Fixed
233
e3058615 234- Fix worker choice strategy options validation.
b0d6ed8f
JB
235- Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
236
06140c32
JB
237## [2.4.12] - 2023-05-06
238
a86b6df1
JB
239### Added
240
241- Support multiple task functions per worker.
08f3f44c 242- Add custom worker weights support to worker choice strategies options.
a86b6df1 243
29ee7e9a
JB
244### Changed
245
246- Use O(1) queue implementation for tasks queueing.
247
0682ba15
JB
248### Fixed
249
250- Fix median computation implementation.
251- Fix fair share worker choice strategy internals update.
252
936d53ec
JB
253## [2.4.11] - 2023-04-23
254
cb70b19d
JB
255### Changed
256
257- Optimize free worker finding in worker choice strategies.
258
15bb637a
JB
259## [2.4.10] - 2023-04-15
260
ef41a6e6
JB
261### Fixed
262
263- Fix typescript type definition for worker function: ensure the input data is optional.
264- Fix typescript type definition for pool execute(): ensure the input data is optional.
265
181eb2b4
JB
266## [2.4.9] - 2023-04-15
267
a20f0ba5
JB
268### Added
269
270- Add tasks queue enablement runtime setter to pool.
271- Add tasks queue options runtime setter to pool.
272- Add worker choice strategy options runtime setter to pool.
273
274### Changed
275
276- Remove the tasks queuing experimental status.
277
d4aeae5a
JB
278### Fixed
279
280- Fix worker function type definition and validation.
2fc5cae3 281- Fix worker choice strategy options handling.
d4aeae5a 282
1d9e7023
JB
283## [2.4.8] - 2023-04-12
284
f9b4bbf8
JB
285### Fixed
286
287- Fix message between main worker and worker type definition for tasks.
288- Fix code documentation.
289
12ae3210
JB
290## [2.4.7] - 2023-04-11
291
7171d33f
JB
292### Added
293
294- Add worker tasks queue options to pool options.
295
e8bd29ce
JB
296### Fixed
297
298- Fix missing documentation.
299
42c7bc10
JB
300## [2.4.6] - 2023-04-10
301
681196cc
JB
302### Fixed
303
304- Ensure one task at a time is executed per worker with tasks queueing enabled.
1c6fe997 305- Properly count worker executing tasks with tasks queueing enabled.
681196cc 306
54d360e3
JB
307## [2.4.5] - 2023-04-09
308
3fafb1b2
JB
309### Added
310
9e775f96
JB
311- Use monotonic high resolution timer for worker tasks runtime.
312- Add worker tasks median runtime to statistics.
ff733df7 313- Add worker tasks queue (experimental).
3fafb1b2 314
92fa3eb6
JB
315## [2.4.4] - 2023-04-07
316
aee46736
JB
317### Added
318
319- Add `PoolEvents` enumeration and `PoolEvent` type.
320
36b5e78f
JB
321### Fixed
322
ff0c2b3e 323- Destroy worker only on alive check.
36b5e78f 324
9fb0f324
JB
325## [2.4.3] - 2023-04-07
326
28cf3617
JB
327### Fixed
328
329- Fix typedoc generation with inheritance.
330
848f0f27
JB
331## [2.4.2] - 2023-04-06
332
164d950a
JB
333### Added
334
335- Add `full` event to dynamic pool.
32417142 336- Keep worker choice strategy in memory for conditional reuse.
164d950a 337
78ab2555
JB
338### Fixed
339
340- Fix possible negative worker key at worker removal in worker choice strategies.
341
79aafe9f
JB
342## [2.4.1] - 2023-04-05
343
9cd39dd4
JB
344### Changed
345
346- Optimize worker choice strategy for dynamic pool.
347
965415bb
JB
348### Fixed
349
350- Ensure dynamic pool does not alter worker choice strategy expected behavior.
351
d8b60b1c
JB
352## [2.4.0] - 2023-04-04
353
c6bd2650
JB
354### Added
355
356- Add `LESS_BUSY` worker choice strategy.
357
358### Changed
359
360- Optimize worker storage in pool.
361- Optimize worker alive status check.
362- BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
363- Optimize `LESS_USED` worker choice strategy.
364- Update benchmarks versus external threads pools.
365- Optimize tasks usage statistics requirements for worker choice strategy.
366
367### Fixed
368
369- Ensure trimmable characters are checked at pool initialization.
370- Fix message id integer overflow.
371- Fix pool worker removal in worker choice strategy internals.
372- Fix package publication with pnpm.
373
d0a3f018
JB
374## [2.4.0-3] - 2023-04-04
375
b2ede285
JB
376### Added
377
378- Add `LESS_BUSY` worker choice strategy.
379
380### Changed
381
382- Optimize worker storage in pool.
383- Optimize worker alive status check.
384- BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
385- Optimize `LESS_USED` worker choice strategy.
386- Update benchmarks versus external threads pools.
387
388### Fixed
389
390- Ensure trimmable characters are checked at pool initialization.
391- Fix message id integer overflow.
392- Fix pool worker removal in worker choice strategy internals.
393- Fix package publication with pnpm.
394
a015ea40
JB
395## [2.4.0-2] - 2023-04-03
396
698f4bbc
JB
397### Added
398
399- Add `LESS_BUSY` worker choice strategy.
400
401### Changed
402
403- Optimize worker storage in pool.
404- Optimize worker alive status check.
405- BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
406- Optimize `LESS_USED` worker choice strategy.
407
408### Fixed
409
410- Ensure trimmable characters are checked at pool initialization.
411- Fix message id integer overflow.
412- Fix pool worker removal in worker choice strategy internals.
413- Fix package publication with pnpm.
414
8fe15920
JB
415## [2.4.0-1] - 2023-04-03
416
5b301c28
JB
417### Added
418
419- Add `LESS_BUSY` worker choice strategy.
420
421### Changed
422
423- Optimize worker storage in pool.
424- Optimize worker alive status check.
425- BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
426- Optimize `LESS_USED` worker choice strategy.
427
428### Fixed
429
430- Ensure trimmable characters are checked at pool initialization.
431- Fix message id integer overflow.
432- Fix pool worker removal in worker choice strategy internals.
433
2fb9ca9c
JB
434## [2.4.0-0] - 2023-04-03
435
168c526f
JB
436### Added
437
438- Add `LESS_BUSY` worker choice strategy.
439
1d71a908
JB
440### Changed
441
ffcbbad8 442- Optimize worker storage in pool.
1d71a908 443- Optimize worker alive status check.
65a60b3b 444- BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
737c6d97 445- Optimize `LESS_USED` worker choice strategy.
1d71a908 446
ffcbbad8
JB
447### Fixed
448
449- Ensure trimmable characters are checked at pool initialization.
b4e75778 450- Fix message id integer overflow.
97a2abc3 451- Fix pool worker removal in worker choice strategy internals.
ffcbbad8 452
08372738
JB
453## [2.3.10] - 2023-03-18
454
710826bc
JB
455### Fixed
456
457- Fix `exports` syntax for ESM and CommonJS.
458
459### Changed
460
461- Permit SemVer pre-release publication.
76e5ac6f 462
e4796ecd
JB
463## [2.3.10-2] - 2023-03-18
464
6abad580
JB
465### Fixed
466
467- Fix `exports` syntax for ESM and CommonJS.
468
a2ee98cc
JB
469## [2.3.10-1] - 2023-03-18
470
7e060cee
JB
471### Changed
472
90483887 473- Permit SemVer pre-release publication.
7e060cee 474
c81bfafb
JB
475## [2.3.10-0] - 2023-03-18
476
fe18768d
JB
477### Fixed
478
479- Fix `exports` syntax for ESM and CommonJS.
480
d7b78217
JB
481## [2.3.9] - 2023-03-18
482
ed6dd37f
JB
483### Changed
484
485- Introduce ESM module support along with CommonJS one.
486
487### Fixed
488
489- Fix brown paper bag bug referencing the same object literal.
490
68e2ad86
JB
491## [2.3.8] - 2023-03-18
492
ca6c7d70
JB
493### Changed
494
495- Switch internal benchmarking code to benny.
fbdedeb9
JB
496- Switch to TypeScript 5.x.x.
497- Switch rollup bundler plugins to core ones.
ed6dd37f 498- Switch to TSDoc syntax.
fbdedeb9 499- Enforce conventional commits.
ca6c7d70 500
d15211d4
JB
501### Fixed
502
503- Fix random integer generator.
fbdedeb9 504- Fix worker choice strategy pool type identification at initialization.
d15211d4 505
995705ea
JB
506## [2.3.7] - 2022-10-23
507
b953022b
JB
508### Changed
509
510- Switch to open collective FOSS project funding platform.
78cea37e
JB
511- Switch to ts-standard linter configuration on TypeScript code.
512
513### Fixed
514
515- Fixed missing async on pool execute method.
516- Fixed typing in TypeScript example.
517- Fixed types in unit tests.
b953022b 518
3b9f6953
JB
519## [2.3.6] - 2022-10-22
520
f80cead4
JB
521### Changed
522
523- Cleanup pool attributes and methods.
524- Refine error types thrown.
525
526### Fixed
527
528- Fix continuous integration build on windows.
529- Fix code coverage reporting by using c8 instead of nyc.
530
efc22107
JB
531## [2.3.5] - 2022-10-21
532
7a6a0a96
JB
533### Changed
534
a05c10de
JB
535- Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
536- Optimize tasks usage lookup implementation.
7a6a0a96 537
b4904890
JB
538### Fixed
539
540- Fix missed pool event emitter type export.
541- Fix typedoc documentation generation.
542
a875f8d1
JB
543## [2.3.4] - 2022-10-17
544
73cda448
JB
545### Added
546
547- Fully automate release process with release-it.
548
45a5a54c
JB
549### Changed
550
73cda448 551- Optimize fair share task scheduling algorithm implementation.
eb4a8a82 552- Update benchmarks versus external pools results with latest version.
45a5a54c 553
90ee1b18 554## [2.3.3] - 2022-10-15
1a76932b
JB
555
556### Added
557
558- Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
559
90ee1b18 560## [2.3.2] - 2022-10-14
11df3590
JB
561
562### Changed
563
564- Optimize fair share worker selection strategy implementation.
565
566### Fixed
567
568- Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
569
90ee1b18 570## [2.3.1] - 2022-10-13
23ff945a
JB
571
572### Added
573
574- Pool worker choice strategies:
575 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
576 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
577
90ee1b18 578## [2.2.2] - 2022-10-09
cb2b6c69
JB
579
580### Fixed
581
582- Fixed `README.md` file.
583
90ee1b18 584## [2.2.1] - 2022-10-08
bdacc2d2 585
bdaf31cd
JB
586### Added
587
588- Dynamic worker choice strategy change at runtime.
bdacc2d2 589
90ee1b18 590## [2.2.0] - 2022-01-05
7e0d447f
JB
591
592### Breaking Changes
593
594- Support only NodeJS version 16.x.x for cluster pool: upstream cluster API have changed on that version.
595
90ee1b18 596## [2.1.0] - 2021-08-29
35cf1c03
JB
597
598### Added
599
600- Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
e088a00c
JB
601
602### Breaking Changes
603
604- `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
605- `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
606- `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
c365b2d3 607- `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
e088a00c 608
90ee1b18 609## [2.0.2] - 2021-05-12
14916bf9
JB
610
611### Bug fixes
612
613- Fix `busy` event emission on fixed pool type
614
90ee1b18 615## [2.0.1] - 2021-03-16
7f685093
JB
616
617### Bug fixes
618
619- Check if pool options are properly set.
620- `busy` event is emitted on all pool types.
621
90ee1b18 622## [2.0.0] - 2021-03-01
fa0f5b28 623
f3f833ab 624### Bug fixes
d63d3be3 625
ddbeaffd 626- Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
d63d3be3 627
fa0f5b28
S
628### Breaking Changes
629
7f685093 630- `FullPool` event is now renamed to `busy`.
1927ee67 631- `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
1a81f8af 632 _Find more details on our JSDoc._
ddbeaffd 633
1927ee67
APA
634- `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
635
ddbeaffd 636- We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
fa0f5b28 637
ec2ccfc8
JB
638### Pool options types declaration merge
639
640`FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
641
fa0f5b28
S
642#### New `export` strategy
643
644```js
645// Before
777b7824 646const DynamicThreadPool = require('poolifier/lib/dynamic')
fa0f5b28 647// After
777b7824 648const { DynamicThreadPool } = require('poolifier/lib/dynamic')
fa0f5b28
S
649```
650
651But you should always prefer just using
652
653```js
777b7824 654const { DynamicThreadPool } = require('poolifier')
fa0f5b28
S
655```
656
d3c8a1a8
S
657#### New type definitions for input data and response
658
6677a3d3 659For cluster worker and worker-thread pools, you can now only send and receive structured-cloneable data.
d3c8a1a8
S
660_This is not a limitation by poolifier but NodeJS._
661
3a4b605f 662#### Public property replacements
5c5a1fb7 663
3a4b605f 664`numWorkers` property is now `numberOfWorkers`
5c5a1fb7 665
280c2a77 666#### Internal (protected) properties and methods renaming
fa0f5b28 667
280c2a77
S
668These properties are not intended for end users
669
670- `id` => `nextMessageId`
671
672These methods are not intended for end users
fa0f5b28
S
673
674- `_chooseWorker` => `chooseWorker`
280c2a77 675- `_newWorker` => `createWorker`
fa0f5b28
S
676- `_execute` => `internalExecute`
677- `_chooseWorker` => `chooseWorker`
678- `_checkAlive` => `checkAlive`
679- `_run` => `run`
680- `_runAsync` => `runAsync`
681
90ee1b18 682## [1.1.0] - 2020-05-21
0312f71a
APA
683
684### Added
685
686- ThreadWorker support async functions as option
cf9aa6c3 687- Various external library patches
0312f71a 688
90ee1b18 689## [1.0.0] - 2020-01-24
522eea03 690
691### Added
692
693- FixedThreadPool implementation
694- DynamicThreadPool implementation
0312f71a 695- WorkerThread implementation to improve developer experience