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