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