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