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