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