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