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