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