refactor: factor out measurement requirements median toggling code
[poolifier.git] / CHANGELOG.md
... / ...
CommitLineData
1# Changelog
2
3All notable changes to this project will be documented in this file.
4
5The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
8## [Unreleased]
9
10## [2.6.17] - 2023-07-16
11
12### Added
13
14- Add `listTaskFunctions()` method to worker class.
15
16## [2.6.16] - 2023-07-12
17
18### Fixed
19
20- Fix pool startup detection.
21- Fix worker task functions handling.
22
23## [2.6.15] - 2023-07-11
24
25### Added
26
27- Take into account worker node readiness in worker choice strategies.
28
29## [2.6.14] - 2023-07-10
30
31### Fixed
32
33- Fix task function statistics tracking.
34
35## [2.6.13] - 2023-07-10
36
37### Added
38
39- Add per task function statistics tracking.
40- Add public methods to manipulate the worker task functions at runtime.
41
42## [2.6.12] - 2023-07-09
43
44### Fixed
45
46- Workaround import issue with `node:os` module in node 16.x.x.
47
48## [2.6.11] - 2023-07-09
49
50### Fixed
51
52- Fix pool readiness semantic.
53
54## [2.6.10] - 2023-07-08
55
56### Fixed
57
58- Ensure workers are not recreated on error at pool startup.
59
60### Added
61
62- Add `ready` and `strategy` fields to pool information.
63- Add pool event `ready` to notify when the number of workers created in the pool has reached the maximum size expected and are ready.
64- Add dynamic pool sizing checks.
65
66## [2.6.9] - 2023-07-07
67
68### Fixed
69
70- Recreate the right worker type on uncaught exception.
71
72### Added
73
74- Add minimum and maximum to internal measurement statistics.
75- Add `runTime` and `waitTime` to pool information.
76- Check worker inactive time only on dynamic worker.
77
78## [2.6.8] - 2023-07-03
79
80### Fixed
81
82- Brown paper bag release to fix version handling in pool information.
83
84## [2.6.7] - 2023-07-03
85
86### Fixed
87
88- Ensure worker queued tasks at error are reassigned to other pool workers.
89
90### Added
91
92- Add pool `utilization` ratio to pool information.
93- Add `version` to pool information.
94- Add worker information to worker nodes.
95
96## [2.6.6] - 2023-07-01
97
98### Added
99
100- Add safe helper `availableParallelism` to help sizing the pool.
101
102### Fixed
103
104- Ensure message handler is only registered in worker.
105
106## [2.6.5] - 2023-06-27
107
108### Known issues
109
110- Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
111
112### Fixed
113
114- Artificial version bump to 2.6.5 to workaround publication issue.
115- Ensure cluster pool destroy() gracefully shutdowns worker's server.
116- Ensure pool event is emitted before task error promise rejection.
117- Fix queued tasks count computation.
118
119### Removed
120
121- Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
122
123## [2.6.4] - 2023-06-27
124
125### Known issues
126
127- Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
128
129### Fixed
130
131- Ensure cluster pool destroy() gracefully shutdowns worker's server.
132- Ensure pool event is emitted before task error promise rejection.
133- Fix queued tasks count computation.
134
135### Removed
136
137- Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
138
139## [2.6.3] - 2023-06-19
140
141### Fixed
142
143- Ensure no tasks are queued when trying to soft kill a dynamic worker.
144- Update strategies internals after statistics computation.
145
146### Changed
147
148- Optimize O(1) queue implementation.
149
150## [2.6.2] - 2023-06-12
151
152### Fixed
153
154- Fix new worker use after creation in dynamic pool given the current worker choice strategy.
155
156## [2.6.1] - 2023-06-10
157
158### Added
159
160- Add worker choice strategy documentation: [README.md](./src/pools/selection-strategies/README.md).
161
162### Fixed
163
164- Fix average statistics computation: ensure failed tasks are not accounted.
165
166## [2.6.0] - 2023-06-09
167
168### Added
169
170- Add `LEAST_ELU` worker choice strategy (experimental).
171- Add tasks ELU instead of runtime support to `FAIR_SHARE` worker choice strategy.
172
173### Changed
174
175- Refactor pool worker node usage internals.
176- Breaking change: refactor worker choice strategy statistics requirements: the syntax of the worker choice strategy options has changed.
177- Breaking change: pool information `info` property object fields have been renamed.
178
179### Fixed
180
181- Fix wait time accounting.
182- Ensure worker choice strategy `LEAST_BUSY` accounts also tasks wait time.
183- Ensure worker choice strategy `LEAST_USED` accounts also queued tasks.
184
185## [2.5.4] - 2023-06-07
186
187### Added
188
189- Add Event Loop Utilization (ELU) statistics to worker tasks usage.
190
191### Changed
192
193- Compute statistics at the worker level only if needed.
194- Add `worker_threads` options to thread pool options.
195
196### Fixed
197
198- Make the `LEAST_BUSY` strategy only relies on task runtime.
199
200## [2.5.3] - 2023-06-04
201
202### Changed
203
204- Refine pool information content.
205- Limit pool internals public exposure.
206
207## [2.5.2] - 2023-06-02
208
209### Added
210
211- Add `taskError` pool event for task execution error.
212- Add pool information `info` property to pool.
213- Emit pool information on `busy` and `full` pool events.
214
215## [2.5.1] - 2023-06-01
216
217### Added
218
219- Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
220- Add `error` pool event for uncaught worker error.
221
222## [2.5.0] - 2023-05-31
223
224### Added
225
226- Switch pool event emitter to `EventEmitterAsyncResource`.
227- Add tasks wait time accounting in per worker tasks usage.
228- Add interleaved weighted round robin `INTERLEAVED_WEIGHTED_ROUND_ROBIN` worker choice strategy (experimental).
229
230### Changed
231
232- Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
233
234## [2.4.14] - 2023-05-09
235
236### Fixed
237
238- Ensure no undefined task runtime can land in the tasks history.
239- Fix median computation implementation once again.
240
241### Added
242
243- Unit tests for median and queue implementations.
244
245## [2.4.13] - 2023-05-08
246
247### Fixed
248
249- Fix worker choice strategy options validation.
250- Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
251
252## [2.4.12] - 2023-05-06
253
254### Added
255
256- Support multiple task functions per worker.
257- Add custom worker weights support to worker choice strategies options.
258
259### Changed
260
261- Use O(1) queue implementation for tasks queueing.
262
263### Fixed
264
265- Fix median computation implementation.
266- Fix fair share worker choice strategy internals update.
267
268## [2.4.11] - 2023-04-23
269
270### Changed
271
272- Optimize free worker finding in worker choice strategies.
273
274## [2.4.10] - 2023-04-15
275
276### Fixed
277
278- Fix typescript type definition for worker function: ensure the input data is optional.
279- Fix typescript type definition for pool execute(): ensure the input data is optional.
280
281## [2.4.9] - 2023-04-15
282
283### Added
284
285- Add tasks queue enablement runtime setter to pool.
286- Add tasks queue options runtime setter to pool.
287- Add worker choice strategy options runtime setter to pool.
288
289### Changed
290
291- Remove the tasks queuing experimental status.
292
293### Fixed
294
295- Fix worker function type definition and validation.
296- Fix worker choice strategy options handling.
297
298## [2.4.8] - 2023-04-12
299
300### Fixed
301
302- Fix message between main worker and worker type definition for tasks.
303- Fix code documentation.
304
305## [2.4.7] - 2023-04-11
306
307### Added
308
309- Add worker tasks queue options to pool options.
310
311### Fixed
312
313- Fix missing documentation.
314
315## [2.4.6] - 2023-04-10
316
317### Fixed
318
319- Ensure one task at a time is executed per worker with tasks queueing enabled.
320- Properly count worker executing tasks with tasks queueing enabled.
321
322## [2.4.5] - 2023-04-09
323
324### Added
325
326- Use monotonic high resolution timer for worker tasks runtime.
327- Add worker tasks median runtime to statistics.
328- Add worker tasks queue (experimental).
329
330## [2.4.4] - 2023-04-07
331
332### Added
333
334- Add `PoolEvents` enumeration and `PoolEvent` type.
335
336### Fixed
337
338- Destroy worker only on alive check.
339
340## [2.4.3] - 2023-04-07
341
342### Fixed
343
344- Fix typedoc generation with inheritance.
345
346## [2.4.2] - 2023-04-06
347
348### Added
349
350- Add `full` event to dynamic pool.
351- Keep worker choice strategy in memory for conditional reuse.
352
353### Fixed
354
355- Fix possible negative worker key at worker removal in worker choice strategies.
356
357## [2.4.1] - 2023-04-05
358
359### Changed
360
361- Optimize worker choice strategy for dynamic pool.
362
363### Fixed
364
365- Ensure dynamic pool does not alter worker choice strategy expected behavior.
366
367## [2.4.0] - 2023-04-04
368
369### Added
370
371- Add `LESS_BUSY` worker choice strategy.
372
373### Changed
374
375- Optimize worker storage in pool.
376- Optimize worker alive status check.
377- BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
378- Optimize `LESS_USED` worker choice strategy.
379- Update benchmarks versus external threads pools.
380- Optimize tasks usage statistics requirements for worker choice strategy.
381
382### Fixed
383
384- Ensure trimmable characters are checked at pool initialization.
385- Fix message id integer overflow.
386- Fix pool worker removal in worker choice strategy internals.
387- Fix package publication with pnpm.
388
389## [2.4.0-3] - 2023-04-04
390
391### Added
392
393- Add `LESS_BUSY` worker choice strategy.
394
395### Changed
396
397- Optimize worker storage in pool.
398- Optimize worker alive status check.
399- BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
400- Optimize `LESS_USED` worker choice strategy.
401- Update benchmarks versus external threads pools.
402
403### Fixed
404
405- Ensure trimmable characters are checked at pool initialization.
406- Fix message id integer overflow.
407- Fix pool worker removal in worker choice strategy internals.
408- Fix package publication with pnpm.
409
410## [2.4.0-2] - 2023-04-03
411
412### Added
413
414- Add `LESS_BUSY` worker choice strategy.
415
416### Changed
417
418- Optimize worker storage in pool.
419- Optimize worker alive status check.
420- BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
421- Optimize `LESS_USED` worker choice strategy.
422
423### Fixed
424
425- Ensure trimmable characters are checked at pool initialization.
426- Fix message id integer overflow.
427- Fix pool worker removal in worker choice strategy internals.
428- Fix package publication with pnpm.
429
430## [2.4.0-1] - 2023-04-03
431
432### Added
433
434- Add `LESS_BUSY` worker choice strategy.
435
436### Changed
437
438- Optimize worker storage in pool.
439- Optimize worker alive status check.
440- BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
441- Optimize `LESS_USED` worker choice strategy.
442
443### Fixed
444
445- Ensure trimmable characters are checked at pool initialization.
446- Fix message id integer overflow.
447- Fix pool worker removal in worker choice strategy internals.
448
449## [2.4.0-0] - 2023-04-03
450
451### Added
452
453- Add `LESS_BUSY` worker choice strategy.
454
455### Changed
456
457- Optimize worker storage in pool.
458- Optimize worker alive status check.
459- BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
460- Optimize `LESS_USED` worker choice strategy.
461
462### Fixed
463
464- Ensure trimmable characters are checked at pool initialization.
465- Fix message id integer overflow.
466- Fix pool worker removal in worker choice strategy internals.
467
468## [2.3.10] - 2023-03-18
469
470### Fixed
471
472- Fix `exports` syntax for ESM and CommonJS.
473
474### Changed
475
476- Permit SemVer pre-release publication.
477
478## [2.3.10-2] - 2023-03-18
479
480### Fixed
481
482- Fix `exports` syntax for ESM and CommonJS.
483
484## [2.3.10-1] - 2023-03-18
485
486### Changed
487
488- Permit SemVer pre-release publication.
489
490## [2.3.10-0] - 2023-03-18
491
492### Fixed
493
494- Fix `exports` syntax for ESM and CommonJS.
495
496## [2.3.9] - 2023-03-18
497
498### Changed
499
500- Introduce ESM module support along with CommonJS one.
501
502### Fixed
503
504- Fix brown paper bag bug referencing the same object literal.
505
506## [2.3.8] - 2023-03-18
507
508### Changed
509
510- Switch internal benchmarking code to benny.
511- Switch to TypeScript 5.x.x.
512- Switch rollup bundler plugins to core ones.
513- Switch to TSDoc syntax.
514- Enforce conventional commits.
515
516### Fixed
517
518- Fix random integer generator.
519- Fix worker choice strategy pool type identification at initialization.
520
521## [2.3.7] - 2022-10-23
522
523### Changed
524
525- Switch to open collective FOSS project funding platform.
526- Switch to ts-standard linter configuration on TypeScript code.
527
528### Fixed
529
530- Fixed missing async on pool execute method.
531- Fixed typing in TypeScript example.
532- Fixed types in unit tests.
533
534## [2.3.6] - 2022-10-22
535
536### Changed
537
538- Cleanup pool attributes and methods.
539- Refine error types thrown.
540
541### Fixed
542
543- Fix continuous integration build on windows.
544- Fix code coverage reporting by using c8 instead of nyc.
545
546## [2.3.5] - 2022-10-21
547
548### Changed
549
550- Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
551- Optimize tasks usage lookup implementation.
552
553### Fixed
554
555- Fix missed pool event emitter type export.
556- Fix typedoc documentation generation.
557
558## [2.3.4] - 2022-10-17
559
560### Added
561
562- Fully automate release process with release-it.
563
564### Changed
565
566- Optimize fair share task scheduling algorithm implementation.
567- Update benchmarks versus external pools results with latest version.
568
569## [2.3.3] - 2022-10-15
570
571### Added
572
573- Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
574
575## [2.3.2] - 2022-10-14
576
577### Changed
578
579- Optimize fair share worker selection strategy implementation.
580
581### Fixed
582
583- Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
584
585## [2.3.1] - 2022-10-13
586
587### Added
588
589- Pool worker choice strategies:
590 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
591 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
592
593## [2.2.2] - 2022-10-09
594
595### Fixed
596
597- Fixed `README.md` file.
598
599## [2.2.1] - 2022-10-08
600
601### Added
602
603- Dynamic worker choice strategy change at runtime.
604
605## [2.2.0] - 2022-01-05
606
607### Breaking Changes
608
609- Support only NodeJS version 16.x.x for cluster pool: upstream cluster API have changed on that version.
610
611## [2.1.0] - 2021-08-29
612
613### Added
614
615- Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
616
617### Breaking Changes
618
619- `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
620- `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
621- `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
622- `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
623
624## [2.0.2] - 2021-05-12
625
626### Bug fixes
627
628- Fix `busy` event emission on fixed pool type
629
630## [2.0.1] - 2021-03-16
631
632### Bug fixes
633
634- Check if pool options are properly set.
635- `busy` event is emitted on all pool types.
636
637## [2.0.0] - 2021-03-01
638
639### Bug fixes
640
641- Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
642
643### Breaking Changes
644
645- `FullPool` event is now renamed to `busy`.
646- `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
647 _Find more details on our JSDoc._
648
649- `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
650
651- We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
652
653### Pool options types declaration merge
654
655`FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
656
657#### New `export` strategy
658
659```js
660// Before
661const DynamicThreadPool = require('poolifier/lib/dynamic')
662// After
663const { DynamicThreadPool } = require('poolifier/lib/dynamic')
664```
665
666But you should always prefer just using
667
668```js
669const { DynamicThreadPool } = require('poolifier')
670```
671
672#### New type definitions for input data and response
673
674For cluster worker and worker-thread pools, you can now only send and receive structured-cloneable data.
675_This is not a limitation by poolifier but NodeJS._
676
677#### Public property replacements
678
679`numWorkers` property is now `numberOfWorkers`
680
681#### Internal (protected) properties and methods renaming
682
683These properties are not intended for end users
684
685- `id` => `nextMessageId`
686
687These methods are not intended for end users
688
689- `_chooseWorker` => `chooseWorker`
690- `_newWorker` => `createWorker`
691- `_execute` => `internalExecute`
692- `_chooseWorker` => `chooseWorker`
693- `_checkAlive` => `checkAlive`
694- `_run` => `run`
695- `_runAsync` => `runAsync`
696
697## [1.1.0] - 2020-05-21
698
699### Added
700
701- ThreadWorker support async functions as option
702- Various external library patches
703
704## [1.0.0] - 2020-01-24
705
706### Added
707
708- FixedThreadPool implementation
709- DynamicThreadPool implementation
710- WorkerThread implementation to improve developer experience