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