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