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