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