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