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