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