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