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