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