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