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