build(deps-dev): apply updates
[poolifier.git] / CHANGELOG.md
... / ...
CommitLineData
1# Changelog
2
3All notable changes to this project will be documented in this file.
4
5The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
8## [Unreleased]
9
10### Fixed
11
12- Ensure unused worker usage statistics are deleted at runtime.
13
14### Changed
15
16- Rename worker choice strategy options `choiceRetries` to `retries`.
17- Avoid unnecessary branching in worker choice strategies.
18
19## [2.6.36] - 2023-08-27
20
21### Fixed
22
23- Fix pool `execute()` arguments check.
24
25### Changed
26
27- Make continuous tasks stealing algorithm less aggressive.
28- Fine tune tasks stealing algorithm under back pressure.
29
30## [2.6.35] - 2023-08-25
31
32### Fixed
33
34- Don't account worker usage statistics for tasks that have failed.
35- Fix pool information runtime and wait time median computation.
36
37### Changed
38
39- Update simple moving average implementation to use a circular buffer.
40- Update simple moving median implementation to use a circular buffer.
41- Account for stolen tasks in worker usage statistics and pool information.
42
43### Added
44
45- Continuous tasks stealing algorithm.
46
47## [2.6.34] - 2023-08-24
48
49### Fixes
50
51- Avoid cascading tasks stealing under back pressure.
52
53### Changed
54
55- Add fastpath to queued tasks rescheduling.
56
57## [2.6.33] - 2023-08-24
58
59### Fixed
60
61- Fix queued tasks rescheduling.
62
63### Changed
64
65- Rename tasks queue options `queueMaxSize` to `size`.
66
67### Added
68
69- Task stealing scheduling algorithm if tasks queueing is enabled.
70
71## [2.6.32] - 2023-08-23
72
73### Fixed
74
75- Ensure no task can be executed when the pool is destroyed.
76
77### Added
78
79- Add `queueMaxSize` option to tasks queue options.
80- Add O(1) deque implementation implemented with doubly linked list and use it for tasks queueing.
81- Add tasks stealing algorithm when a worker node queue is back pressured if tasks queueing is enabled.
82
83## [2.6.31] - 2023-08-20
84
85### Fixed
86
87- Fix worker choice strategy retries mechanism in some edge cases.
88
89### Changed
90
91- Make orthogonal worker choice strategies tasks distribution and created dynamic worker usage.
92- Remove the experimental status of the `LEAST_ELU` worker choice strategy.
93
94## [2.6.30] - 2023-08-19
95
96### Fixed
97
98- Ensure pool event `backPressure` is emitted.
99- Ensure pool event `full` is emitted only once.
100- Ensure worker node cannot be instantiated without proper arguments.
101
102## [2.6.29] - 2023-08-18
103
104### Fixed
105
106- Fix race condition between ready and task functions worker message handling at startup.
107- Fix duplicate task function worker usage statistics computation per task function.
108- Update task function worker usage statistics if and only if there's at least two different task functions.
109- Fix race condition at task function worker usage executing task computation leading to negative value.
110
111### Added
112
113- Add back pressure detection on the worker node queue. Event `backPressure` is emitted when all worker node queues are full (worker node queue size >= poolMaxSize^2).
114- Use back pressure detection in worker choice strategies.
115- Add worker choice strategies retries mechanism if no worker is eligible.
116
117## [2.6.28] - 2023-08-16
118
119### Fixed
120
121- Ensure pool workers are properly initialized.
122
123### Added
124
125- HTTP server pool examples: express-cluster, express-hybrid.
126
127### Changed
128
129- Remove now useless branching in worker hot code path.
130
131## [2.6.27] - 2023-08-15
132
133### Fixed
134
135- Add `KillHandler` type definition to exported types.
136
137### Added
138
139- Add `destroy` event to pool API.
140
141## [2.6.26] - 2023-08-15
142
143### Added
144
145- Add kill handler to worker options allowing to execute custom code when worker is killed.
146- Add `listTaskFunctions()` method to pool API.
147- SMTP server pool example: nodemailer.
148
149## [2.6.25] - 2023-08-13
150
151### Added
152
153- HTTP server pool examples: fastify-cluster, fastify-hybrid.
154- WebSocket server pool examples: ws-cluster, ws-hybrid.
155
156## [2.6.24] - 2023-08-12
157
158### Added
159
160- Add array of transferable objects to the `execute()` method arguments.
161- WebSocket server pool examples: ws-worker_threads.
162
163## [2.6.23] - 2023-08-11
164
165### Fixed
166
167- Fix pool busyness semantic when tasks queueing is enabled: the pool is busy when the number of executing tasks on each worker has reached the maximum tasks concurrency per worker.
168
169### Added
170
171- HTTP client pool examples: fetch, node-fetch and axios with multiple task functions.
172- HTTP server pool examples: express-worker_threads, fastify-worker_threads.
173
174## [2.6.22] - 2023-08-10
175
176### Fixed
177
178- Add missing `types` field to package.json `exports`.
179
180### Changed
181
182- Structure markdown documentation (PR #811).
183
184## [2.6.21] - 2023-08-03
185
186### Changed
187
188- Improve code documentation.
189- Code refactoring and cleanup for better maintainability and readability.
190
191## [2.6.20] - 2023-07-21
192
193### Fixed
194
195- Fix queued tasks redistribution on error task execution starvation.
196- Ensure tasks queueing per worker condition is untangled from the pool busyness semantic.
197
198### Changed
199
200- Drastically reduce lookups by worker in the worker nodes.
201
202## [2.6.19] - 2023-07-20
203
204### Added
205
206- Dedicated internal communication channel for worker_threads pools.
207
208## [2.6.18] - 2023-07-19
209
210### Changed
211
212- Code refactoring and cleanup for better maintainability and readability. Bundle size is a bit smaller.
213
214## [2.6.17] - 2023-07-16
215
216### Added
217
218- Add `listTaskFunctions()` method to worker API.
219
220## [2.6.16] - 2023-07-12
221
222### Fixed
223
224- Fix pool startup detection.
225- Fix worker task functions handling.
226
227## [2.6.15] - 2023-07-11
228
229### Added
230
231- Take into account worker node readiness in worker choice strategies.
232
233## [2.6.14] - 2023-07-10
234
235### Fixed
236
237- Fix task function statistics tracking.
238
239## [2.6.13] - 2023-07-10
240
241### Added
242
243- Add per task function statistics tracking.
244- Add public methods to manipulate the worker task functions at runtime.
245
246## [2.6.12] - 2023-07-09
247
248### Fixed
249
250- Workaround import issue with `node:os` module in node 16.x.x.
251
252## [2.6.11] - 2023-07-09
253
254### Fixed
255
256- Fix pool readiness semantic.
257
258## [2.6.10] - 2023-07-08
259
260### Fixed
261
262- Ensure workers are not recreated on error at pool startup.
263
264### Added
265
266- Add `ready` and `strategy` fields to pool information.
267- Add pool event `ready` to notify when the number of workers created in the pool has reached the maximum size expected and are ready.
268- Add dynamic pool sizing checks.
269
270## [2.6.9] - 2023-07-07
271
272### Fixed
273
274- Recreate the right worker type on uncaught exception.
275
276### Added
277
278- Add minimum and maximum to internal measurement statistics.
279- Add `runTime` and `waitTime` to pool information.
280- Check worker inactive time only on dynamic worker.
281
282## [2.6.8] - 2023-07-03
283
284### Fixed
285
286- Brown paper bag release to fix version handling in pool information.
287
288## [2.6.7] - 2023-07-03
289
290### Fixed
291
292- Ensure worker queued tasks at error are reassigned to other pool workers.
293
294### Added
295
296- Add pool `utilization` ratio to pool information.
297- Add `version` to pool information.
298- Add worker information to worker nodes.
299
300## [2.6.6] - 2023-07-01
301
302### Added
303
304- Add safe helper `availableParallelism()` to help sizing the pool.
305
306### Fixed
307
308- Ensure message handler is only registered in worker.
309
310## [2.6.5] - 2023-06-27
311
312### Known issues
313
314- Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
315
316### Fixed
317
318- Artificial version bump to 2.6.5 to workaround publication issue.
319- Ensure cluster pool `destroy()` gracefully shutdowns worker's server.
320- Ensure pool event is emitted before task error promise rejection.
321- Fix queued tasks count computation.
322
323### Removed
324
325- Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
326
327## [2.6.4] - 2023-06-27
328
329### Known issues
330
331- Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
332
333### Fixed
334
335- Ensure cluster pool `destroy()` gracefully shutdowns worker's server.
336- Ensure pool event is emitted before task error promise rejection.
337- Fix queued tasks count computation.
338
339### Removed
340
341- Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
342
343## [2.6.3] - 2023-06-19
344
345### Fixed
346
347- Ensure no tasks are queued when trying to soft kill a dynamic worker.
348- Update strategies internals after statistics computation.
349
350### Changed
351
352- Optimize O(1) queue implementation.
353
354## [2.6.2] - 2023-06-12
355
356### Fixed
357
358- Fix new worker use after creation in dynamic pool given the current worker choice strategy.
359
360## [2.6.1] - 2023-06-10
361
362### Added
363
364- Add worker choice strategy documentation: [README.md](./docs/worker-choice-strategies.md).
365
366### Fixed
367
368- Fix average statistics computation: ensure failed tasks are not accounted.
369
370## [2.6.0] - 2023-06-09
371
372### Added
373
374- Add `LEAST_ELU` worker choice strategy (experimental).
375- Add tasks ELU instead of runtime support to `FAIR_SHARE` worker choice strategy.
376
377### Changed
378
379- Refactor pool worker node usage internals.
380- Breaking change: refactor worker choice strategy statistics requirements: the syntax of the worker choice strategy options has changed.
381- Breaking change: pool information `info` property object fields have been renamed.
382
383### Fixed
384
385- Fix wait time accounting.
386- Ensure worker choice strategy `LEAST_BUSY` accounts also tasks wait time.
387- Ensure worker choice strategy `LEAST_USED` accounts also queued tasks.
388
389## [2.5.4] - 2023-06-07
390
391### Added
392
393- Add Event Loop Utilization (ELU) statistics to worker tasks usage.
394
395### Changed
396
397- Compute statistics at the worker level only if needed.
398- Add `worker_threads` options to thread pool options.
399
400### Fixed
401
402- Make the `LEAST_BUSY` strategy only relies on task runtime.
403
404## [2.5.3] - 2023-06-04
405
406### Changed
407
408- Refine pool information content.
409- Limit pool internals public exposure.
410
411## [2.5.2] - 2023-06-02
412
413### Added
414
415- Add `taskError` pool event for task execution error.
416- Add pool information `info` property to pool.
417- Emit pool information on `busy` and `full` pool events.
418
419## [2.5.1] - 2023-06-01
420
421### Added
422
423- Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
424- Add `error` pool event for uncaught worker error.
425
426## [2.5.0] - 2023-05-31
427
428### Added
429
430- Switch pool event emitter to `EventEmitterAsyncResource`.
431- Add tasks wait time accounting in per worker tasks usage.
432- Add interleaved weighted round robin `INTERLEAVED_WEIGHTED_ROUND_ROBIN` worker choice strategy (experimental).
433
434### Changed
435
436- Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
437
438## [2.4.14] - 2023-05-09
439
440### Fixed
441
442- Ensure no undefined task runtime can land in the tasks history.
443- Fix median computation implementation once again.
444
445### Added
446
447- Unit tests for median and queue implementations.
448
449## [2.4.13] - 2023-05-08
450
451### Fixed
452
453- Fix worker choice strategy options validation.
454- Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
455
456## [2.4.12] - 2023-05-06
457
458### Added
459
460- Support multiple task functions per worker.
461- Add custom worker weights support to worker choice strategies options.
462
463### Changed
464
465- Use O(1) queue implementation for tasks queueing.
466
467### Fixed
468
469- Fix median computation implementation.
470- Fix fair share worker choice strategy internals update.
471
472## [2.4.11] - 2023-04-23
473
474### Changed
475
476- Optimize free worker finding in worker choice strategies.
477
478## [2.4.10] - 2023-04-15
479
480### Fixed
481
482- Fix typescript type definition for task function: ensure the input data is optional.
483- Fix typescript type definition for pool execute(): ensure the input data is optional.
484
485## [2.4.9] - 2023-04-15
486
487### Added
488
489- Add tasks queue enablement runtime setter to pool.
490- Add tasks queue options runtime setter to pool.
491- Add worker choice strategy options runtime setter to pool.
492
493### Changed
494
495- Remove the tasks queuing experimental status.
496
497### Fixed
498
499- Fix task function type definition and validation.
500- Fix worker choice strategy options handling.
501
502## [2.4.8] - 2023-04-12
503
504### Fixed
505
506- Fix message between main worker and worker type definition for tasks.
507- Fix code documentation.
508
509## [2.4.7] - 2023-04-11
510
511### Added
512
513- Add worker tasks queue options to pool options.
514
515### Fixed
516
517- Fix missing documentation.
518
519## [2.4.6] - 2023-04-10
520
521### Fixed
522
523- Ensure one task at a time is executed per worker with tasks queueing enabled.
524- Properly count worker executing tasks with tasks queueing enabled.
525
526## [2.4.5] - 2023-04-09
527
528### Added
529
530- Use monotonic high resolution timer for worker tasks runtime.
531- Add worker tasks median runtime to statistics.
532- Add worker tasks queue (experimental).
533
534## [2.4.4] - 2023-04-07
535
536### Added
537
538- Add `PoolEvents` enumeration and `PoolEvent` type.
539
540### Fixed
541
542- Destroy worker only on alive check.
543
544## [2.4.3] - 2023-04-07
545
546### Fixed
547
548- Fix typedoc generation with inheritance.
549
550## [2.4.2] - 2023-04-06
551
552### Added
553
554- Add `full` event to dynamic pool.
555- Keep worker choice strategy in memory for conditional reuse.
556
557### Fixed
558
559- Fix possible negative worker key at worker removal in worker choice strategies.
560
561## [2.4.1] - 2023-04-05
562
563### Changed
564
565- Optimize worker choice strategy for dynamic pool.
566
567### Fixed
568
569- Ensure dynamic pool does not alter worker choice strategy expected behavior.
570
571## [2.4.0] - 2023-04-04
572
573### Added
574
575- Add `LESS_BUSY` worker choice strategy.
576
577### Changed
578
579- Optimize worker storage in pool.
580- Optimize worker alive status check.
581- BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
582- Optimize `LESS_USED` worker choice strategy.
583- Update benchmarks versus external threads pools.
584- Optimize tasks usage statistics requirements for worker choice strategy.
585
586### Fixed
587
588- Ensure trimmable characters are checked at pool initialization.
589- Fix message id integer overflow.
590- Fix pool worker removal in worker choice strategy internals.
591- Fix package publication with pnpm.
592
593## [2.4.0-3] - 2023-04-04
594
595### Added
596
597- Add `LESS_BUSY` worker choice strategy.
598
599### Changed
600
601- Optimize worker storage in pool.
602- Optimize worker alive status check.
603- BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
604- Optimize `LESS_USED` worker choice strategy.
605- Update benchmarks versus external threads pools.
606
607### Fixed
608
609- Ensure trimmable characters are checked at pool initialization.
610- Fix message id integer overflow.
611- Fix pool worker removal in worker choice strategy internals.
612- Fix package publication with pnpm.
613
614## [2.4.0-2] - 2023-04-03
615
616### Added
617
618- Add `LESS_BUSY` worker choice strategy.
619
620### Changed
621
622- Optimize worker storage in pool.
623- Optimize worker alive status check.
624- BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
625- Optimize `LESS_USED` worker choice strategy.
626
627### Fixed
628
629- Ensure trimmable characters are checked at pool initialization.
630- Fix message id integer overflow.
631- Fix pool worker removal in worker choice strategy internals.
632- Fix package publication with pnpm.
633
634## [2.4.0-1] - 2023-04-03
635
636### Added
637
638- Add `LESS_BUSY` worker choice strategy.
639
640### Changed
641
642- Optimize worker storage in pool.
643- Optimize worker alive status check.
644- BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
645- Optimize `LESS_USED` worker choice strategy.
646
647### Fixed
648
649- Ensure trimmable characters are checked at pool initialization.
650- Fix message id integer overflow.
651- Fix pool worker removal in worker choice strategy internals.
652
653## [2.4.0-0] - 2023-04-03
654
655### Added
656
657- Add `LESS_BUSY` worker choice strategy.
658
659### Changed
660
661- Optimize worker storage in pool.
662- Optimize worker alive status check.
663- BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
664- Optimize `LESS_USED` worker choice strategy.
665
666### Fixed
667
668- Ensure trimmable characters are checked at pool initialization.
669- Fix message id integer overflow.
670- Fix pool worker removal in worker choice strategy internals.
671
672## [2.3.10] - 2023-03-18
673
674### Fixed
675
676- Fix package.json `exports` syntax for ESM and CommonJS.
677
678### Changed
679
680- Permit SemVer pre-release publication.
681
682## [2.3.10-2] - 2023-03-18
683
684### Fixed
685
686- Fix package.json `exports` syntax for ESM and CommonJS.
687
688## [2.3.10-1] - 2023-03-18
689
690### Changed
691
692- Permit SemVer pre-release publication.
693
694## [2.3.10-0] - 2023-03-18
695
696### Fixed
697
698- Fix package.json `exports` syntax for ESM and CommonJS.
699
700## [2.3.9] - 2023-03-18
701
702### Changed
703
704- Introduce ESM module support along with CommonJS one.
705
706### Fixed
707
708- Fix brown paper bag bug referencing the same object literal.
709
710## [2.3.8] - 2023-03-18
711
712### Changed
713
714- Switch internal benchmarking code to benny.
715- Switch to TypeScript 5.x.x.
716- Switch rollup bundler plugins to core ones.
717- Switch to TSDoc syntax.
718- Enforce conventional commits.
719
720### Fixed
721
722- Fix random integer generator.
723- Fix worker choice strategy pool type identification at initialization.
724
725## [2.3.7] - 2022-10-23
726
727### Changed
728
729- Switch to open collective FOSS project funding platform.
730- Switch to ts-standard linter configuration on TypeScript code.
731
732### Fixed
733
734- Fixed missing async on pool execute method.
735- Fixed typing in TypeScript example.
736- Fixed types in unit tests.
737
738## [2.3.6] - 2022-10-22
739
740### Changed
741
742- Cleanup pool attributes and methods.
743- Refine error types thrown.
744
745### Fixed
746
747- Fix continuous integration build on windows.
748- Fix code coverage reporting by using c8 instead of nyc.
749
750## [2.3.5] - 2022-10-21
751
752### Changed
753
754- Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
755- Optimize tasks usage lookup implementation.
756
757### Fixed
758
759- Fix missed pool event emitter type export.
760- Fix typedoc documentation generation.
761
762## [2.3.4] - 2022-10-17
763
764### Added
765
766- Fully automate release process with release-it.
767
768### Changed
769
770- Optimize fair share task scheduling algorithm implementation.
771- Update benchmarks versus external pools results with latest version.
772
773## [2.3.3] - 2022-10-15
774
775### Added
776
777- Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
778
779## [2.3.2] - 2022-10-14
780
781### Changed
782
783- Optimize fair share worker selection strategy implementation.
784
785### Fixed
786
787- Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
788
789## [2.3.1] - 2022-10-13
790
791### Added
792
793- Pool worker choice strategies:
794 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
795 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
796
797## [2.2.2] - 2022-10-09
798
799### Fixed
800
801- Fixed `README.md` file.
802
803## [2.2.1] - 2022-10-08
804
805### Added
806
807- Dynamic worker choice strategy change at runtime.
808
809## [2.2.0] - 2022-01-05
810
811### Breaking Changes
812
813- Support only Node.js version 16.x.x for cluster pool: upstream cluster API have changed on that version.
814
815## [2.1.0] - 2021-08-29
816
817### Added
818
819- Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
820
821### Breaking Changes
822
823- `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
824- `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
825- `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
826- `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
827
828## [2.0.2] - 2021-05-12
829
830### Bug fixes
831
832- Fix `busy` event emission on fixed pool type
833
834## [2.0.1] - 2021-03-16
835
836### Bug fixes
837
838- Check if pool options are properly set.
839- `busy` event is emitted on all pool types.
840
841## [2.0.0] - 2021-03-01
842
843### Bug fixes
844
845- Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
846
847### Breaking Changes
848
849- `FullPool` event is now renamed to `busy`.
850- `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
851 _Find more details on our JSDoc._
852
853- `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
854
855- We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
856
857### Pool options types declaration merge
858
859`FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
860
861#### New `export` strategy
862
863```js
864// Before
865const DynamicThreadPool = require('poolifier/lib/dynamic')
866// After
867const { DynamicThreadPool } = require('poolifier/lib/dynamic')
868```
869
870But you should always prefer just using
871
872```js
873const { DynamicThreadPool } = require('poolifier')
874```
875
876#### New type definitions for input data and response
877
878For cluster worker and worker-thread pools, you can now only send and receive structured-cloneable data.
879_This is not a limitation by poolifier but Node.js._
880
881#### Public property replacements
882
883`numWorkers` property is now `numberOfWorkers`
884
885#### Internal (protected) properties and methods renaming
886
887These properties are not intended for end users
888
889- `id` => `nextMessageId`
890
891These methods are not intended for end users
892
893- `_chooseWorker` => `chooseWorker`
894- `_newWorker` => `createWorker`
895- `_execute` => `internalExecute`
896- `_chooseWorker` => `chooseWorker`
897- `_checkAlive` => `checkAlive`
898- `_run` => `run`
899- `_runAsync` => `runAsync`
900
901## [1.1.0] - 2020-05-21
902
903### Added
904
905- ThreadWorker support async functions as option
906- Various external library patches
907
908## [1.0.0] - 2020-01-24
909
910### Added
911
912- FixedThreadPool implementation
913- DynamicThreadPool implementation
914- WorkerThread implementation to improve developer experience