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