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