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