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