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