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