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