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