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