test: add tests for worker choice strategies using median run time
[poolifier.git] / CHANGELOG.md
CommitLineData
522eea03 1# Changelog
2
3All notable changes to this project will be documented in this file.
4
d4abc60a 5The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
522eea03 6and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
45a5a54c
JB
8## [Unreleased]
9
d4aeae5a
JB
10### Fixed
11
12- Fix worker function type definition and validation.
2fc5cae3 13- Fix worker choice strategy options handling.
d4aeae5a 14
1d9e7023
JB
15## [2.4.8] - 2023-04-12
16
f9b4bbf8
JB
17### Fixed
18
19- Fix message between main worker and worker type definition for tasks.
20- Fix code documentation.
21
12ae3210
JB
22## [2.4.7] - 2023-04-11
23
7171d33f
JB
24### Added
25
26- Add worker tasks queue options to pool options.
27
e8bd29ce
JB
28### Fixed
29
30- Fix missing documentation.
31
42c7bc10
JB
32## [2.4.6] - 2023-04-10
33
681196cc
JB
34### Fixed
35
36- Ensure one task at a time is executed per worker with tasks queueing enabled.
76545787 37- Properly count worker running tasks with tasks queueing enabled.
681196cc 38
54d360e3
JB
39## [2.4.5] - 2023-04-09
40
3fafb1b2
JB
41### Added
42
43- Use monotonic high resolution timer for worker tasks run time.
44- Add worker tasks median run time to statistics.
ff733df7 45- Add worker tasks queue (experimental).
3fafb1b2 46
92fa3eb6
JB
47## [2.4.4] - 2023-04-07
48
aee46736
JB
49### Added
50
51- Add `PoolEvents` enumeration and `PoolEvent` type.
52
36b5e78f
JB
53### Fixed
54
ff0c2b3e 55- Destroy worker only on alive check.
36b5e78f 56
9fb0f324
JB
57## [2.4.3] - 2023-04-07
58
28cf3617
JB
59### Fixed
60
61- Fix typedoc generation with inheritance.
62
848f0f27
JB
63## [2.4.2] - 2023-04-06
64
164d950a
JB
65### Added
66
67- Add `full` event to dynamic pool.
32417142 68- Keep worker choice strategy in memory for conditional reuse.
164d950a 69
78ab2555
JB
70### Fixed
71
72- Fix possible negative worker key at worker removal in worker choice strategies.
73
79aafe9f
JB
74## [2.4.1] - 2023-04-05
75
9cd39dd4
JB
76### Changed
77
78- Optimize worker choice strategy for dynamic pool.
79
965415bb
JB
80### Fixed
81
82- Ensure dynamic pool does not alter worker choice strategy expected behavior.
83
d8b60b1c
JB
84## [2.4.0] - 2023-04-04
85
c6bd2650
JB
86### Added
87
88- Add `LESS_BUSY` worker choice strategy.
89
90### Changed
91
92- Optimize worker storage in pool.
93- Optimize worker alive status check.
94- BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
95- Optimize `LESS_USED` worker choice strategy.
96- Update benchmarks versus external threads pools.
97- Optimize tasks usage statistics requirements for worker choice strategy.
98
99### Fixed
100
101- Ensure trimmable characters are checked at pool initialization.
102- Fix message id integer overflow.
103- Fix pool worker removal in worker choice strategy internals.
104- Fix package publication with pnpm.
105
d0a3f018
JB
106## [2.4.0-3] - 2023-04-04
107
b2ede285
JB
108### Added
109
110- Add `LESS_BUSY` worker choice strategy.
111
112### Changed
113
114- Optimize worker storage in pool.
115- Optimize worker alive status check.
116- BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
117- Optimize `LESS_USED` worker choice strategy.
118- Update benchmarks versus external threads pools.
119
120### Fixed
121
122- Ensure trimmable characters are checked at pool initialization.
123- Fix message id integer overflow.
124- Fix pool worker removal in worker choice strategy internals.
125- Fix package publication with pnpm.
126
a015ea40
JB
127## [2.4.0-2] - 2023-04-03
128
698f4bbc
JB
129### Added
130
131- Add `LESS_BUSY` worker choice strategy.
132
133### Changed
134
135- Optimize worker storage in pool.
136- Optimize worker alive status check.
137- BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
138- Optimize `LESS_USED` worker choice strategy.
139
140### Fixed
141
142- Ensure trimmable characters are checked at pool initialization.
143- Fix message id integer overflow.
144- Fix pool worker removal in worker choice strategy internals.
145- Fix package publication with pnpm.
146
8fe15920
JB
147## [2.4.0-1] - 2023-04-03
148
5b301c28
JB
149### Added
150
151- Add `LESS_BUSY` worker choice strategy.
152
153### Changed
154
155- Optimize worker storage in pool.
156- Optimize worker alive status check.
157- BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
158- Optimize `LESS_USED` worker choice strategy.
159
160### Fixed
161
162- Ensure trimmable characters are checked at pool initialization.
163- Fix message id integer overflow.
164- Fix pool worker removal in worker choice strategy internals.
165
2fb9ca9c
JB
166## [2.4.0-0] - 2023-04-03
167
168c526f
JB
168### Added
169
170- Add `LESS_BUSY` worker choice strategy.
171
1d71a908
JB
172### Changed
173
ffcbbad8 174- Optimize worker storage in pool.
1d71a908 175- Optimize worker alive status check.
65a60b3b 176- BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
737c6d97 177- Optimize `LESS_USED` worker choice strategy.
1d71a908 178
ffcbbad8
JB
179### Fixed
180
181- Ensure trimmable characters are checked at pool initialization.
b4e75778 182- Fix message id integer overflow.
97a2abc3 183- Fix pool worker removal in worker choice strategy internals.
ffcbbad8 184
08372738
JB
185## [2.3.10] - 2023-03-18
186
710826bc
JB
187### Fixed
188
189- Fix `exports` syntax for ESM and CommonJS.
190
191### Changed
192
193- Permit SemVer pre-release publication.
76e5ac6f 194
e4796ecd
JB
195## [2.3.10-2] - 2023-03-18
196
6abad580
JB
197### Fixed
198
199- Fix `exports` syntax for ESM and CommonJS.
200
a2ee98cc
JB
201## [2.3.10-1] - 2023-03-18
202
7e060cee
JB
203### Changed
204
90483887 205- Permit SemVer pre-release publication.
7e060cee 206
c81bfafb
JB
207## [2.3.10-0] - 2023-03-18
208
fe18768d
JB
209### Fixed
210
211- Fix `exports` syntax for ESM and CommonJS.
212
d7b78217
JB
213## [2.3.9] - 2023-03-18
214
ed6dd37f
JB
215### Changed
216
217- Introduce ESM module support along with CommonJS one.
218
219### Fixed
220
221- Fix brown paper bag bug referencing the same object literal.
222
68e2ad86
JB
223## [2.3.8] - 2023-03-18
224
ca6c7d70
JB
225### Changed
226
227- Switch internal benchmarking code to benny.
fbdedeb9
JB
228- Switch to TypeScript 5.x.x.
229- Switch rollup bundler plugins to core ones.
ed6dd37f 230- Switch to TSDoc syntax.
fbdedeb9 231- Enforce conventional commits.
ca6c7d70 232
d15211d4
JB
233### Fixed
234
235- Fix random integer generator.
fbdedeb9 236- Fix worker choice strategy pool type identification at initialization.
d15211d4 237
995705ea
JB
238## [2.3.7] - 2022-10-23
239
b953022b
JB
240### Changed
241
242- Switch to open collective FOSS project funding platform.
78cea37e
JB
243- Switch to ts-standard linter configuration on TypeScript code.
244
245### Fixed
246
247- Fixed missing async on pool execute method.
248- Fixed typing in TypeScript example.
249- Fixed types in unit tests.
b953022b 250
3b9f6953
JB
251## [2.3.6] - 2022-10-22
252
f80cead4
JB
253### Changed
254
255- Cleanup pool attributes and methods.
256- Refine error types thrown.
257
258### Fixed
259
260- Fix continuous integration build on windows.
261- Fix code coverage reporting by using c8 instead of nyc.
262
efc22107
JB
263## [2.3.5] - 2022-10-21
264
7a6a0a96
JB
265### Changed
266
a05c10de
JB
267- Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
268- Optimize tasks usage lookup implementation.
7a6a0a96 269
b4904890
JB
270### Fixed
271
272- Fix missed pool event emitter type export.
273- Fix typedoc documentation generation.
274
a875f8d1
JB
275## [2.3.4] - 2022-10-17
276
73cda448
JB
277### Added
278
279- Fully automate release process with release-it.
280
45a5a54c
JB
281### Changed
282
73cda448 283- Optimize fair share task scheduling algorithm implementation.
eb4a8a82 284- Update benchmarks versus external pools results with latest version.
45a5a54c 285
90ee1b18 286## [2.3.3] - 2022-10-15
1a76932b
JB
287
288### Added
289
290- Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
291
90ee1b18 292## [2.3.2] - 2022-10-14
11df3590
JB
293
294### Changed
295
296- Optimize fair share worker selection strategy implementation.
297
298### Fixed
299
300- Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
301
90ee1b18 302## [2.3.1] - 2022-10-13
23ff945a
JB
303
304### Added
305
306- Pool worker choice strategies:
307 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
308 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
309
90ee1b18 310## [2.2.2] - 2022-10-09
cb2b6c69
JB
311
312### Fixed
313
314- Fixed `README.md` file.
315
90ee1b18 316## [2.2.1] - 2022-10-08
bdacc2d2 317
bdaf31cd
JB
318### Added
319
320- Dynamic worker choice strategy change at runtime.
bdacc2d2 321
90ee1b18 322## [2.2.0] - 2022-01-05
7e0d447f
JB
323
324### Breaking Changes
325
326- Support only NodeJS version 16.x.x for cluster pool: upstream cluster API have changed on that version.
327
90ee1b18 328## [2.1.0] - 2021-08-29
35cf1c03
JB
329
330### Added
331
332- Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
e088a00c
JB
333
334### Breaking Changes
335
336- `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
337- `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
338- `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
c365b2d3 339- `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
e088a00c 340
90ee1b18 341## [2.0.2] - 2021-05-12
14916bf9
JB
342
343### Bug fixes
344
345- Fix `busy` event emission on fixed pool type
346
90ee1b18 347## [2.0.1] - 2021-03-16
7f685093
JB
348
349### Bug fixes
350
351- Check if pool options are properly set.
352- `busy` event is emitted on all pool types.
353
90ee1b18 354## [2.0.0] - 2021-03-01
fa0f5b28 355
f3f833ab 356### Bug fixes
d63d3be3 357
ddbeaffd 358- Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
d63d3be3 359
fa0f5b28
S
360### Breaking Changes
361
7f685093 362- `FullPool` event is now renamed to `busy`.
1927ee67 363- `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
1a81f8af 364 _Find more details on our JSDoc._
ddbeaffd 365
1927ee67
APA
366- `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
367
ddbeaffd 368- We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
fa0f5b28 369
ec2ccfc8
JB
370### Pool options types declaration merge
371
372`FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
373
fa0f5b28
S
374#### New `export` strategy
375
376```js
377// Before
777b7824 378const DynamicThreadPool = require('poolifier/lib/dynamic')
fa0f5b28 379// After
777b7824 380const { DynamicThreadPool } = require('poolifier/lib/dynamic')
fa0f5b28
S
381```
382
383But you should always prefer just using
384
385```js
777b7824 386const { DynamicThreadPool } = require('poolifier')
fa0f5b28
S
387```
388
d3c8a1a8
S
389#### New type definitions for input data and response
390
ec2ccfc8 391For cluster worker and worker-thread pools, you can now only send and receive serializable data.
d3c8a1a8
S
392_This is not a limitation by poolifier but NodeJS._
393
3a4b605f 394#### Public property replacements
5c5a1fb7 395
3a4b605f 396`numWorkers` property is now `numberOfWorkers`
5c5a1fb7 397
280c2a77 398#### Internal (protected) properties and methods renaming
fa0f5b28 399
280c2a77
S
400These properties are not intended for end users
401
402- `id` => `nextMessageId`
403
404These methods are not intended for end users
fa0f5b28
S
405
406- `_chooseWorker` => `chooseWorker`
280c2a77 407- `_newWorker` => `createWorker`
fa0f5b28
S
408- `_execute` => `internalExecute`
409- `_chooseWorker` => `chooseWorker`
410- `_checkAlive` => `checkAlive`
411- `_run` => `run`
412- `_runAsync` => `runAsync`
413
90ee1b18 414## [1.1.0] - 2020-05-21
0312f71a
APA
415
416### Added
417
418- ThreadWorker support async functions as option
cf9aa6c3 419- Various external library patches
0312f71a 420
90ee1b18 421## [1.0.0] - 2020-01-24
522eea03 422
423### Added
424
425- FixedThreadPool implementation
426- DynamicThreadPool implementation
0312f71a 427- WorkerThread implementation to improve developer experience