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