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