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