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