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