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