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