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