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