@soulcraft/brainy 0.52.0 → 0.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +154 -0
- package/dist/brainyData.d.ts +38 -0
- package/dist/brainyData.js +104 -3
- package/dist/brainyData.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/storage/adapters/s3CompatibleStorage.d.ts +2 -0
- package/dist/storage/adapters/s3CompatibleStorage.js +46 -65
- package/dist/storage/adapters/s3CompatibleStorage.js.map +1 -1
- package/dist/utils/adaptiveBackpressure.d.ts +103 -0
- package/dist/utils/adaptiveBackpressure.js +342 -0
- package/dist/utils/adaptiveBackpressure.js.map +1 -0
- package/dist/utils/adaptiveSocketManager.d.ts +117 -0
- package/dist/utils/adaptiveSocketManager.js +378 -0
- package/dist/utils/adaptiveSocketManager.js.map +1 -0
- package/dist/utils/performanceMonitor.d.ts +114 -0
- package/dist/utils/performanceMonitor.js +384 -0
- package/dist/utils/performanceMonitor.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adaptive Socket Manager
|
|
3
|
+
* Automatically manages socket pools and connection settings based on load patterns
|
|
4
|
+
* Zero-configuration approach that learns and adapts to workload characteristics
|
|
5
|
+
*/
|
|
6
|
+
import { Agent as HttpsAgent } from 'https';
|
|
7
|
+
import { NodeHttpHandler } from '@smithy/node-http-handler';
|
|
8
|
+
import { createModuleLogger } from './logger.js';
|
|
9
|
+
/**
|
|
10
|
+
* Adaptive Socket Manager that automatically scales based on load patterns
|
|
11
|
+
*/
|
|
12
|
+
export class AdaptiveSocketManager {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.logger = createModuleLogger('AdaptiveSocketManager');
|
|
15
|
+
// Current configuration
|
|
16
|
+
this.config = {
|
|
17
|
+
maxSockets: 100, // Start conservative
|
|
18
|
+
maxFreeSockets: 20,
|
|
19
|
+
keepAliveTimeout: 60000,
|
|
20
|
+
connectionTimeout: 10000,
|
|
21
|
+
socketTimeout: 60000,
|
|
22
|
+
batchSize: 10
|
|
23
|
+
};
|
|
24
|
+
// Performance tracking
|
|
25
|
+
this.metrics = {
|
|
26
|
+
requestsPerSecond: 0,
|
|
27
|
+
pendingRequests: 0,
|
|
28
|
+
socketUtilization: 0,
|
|
29
|
+
errorRate: 0,
|
|
30
|
+
latencyP50: 0,
|
|
31
|
+
latencyP95: 0,
|
|
32
|
+
memoryUsage: 0
|
|
33
|
+
};
|
|
34
|
+
// Historical data for learning
|
|
35
|
+
this.history = [];
|
|
36
|
+
this.maxHistorySize = 100;
|
|
37
|
+
// Adaptation state
|
|
38
|
+
this.lastAdaptationTime = 0;
|
|
39
|
+
this.adaptationInterval = 5000; // Check every 5 seconds
|
|
40
|
+
this.consecutiveHighLoad = 0;
|
|
41
|
+
this.consecutiveLowLoad = 0;
|
|
42
|
+
// Request tracking
|
|
43
|
+
this.requestStartTimes = new Map();
|
|
44
|
+
this.requestLatencies = [];
|
|
45
|
+
this.errorCount = 0;
|
|
46
|
+
this.successCount = 0;
|
|
47
|
+
this.lastMetricReset = Date.now();
|
|
48
|
+
// Socket pool instances
|
|
49
|
+
this.currentAgent = null;
|
|
50
|
+
this.currentHandler = null;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Get or create an optimized HTTP handler
|
|
54
|
+
*/
|
|
55
|
+
getHttpHandler() {
|
|
56
|
+
// Adapt configuration if needed
|
|
57
|
+
this.adaptIfNeeded();
|
|
58
|
+
// Create new handler if configuration changed
|
|
59
|
+
if (!this.currentHandler || this.shouldRecreateHandler()) {
|
|
60
|
+
this.currentAgent = new HttpsAgent({
|
|
61
|
+
keepAlive: true,
|
|
62
|
+
maxSockets: this.config.maxSockets,
|
|
63
|
+
maxFreeSockets: this.config.maxFreeSockets,
|
|
64
|
+
timeout: this.config.keepAliveTimeout,
|
|
65
|
+
scheduling: 'fifo' // Fair scheduling for high-volume scenarios
|
|
66
|
+
});
|
|
67
|
+
this.currentHandler = new NodeHttpHandler({
|
|
68
|
+
httpsAgent: this.currentAgent,
|
|
69
|
+
connectionTimeout: this.config.connectionTimeout,
|
|
70
|
+
socketTimeout: this.config.socketTimeout
|
|
71
|
+
});
|
|
72
|
+
this.logger.debug('Created new HTTP handler with config:', this.config);
|
|
73
|
+
}
|
|
74
|
+
return this.currentHandler;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Get current batch size recommendation
|
|
78
|
+
*/
|
|
79
|
+
getBatchSize() {
|
|
80
|
+
this.adaptIfNeeded();
|
|
81
|
+
return this.config.batchSize;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Track request start
|
|
85
|
+
*/
|
|
86
|
+
trackRequestStart(requestId) {
|
|
87
|
+
this.requestStartTimes.set(requestId, Date.now());
|
|
88
|
+
this.metrics.pendingRequests++;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Track request completion
|
|
92
|
+
*/
|
|
93
|
+
trackRequestComplete(requestId, success) {
|
|
94
|
+
const startTime = this.requestStartTimes.get(requestId);
|
|
95
|
+
if (startTime) {
|
|
96
|
+
const latency = Date.now() - startTime;
|
|
97
|
+
this.requestLatencies.push(latency);
|
|
98
|
+
this.requestStartTimes.delete(requestId);
|
|
99
|
+
// Keep latency array bounded
|
|
100
|
+
if (this.requestLatencies.length > 1000) {
|
|
101
|
+
this.requestLatencies = this.requestLatencies.slice(-500);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (success) {
|
|
105
|
+
this.successCount++;
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
this.errorCount++;
|
|
109
|
+
}
|
|
110
|
+
this.metrics.pendingRequests = Math.max(0, this.metrics.pendingRequests - 1);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Check if we should adapt configuration
|
|
114
|
+
*/
|
|
115
|
+
adaptIfNeeded() {
|
|
116
|
+
const now = Date.now();
|
|
117
|
+
if (now - this.lastAdaptationTime < this.adaptationInterval) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
this.lastAdaptationTime = now;
|
|
121
|
+
this.updateMetrics();
|
|
122
|
+
this.analyzeAndAdapt();
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Update current metrics
|
|
126
|
+
*/
|
|
127
|
+
updateMetrics() {
|
|
128
|
+
const now = Date.now();
|
|
129
|
+
const timeSinceReset = (now - this.lastMetricReset) / 1000;
|
|
130
|
+
// Calculate requests per second
|
|
131
|
+
const totalRequests = this.successCount + this.errorCount;
|
|
132
|
+
this.metrics.requestsPerSecond = timeSinceReset > 0
|
|
133
|
+
? totalRequests / timeSinceReset
|
|
134
|
+
: 0;
|
|
135
|
+
// Calculate error rate
|
|
136
|
+
this.metrics.errorRate = totalRequests > 0
|
|
137
|
+
? this.errorCount / totalRequests
|
|
138
|
+
: 0;
|
|
139
|
+
// Calculate latency percentiles
|
|
140
|
+
if (this.requestLatencies.length > 0) {
|
|
141
|
+
const sorted = [...this.requestLatencies].sort((a, b) => a - b);
|
|
142
|
+
const p50Index = Math.floor(sorted.length * 0.5);
|
|
143
|
+
const p95Index = Math.floor(sorted.length * 0.95);
|
|
144
|
+
this.metrics.latencyP50 = sorted[p50Index] || 0;
|
|
145
|
+
this.metrics.latencyP95 = sorted[p95Index] || 0;
|
|
146
|
+
}
|
|
147
|
+
// Calculate socket utilization
|
|
148
|
+
this.metrics.socketUtilization = this.metrics.pendingRequests / this.config.maxSockets;
|
|
149
|
+
// Memory usage
|
|
150
|
+
if (typeof process !== 'undefined' && process.memoryUsage) {
|
|
151
|
+
const memUsage = process.memoryUsage();
|
|
152
|
+
this.metrics.memoryUsage = memUsage.heapUsed / memUsage.heapTotal;
|
|
153
|
+
}
|
|
154
|
+
// Add to history
|
|
155
|
+
this.history.push({ ...this.metrics });
|
|
156
|
+
if (this.history.length > this.maxHistorySize) {
|
|
157
|
+
this.history.shift();
|
|
158
|
+
}
|
|
159
|
+
// Reset counters periodically
|
|
160
|
+
if (timeSinceReset > 60) {
|
|
161
|
+
this.lastMetricReset = now;
|
|
162
|
+
this.successCount = 0;
|
|
163
|
+
this.errorCount = 0;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Analyze metrics and adapt configuration
|
|
168
|
+
*/
|
|
169
|
+
analyzeAndAdapt() {
|
|
170
|
+
const wasConfig = { ...this.config };
|
|
171
|
+
// Detect high load conditions
|
|
172
|
+
const isHighLoad = this.detectHighLoad();
|
|
173
|
+
const isLowLoad = this.detectLowLoad();
|
|
174
|
+
const hasErrors = this.metrics.errorRate > 0.01; // More than 1% errors
|
|
175
|
+
if (isHighLoad) {
|
|
176
|
+
this.consecutiveHighLoad++;
|
|
177
|
+
this.consecutiveLowLoad = 0;
|
|
178
|
+
if (this.consecutiveHighLoad >= 2) { // Wait for 2 consecutive high load readings
|
|
179
|
+
this.scaleUp();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
else if (isLowLoad) {
|
|
183
|
+
this.consecutiveLowLoad++;
|
|
184
|
+
this.consecutiveHighLoad = 0;
|
|
185
|
+
if (this.consecutiveLowLoad >= 6) { // Wait longer before scaling down
|
|
186
|
+
this.scaleDown();
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
// Reset counters if load is normal
|
|
191
|
+
this.consecutiveHighLoad = Math.max(0, this.consecutiveHighLoad - 1);
|
|
192
|
+
this.consecutiveLowLoad = Math.max(0, this.consecutiveLowLoad - 1);
|
|
193
|
+
}
|
|
194
|
+
// Handle error conditions
|
|
195
|
+
if (hasErrors) {
|
|
196
|
+
this.handleErrors();
|
|
197
|
+
}
|
|
198
|
+
// Log significant changes
|
|
199
|
+
if (JSON.stringify(wasConfig) !== JSON.stringify(this.config)) {
|
|
200
|
+
this.logger.info('Adapted configuration', {
|
|
201
|
+
from: wasConfig,
|
|
202
|
+
to: this.config,
|
|
203
|
+
metrics: this.metrics
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Detect high load conditions
|
|
209
|
+
*/
|
|
210
|
+
detectHighLoad() {
|
|
211
|
+
return (this.metrics.socketUtilization > 0.7 || // Sockets heavily used
|
|
212
|
+
this.metrics.pendingRequests > this.config.maxSockets * 0.8 || // Many pending requests
|
|
213
|
+
this.metrics.latencyP95 > 5000 || // High latency
|
|
214
|
+
this.metrics.requestsPerSecond > 100 // High request rate
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Detect low load conditions
|
|
219
|
+
*/
|
|
220
|
+
detectLowLoad() {
|
|
221
|
+
return (this.metrics.socketUtilization < 0.2 && // Sockets barely used
|
|
222
|
+
this.metrics.pendingRequests < 5 && // Few pending requests
|
|
223
|
+
this.metrics.latencyP95 < 1000 && // Low latency
|
|
224
|
+
this.metrics.requestsPerSecond < 10 && // Low request rate
|
|
225
|
+
this.metrics.memoryUsage < 0.5 // Low memory usage
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Scale up resources for high load
|
|
230
|
+
*/
|
|
231
|
+
scaleUp() {
|
|
232
|
+
// Increase socket limits progressively
|
|
233
|
+
const scaleFactor = this.metrics.errorRate > 0.05 ? 1.5 : 2.0; // Scale more aggressively if no errors
|
|
234
|
+
this.config.maxSockets = Math.min(2000, // Hard limit to prevent resource exhaustion
|
|
235
|
+
Math.ceil(this.config.maxSockets * scaleFactor));
|
|
236
|
+
this.config.maxFreeSockets = Math.min(200, Math.ceil(this.config.maxSockets * 0.1) // Keep 10% as free sockets
|
|
237
|
+
);
|
|
238
|
+
// Increase batch size for better throughput
|
|
239
|
+
this.config.batchSize = Math.min(100, Math.ceil(this.config.batchSize * 1.5));
|
|
240
|
+
// Adjust timeouts for high load
|
|
241
|
+
this.config.keepAliveTimeout = 120000; // Keep connections alive longer
|
|
242
|
+
this.config.connectionTimeout = 15000; // Allow more time for connections
|
|
243
|
+
this.config.socketTimeout = 90000; // Allow more time for responses
|
|
244
|
+
this.logger.debug('Scaled up for high load', {
|
|
245
|
+
sockets: this.config.maxSockets,
|
|
246
|
+
batchSize: this.config.batchSize
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Scale down resources for low load
|
|
251
|
+
*/
|
|
252
|
+
scaleDown() {
|
|
253
|
+
// Only scale down if memory pressure is low
|
|
254
|
+
if (this.metrics.memoryUsage > 0.7) {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
// Decrease socket limits conservatively
|
|
258
|
+
this.config.maxSockets = Math.max(50, // Minimum sockets
|
|
259
|
+
Math.floor(this.config.maxSockets * 0.7));
|
|
260
|
+
this.config.maxFreeSockets = Math.max(10, Math.floor(this.config.maxSockets * 0.2) // Keep 20% as free sockets
|
|
261
|
+
);
|
|
262
|
+
// Decrease batch size
|
|
263
|
+
this.config.batchSize = Math.max(5, Math.floor(this.config.batchSize * 0.7));
|
|
264
|
+
// Adjust timeouts for low load
|
|
265
|
+
this.config.keepAliveTimeout = 60000;
|
|
266
|
+
this.config.connectionTimeout = 10000;
|
|
267
|
+
this.config.socketTimeout = 60000;
|
|
268
|
+
this.logger.debug('Scaled down for low load', {
|
|
269
|
+
sockets: this.config.maxSockets,
|
|
270
|
+
batchSize: this.config.batchSize
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Handle error conditions by adjusting configuration
|
|
275
|
+
*/
|
|
276
|
+
handleErrors() {
|
|
277
|
+
const errorRate = this.metrics.errorRate;
|
|
278
|
+
if (errorRate > 0.1) { // More than 10% errors
|
|
279
|
+
// Severe errors - back off aggressively
|
|
280
|
+
this.config.maxSockets = Math.max(50, Math.floor(this.config.maxSockets * 0.5));
|
|
281
|
+
this.config.batchSize = Math.max(1, Math.floor(this.config.batchSize * 0.3));
|
|
282
|
+
this.config.connectionTimeout = Math.min(30000, this.config.connectionTimeout * 2);
|
|
283
|
+
this.config.socketTimeout = Math.min(120000, this.config.socketTimeout * 2);
|
|
284
|
+
this.logger.warn('High error rate detected, backing off', {
|
|
285
|
+
errorRate,
|
|
286
|
+
newConfig: this.config
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
else if (errorRate > 0.05) { // More than 5% errors
|
|
290
|
+
// Moderate errors - reduce load slightly
|
|
291
|
+
this.config.batchSize = Math.max(1, Math.floor(this.config.batchSize * 0.7));
|
|
292
|
+
this.config.connectionTimeout = Math.min(20000, this.config.connectionTimeout * 1.2);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Check if we should recreate the handler
|
|
297
|
+
*/
|
|
298
|
+
shouldRecreateHandler() {
|
|
299
|
+
if (!this.currentAgent)
|
|
300
|
+
return true;
|
|
301
|
+
// Recreate if socket configuration changed significantly
|
|
302
|
+
const currentMaxSockets = this.currentAgent.maxSockets;
|
|
303
|
+
const socketsDiff = Math.abs(currentMaxSockets - this.config.maxSockets);
|
|
304
|
+
return socketsDiff > currentMaxSockets * 0.5; // 50% change threshold
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Get current configuration (for monitoring)
|
|
308
|
+
*/
|
|
309
|
+
getConfig() {
|
|
310
|
+
return { ...this.config };
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Get current metrics (for monitoring)
|
|
314
|
+
*/
|
|
315
|
+
getMetrics() {
|
|
316
|
+
return { ...this.metrics };
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Predict optimal configuration based on historical data
|
|
320
|
+
*/
|
|
321
|
+
predictOptimalConfig() {
|
|
322
|
+
if (this.history.length < 10) {
|
|
323
|
+
return this.config; // Not enough data to predict
|
|
324
|
+
}
|
|
325
|
+
// Analyze recent history
|
|
326
|
+
const recentHistory = this.history.slice(-20);
|
|
327
|
+
const avgRPS = recentHistory.reduce((sum, m) => sum + m.requestsPerSecond, 0) / recentHistory.length;
|
|
328
|
+
const maxRPS = Math.max(...recentHistory.map(m => m.requestsPerSecond));
|
|
329
|
+
const avgLatency = recentHistory.reduce((sum, m) => sum + m.latencyP95, 0) / recentHistory.length;
|
|
330
|
+
// Predict optimal socket count based on request patterns
|
|
331
|
+
const optimalSockets = Math.min(2000, Math.max(50, Math.ceil(maxRPS * 2)));
|
|
332
|
+
// Predict optimal batch size based on latency
|
|
333
|
+
const optimalBatchSize = avgLatency < 1000 ? 50 : avgLatency < 3000 ? 20 : 10;
|
|
334
|
+
return {
|
|
335
|
+
maxSockets: optimalSockets,
|
|
336
|
+
maxFreeSockets: Math.ceil(optimalSockets * 0.15),
|
|
337
|
+
keepAliveTimeout: avgRPS > 50 ? 120000 : 60000,
|
|
338
|
+
connectionTimeout: avgLatency > 3000 ? 20000 : 10000,
|
|
339
|
+
socketTimeout: avgLatency > 3000 ? 90000 : 60000,
|
|
340
|
+
batchSize: optimalBatchSize
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Reset to default configuration
|
|
345
|
+
*/
|
|
346
|
+
reset() {
|
|
347
|
+
this.config = {
|
|
348
|
+
maxSockets: 100,
|
|
349
|
+
maxFreeSockets: 20,
|
|
350
|
+
keepAliveTimeout: 60000,
|
|
351
|
+
connectionTimeout: 10000,
|
|
352
|
+
socketTimeout: 60000,
|
|
353
|
+
batchSize: 10
|
|
354
|
+
};
|
|
355
|
+
this.consecutiveHighLoad = 0;
|
|
356
|
+
this.consecutiveLowLoad = 0;
|
|
357
|
+
this.history = [];
|
|
358
|
+
this.requestLatencies = [];
|
|
359
|
+
this.errorCount = 0;
|
|
360
|
+
this.successCount = 0;
|
|
361
|
+
// Force recreation of handler
|
|
362
|
+
this.currentAgent = null;
|
|
363
|
+
this.currentHandler = null;
|
|
364
|
+
this.logger.info('Reset to default configuration');
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
// Global singleton instance
|
|
368
|
+
let globalSocketManager = null;
|
|
369
|
+
/**
|
|
370
|
+
* Get the global socket manager instance
|
|
371
|
+
*/
|
|
372
|
+
export function getGlobalSocketManager() {
|
|
373
|
+
if (!globalSocketManager) {
|
|
374
|
+
globalSocketManager = new AdaptiveSocketManager();
|
|
375
|
+
}
|
|
376
|
+
return globalSocketManager;
|
|
377
|
+
}
|
|
378
|
+
//# sourceMappingURL=adaptiveSocketManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adaptiveSocketManager.js","sourceRoot":"","sources":["../../src/utils/adaptiveSocketManager.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,OAAO,CAAA;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAqBhD;;GAEG;AACH,MAAM,OAAO,qBAAqB;IAAlC;QACU,WAAM,GAAG,kBAAkB,CAAC,uBAAuB,CAAC,CAAA;QAE5D,wBAAwB;QAChB,WAAM,GAAmB;YAC/B,UAAU,EAAE,GAAG,EAAG,qBAAqB;YACvC,cAAc,EAAE,EAAE;YAClB,gBAAgB,EAAE,KAAK;YACvB,iBAAiB,EAAE,KAAK;YACxB,aAAa,EAAE,KAAK;YACpB,SAAS,EAAE,EAAE;SACd,CAAA;QAED,uBAAuB;QACf,YAAO,GAAgB;YAC7B,iBAAiB,EAAE,CAAC;YACpB,eAAe,EAAE,CAAC;YAClB,iBAAiB,EAAE,CAAC;YACpB,SAAS,EAAE,CAAC;YACZ,UAAU,EAAE,CAAC;YACb,UAAU,EAAE,CAAC;YACb,WAAW,EAAE,CAAC;SACf,CAAA;QAED,+BAA+B;QACvB,YAAO,GAAkB,EAAE,CAAA;QAC3B,mBAAc,GAAG,GAAG,CAAA;QAE5B,mBAAmB;QACX,uBAAkB,GAAG,CAAC,CAAA;QACtB,uBAAkB,G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AC,MAAM,GAAG;YACZ,UAAU,EAAE,GAAG;YACf,cAAc,EAAE,EAAE;YAClB,gBAAgB,EAAE,KAAK;YACvB,iBAAiB,EAAE,KAAK;YACxB,aAAa,EAAE,KAAK;YACpB,SAAS,EAAE,EAAE;SACd,CAAA;QAED,IAAI,CAAC,mBAAmB,GAAG,CAAC,CAAA;QAC5B,IAAI,CAAC,kBAAkB,GAAG,CAAC,CAAA;QAC3B,IAAI,CAAC,OAAO,GAAG,EAAE,CAAA;QACjB,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAA;QAC1B,IAAI,CAAC,UAAU,GAAG,CAAC,CAAA;QACnB,IAAI,CAAC,YAAY,GAAG,CAAC,CAAA;QAErB,8BAA8B;QAC9B,IAAI,CAAC,YAAY,GAAG,IAAI,CAAA;QACxB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAA;QAE1B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAA;IACpD,CAAC;CACF;AAED,4BAA4B;AAC5B,IAAI,mBAAmB,GAAiC,IAAI,CAAA;AAE5D;;GAEG;AACH,MAAM,UAAU,sBAAsB;IACpC,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACzB,mBAAmB,GAAG,IAAI,qBAAqB,EAAE,CAAA;IACnD,CAAC;IACD,OAAO,mBAAmB,CAAA;AAC5B,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Performance Monitor
|
|
3
|
+
* Automatically tracks and optimizes system performance
|
|
4
|
+
* Provides real-time insights and auto-tuning recommendations
|
|
5
|
+
*/
|
|
6
|
+
interface PerformanceMetrics {
|
|
7
|
+
totalOperations: number;
|
|
8
|
+
successfulOperations: number;
|
|
9
|
+
failedOperations: number;
|
|
10
|
+
averageLatency: number;
|
|
11
|
+
p95Latency: number;
|
|
12
|
+
p99Latency: number;
|
|
13
|
+
operationsPerSecond: number;
|
|
14
|
+
bytesPerSecond: number;
|
|
15
|
+
memoryUsage: number;
|
|
16
|
+
cpuUsage: number;
|
|
17
|
+
socketUtilization: number;
|
|
18
|
+
queueDepth: number;
|
|
19
|
+
errorRate: number;
|
|
20
|
+
healthScore: number;
|
|
21
|
+
}
|
|
22
|
+
interface PerformanceTrend {
|
|
23
|
+
metric: string;
|
|
24
|
+
direction: 'improving' | 'degrading' | 'stable';
|
|
25
|
+
changeRate: number;
|
|
26
|
+
prediction: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Comprehensive performance monitoring and optimization
|
|
30
|
+
*/
|
|
31
|
+
export declare class PerformanceMonitor {
|
|
32
|
+
private logger;
|
|
33
|
+
private metrics;
|
|
34
|
+
private history;
|
|
35
|
+
private maxHistorySize;
|
|
36
|
+
private operationLatencies;
|
|
37
|
+
private operationSizes;
|
|
38
|
+
private lastReset;
|
|
39
|
+
private resetInterval;
|
|
40
|
+
private lastCpuUsage;
|
|
41
|
+
private lastCpuCheck;
|
|
42
|
+
private thresholds;
|
|
43
|
+
private recommendations;
|
|
44
|
+
private autoOptimizeEnabled;
|
|
45
|
+
private lastOptimization;
|
|
46
|
+
private optimizationInterval;
|
|
47
|
+
/**
|
|
48
|
+
* Track an operation completion
|
|
49
|
+
*/
|
|
50
|
+
trackOperation(success: boolean, latency: number, bytes?: number): void;
|
|
51
|
+
/**
|
|
52
|
+
* Update all metrics
|
|
53
|
+
*/
|
|
54
|
+
private updateMetrics;
|
|
55
|
+
/**
|
|
56
|
+
* Update resource metrics
|
|
57
|
+
*/
|
|
58
|
+
private updateResourceMetrics;
|
|
59
|
+
/**
|
|
60
|
+
* Calculate overall health score
|
|
61
|
+
*/
|
|
62
|
+
private calculateHealthScore;
|
|
63
|
+
/**
|
|
64
|
+
* Check for alert conditions
|
|
65
|
+
*/
|
|
66
|
+
private checkAlerts;
|
|
67
|
+
/**
|
|
68
|
+
* Auto-optimize system based on metrics
|
|
69
|
+
*/
|
|
70
|
+
private autoOptimize;
|
|
71
|
+
/**
|
|
72
|
+
* Analyze performance trends
|
|
73
|
+
*/
|
|
74
|
+
private analyzeTrends;
|
|
75
|
+
/**
|
|
76
|
+
* Reset counters
|
|
77
|
+
*/
|
|
78
|
+
private resetCounters;
|
|
79
|
+
/**
|
|
80
|
+
* Get current metrics
|
|
81
|
+
*/
|
|
82
|
+
getMetrics(): Readonly<PerformanceMetrics>;
|
|
83
|
+
/**
|
|
84
|
+
* Get performance trends
|
|
85
|
+
*/
|
|
86
|
+
getTrends(): PerformanceTrend[];
|
|
87
|
+
/**
|
|
88
|
+
* Get recommendations
|
|
89
|
+
*/
|
|
90
|
+
getRecommendations(): string[];
|
|
91
|
+
/**
|
|
92
|
+
* Get performance report
|
|
93
|
+
*/
|
|
94
|
+
getReport(): {
|
|
95
|
+
metrics: PerformanceMetrics;
|
|
96
|
+
trends: PerformanceTrend[];
|
|
97
|
+
recommendations: string[];
|
|
98
|
+
socketConfig: any;
|
|
99
|
+
backpressureStatus: any;
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Enable/disable auto-optimization
|
|
103
|
+
*/
|
|
104
|
+
setAutoOptimize(enabled: boolean): void;
|
|
105
|
+
/**
|
|
106
|
+
* Reset all metrics and history
|
|
107
|
+
*/
|
|
108
|
+
reset(): void;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Get the global performance monitor instance
|
|
112
|
+
*/
|
|
113
|
+
export declare function getGlobalPerformanceMonitor(): PerformanceMonitor;
|
|
114
|
+
export {};
|