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