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