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