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