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