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