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