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