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