@soulcraft/brainy 0.53.0 → 0.54.1
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/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 +44 -0
- package/dist/storage/adapters/s3CompatibleStorage.js +270 -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/dist/utils/requestCoalescer.d.ts +91 -0
- package/dist/utils/requestCoalescer.js +324 -0
- package/dist/utils/requestCoalescer.js.map +1 -0
- package/dist/utils/writeBuffer.d.ts +93 -0
- package/dist/utils/writeBuffer.js +324 -0
- package/dist/utils/writeBuffer.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Performance Monitor
|
|
3
|
+
* Automatically tracks and optimizes system performance
|
|
4
|
+
* Provides real-time insights and auto-tuning recommendations
|
|
5
|
+
*/
|
|
6
|
+
import { createModuleLogger } from './logger.js';
|
|
7
|
+
import { getGlobalSocketManager } from './adaptiveSocketManager.js';
|
|
8
|
+
import { getGlobalBackpressure } from './adaptiveBackpressure.js';
|
|
9
|
+
/**
|
|
10
|
+
* Comprehensive performance monitoring and optimization
|
|
11
|
+
*/
|
|
12
|
+
export class PerformanceMonitor {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.logger = createModuleLogger('PerformanceMonitor');
|
|
15
|
+
// Current metrics
|
|
16
|
+
this.metrics = {
|
|
17
|
+
totalOperations: 0,
|
|
18
|
+
successfulOperations: 0,
|
|
19
|
+
failedOperations: 0,
|
|
20
|
+
averageLatency: 0,
|
|
21
|
+
p95Latency: 0,
|
|
22
|
+
p99Latency: 0,
|
|
23
|
+
operationsPerSecond: 0,
|
|
24
|
+
bytesPerSecond: 0,
|
|
25
|
+
memoryUsage: 0,
|
|
26
|
+
cpuUsage: 0,
|
|
27
|
+
socketUtilization: 0,
|
|
28
|
+
queueDepth: 0,
|
|
29
|
+
errorRate: 0,
|
|
30
|
+
healthScore: 100
|
|
31
|
+
};
|
|
32
|
+
// Historical data for trend analysis
|
|
33
|
+
this.history = [];
|
|
34
|
+
this.maxHistorySize = 1000;
|
|
35
|
+
// Operation tracking
|
|
36
|
+
this.operationLatencies = [];
|
|
37
|
+
this.operationSizes = [];
|
|
38
|
+
this.lastReset = Date.now();
|
|
39
|
+
this.resetInterval = 60000; // Reset counters every minute
|
|
40
|
+
// CPU tracking
|
|
41
|
+
this.lastCpuUsage = process.cpuUsage ? process.cpuUsage() : null;
|
|
42
|
+
this.lastCpuCheck = Date.now();
|
|
43
|
+
// Alert thresholds
|
|
44
|
+
this.thresholds = {
|
|
45
|
+
errorRate: 0.05, // 5% error rate
|
|
46
|
+
latencyP95: 5000, // 5 second P95
|
|
47
|
+
memoryUsage: 0.8, // 80% memory
|
|
48
|
+
cpuUsage: 0.9, // 90% CPU
|
|
49
|
+
healthScore: 70 // Health score below 70
|
|
50
|
+
};
|
|
51
|
+
// Optimization recommendations
|
|
52
|
+
this.recommendations = [];
|
|
53
|
+
// Auto-optimization state
|
|
54
|
+
this.autoOptimizeEnabled = true;
|
|
55
|
+
this.lastOptimization = Date.now();
|
|
56
|
+
this.optimizationInterval = 30000; // Optimize every 30 seconds
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Track an operation completion
|
|
60
|
+
*/
|
|
61
|
+
trackOperation(success, latency, bytes = 0) {
|
|
62
|
+
// Update counters
|
|
63
|
+
this.metrics.totalOperations++;
|
|
64
|
+
if (success) {
|
|
65
|
+
this.metrics.successfulOperations++;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
this.metrics.failedOperations++;
|
|
69
|
+
}
|
|
70
|
+
// Track latency
|
|
71
|
+
this.operationLatencies.push(latency);
|
|
72
|
+
if (this.operationLatencies.length > 10000) {
|
|
73
|
+
this.operationLatencies = this.operationLatencies.slice(-5000);
|
|
74
|
+
}
|
|
75
|
+
// Track size
|
|
76
|
+
if (bytes > 0) {
|
|
77
|
+
this.operationSizes.push(bytes);
|
|
78
|
+
if (this.operationSizes.length > 10000) {
|
|
79
|
+
this.operationSizes = this.operationSizes.slice(-5000);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// Update metrics periodically
|
|
83
|
+
this.updateMetrics();
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Update all metrics
|
|
87
|
+
*/
|
|
88
|
+
updateMetrics() {
|
|
89
|
+
const now = Date.now();
|
|
90
|
+
const timeSinceReset = (now - this.lastReset) / 1000;
|
|
91
|
+
// Calculate latency percentiles
|
|
92
|
+
if (this.operationLatencies.length > 0) {
|
|
93
|
+
const sorted = [...this.operationLatencies].sort((a, b) => a - b);
|
|
94
|
+
const p95Index = Math.floor(sorted.length * 0.95);
|
|
95
|
+
const p99Index = Math.floor(sorted.length * 0.99);
|
|
96
|
+
this.metrics.averageLatency = sorted.reduce((a, b) => a + b, 0) / sorted.length;
|
|
97
|
+
this.metrics.p95Latency = sorted[p95Index] || 0;
|
|
98
|
+
this.metrics.p99Latency = sorted[p99Index] || 0;
|
|
99
|
+
}
|
|
100
|
+
// Calculate throughput
|
|
101
|
+
if (timeSinceReset > 0) {
|
|
102
|
+
this.metrics.operationsPerSecond = this.metrics.totalOperations / timeSinceReset;
|
|
103
|
+
const totalBytes = this.operationSizes.reduce((a, b) => a + b, 0);
|
|
104
|
+
this.metrics.bytesPerSecond = totalBytes / timeSinceReset;
|
|
105
|
+
}
|
|
106
|
+
// Calculate error rate
|
|
107
|
+
this.metrics.errorRate = this.metrics.totalOperations > 0
|
|
108
|
+
? this.metrics.failedOperations / this.metrics.totalOperations
|
|
109
|
+
: 0;
|
|
110
|
+
// Update resource metrics
|
|
111
|
+
this.updateResourceMetrics();
|
|
112
|
+
// Calculate health score
|
|
113
|
+
this.calculateHealthScore();
|
|
114
|
+
// Store in history
|
|
115
|
+
this.history.push({ ...this.metrics });
|
|
116
|
+
if (this.history.length > this.maxHistorySize) {
|
|
117
|
+
this.history.shift();
|
|
118
|
+
}
|
|
119
|
+
// Check for alerts
|
|
120
|
+
this.checkAlerts();
|
|
121
|
+
// Auto-optimize if enabled
|
|
122
|
+
if (this.autoOptimizeEnabled && now - this.lastOptimization > this.optimizationInterval) {
|
|
123
|
+
this.autoOptimize();
|
|
124
|
+
this.lastOptimization = now;
|
|
125
|
+
}
|
|
126
|
+
// Reset counters periodically
|
|
127
|
+
if (now - this.lastReset > this.resetInterval) {
|
|
128
|
+
this.resetCounters();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Update resource metrics
|
|
133
|
+
*/
|
|
134
|
+
updateResourceMetrics() {
|
|
135
|
+
// Memory usage
|
|
136
|
+
if (typeof process !== 'undefined' && process.memoryUsage) {
|
|
137
|
+
const memUsage = process.memoryUsage();
|
|
138
|
+
this.metrics.memoryUsage = memUsage.heapUsed / memUsage.heapTotal;
|
|
139
|
+
}
|
|
140
|
+
// CPU usage (Node.js only)
|
|
141
|
+
if (this.lastCpuUsage && process.cpuUsage) {
|
|
142
|
+
const currentCpuUsage = process.cpuUsage();
|
|
143
|
+
const now = Date.now();
|
|
144
|
+
const timeDiff = now - this.lastCpuCheck;
|
|
145
|
+
if (timeDiff > 1000) { // Update CPU every second
|
|
146
|
+
const userDiff = currentCpuUsage.user - this.lastCpuUsage.user;
|
|
147
|
+
const systemDiff = currentCpuUsage.system - this.lastCpuUsage.system;
|
|
148
|
+
const totalDiff = userDiff + systemDiff;
|
|
149
|
+
// CPU percentage (approximate)
|
|
150
|
+
this.metrics.cpuUsage = totalDiff / (timeDiff * 1000);
|
|
151
|
+
this.lastCpuUsage = currentCpuUsage;
|
|
152
|
+
this.lastCpuCheck = now;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
// Get metrics from socket manager
|
|
156
|
+
const socketMetrics = getGlobalSocketManager().getMetrics();
|
|
157
|
+
this.metrics.socketUtilization = socketMetrics.socketUtilization;
|
|
158
|
+
// Get metrics from backpressure system
|
|
159
|
+
const backpressureStatus = getGlobalBackpressure().getStatus();
|
|
160
|
+
this.metrics.queueDepth = backpressureStatus.queueLength;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Calculate overall health score
|
|
164
|
+
*/
|
|
165
|
+
calculateHealthScore() {
|
|
166
|
+
let score = 100;
|
|
167
|
+
// Deduct points for high error rate
|
|
168
|
+
if (this.metrics.errorRate > 0.01) {
|
|
169
|
+
score -= Math.min(30, this.metrics.errorRate * 300);
|
|
170
|
+
}
|
|
171
|
+
// Deduct points for high latency
|
|
172
|
+
if (this.metrics.p95Latency > 3000) {
|
|
173
|
+
score -= Math.min(20, (this.metrics.p95Latency - 3000) / 100);
|
|
174
|
+
}
|
|
175
|
+
// Deduct points for high memory usage
|
|
176
|
+
if (this.metrics.memoryUsage > 0.7) {
|
|
177
|
+
score -= Math.min(20, (this.metrics.memoryUsage - 0.7) * 66);
|
|
178
|
+
}
|
|
179
|
+
// Deduct points for high CPU usage
|
|
180
|
+
if (this.metrics.cpuUsage > 0.8) {
|
|
181
|
+
score -= Math.min(15, (this.metrics.cpuUsage - 0.8) * 75);
|
|
182
|
+
}
|
|
183
|
+
// Deduct points for low throughput
|
|
184
|
+
if (this.metrics.operationsPerSecond < 1 && this.metrics.totalOperations > 10) {
|
|
185
|
+
score -= 10;
|
|
186
|
+
}
|
|
187
|
+
// Deduct points for queue depth
|
|
188
|
+
if (this.metrics.queueDepth > 100) {
|
|
189
|
+
score -= Math.min(15, this.metrics.queueDepth / 20);
|
|
190
|
+
}
|
|
191
|
+
this.metrics.healthScore = Math.max(0, Math.min(100, score));
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Check for alert conditions
|
|
195
|
+
*/
|
|
196
|
+
checkAlerts() {
|
|
197
|
+
const alerts = [];
|
|
198
|
+
if (this.metrics.errorRate > this.thresholds.errorRate) {
|
|
199
|
+
alerts.push(`High error rate: ${(this.metrics.errorRate * 100).toFixed(1)}%`);
|
|
200
|
+
}
|
|
201
|
+
if (this.metrics.p95Latency > this.thresholds.latencyP95) {
|
|
202
|
+
alerts.push(`High P95 latency: ${this.metrics.p95Latency}ms`);
|
|
203
|
+
}
|
|
204
|
+
if (this.metrics.memoryUsage > this.thresholds.memoryUsage) {
|
|
205
|
+
alerts.push(`High memory usage: ${(this.metrics.memoryUsage * 100).toFixed(1)}%`);
|
|
206
|
+
}
|
|
207
|
+
if (this.metrics.cpuUsage > this.thresholds.cpuUsage) {
|
|
208
|
+
alerts.push(`High CPU usage: ${(this.metrics.cpuUsage * 100).toFixed(1)}%`);
|
|
209
|
+
}
|
|
210
|
+
if (this.metrics.healthScore < this.thresholds.healthScore) {
|
|
211
|
+
alerts.push(`Low health score: ${this.metrics.healthScore.toFixed(0)}`);
|
|
212
|
+
}
|
|
213
|
+
if (alerts.length > 0) {
|
|
214
|
+
this.logger.warn('Performance alerts', { alerts, metrics: this.metrics });
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Auto-optimize system based on metrics
|
|
219
|
+
*/
|
|
220
|
+
autoOptimize() {
|
|
221
|
+
this.recommendations = [];
|
|
222
|
+
// Analyze trends
|
|
223
|
+
const trends = this.analyzeTrends();
|
|
224
|
+
// Generate recommendations based on metrics and trends
|
|
225
|
+
if (this.metrics.errorRate > 0.02) {
|
|
226
|
+
this.recommendations.push('Reduce load or increase timeouts due to high error rate');
|
|
227
|
+
}
|
|
228
|
+
if (this.metrics.p95Latency > 3000) {
|
|
229
|
+
this.recommendations.push('Increase batch size or socket limits to improve latency');
|
|
230
|
+
}
|
|
231
|
+
if (this.metrics.memoryUsage > 0.7) {
|
|
232
|
+
this.recommendations.push('Reduce cache sizes or batch sizes to free memory');
|
|
233
|
+
}
|
|
234
|
+
if (this.metrics.queueDepth > 50) {
|
|
235
|
+
this.recommendations.push('Increase concurrency limits to reduce queue depth');
|
|
236
|
+
}
|
|
237
|
+
// Check for degrading trends
|
|
238
|
+
trends.forEach(trend => {
|
|
239
|
+
if (trend.direction === 'degrading' && Math.abs(trend.changeRate) > 0.1) {
|
|
240
|
+
this.recommendations.push(`${trend.metric} is degrading at ${(trend.changeRate * 100).toFixed(1)}% per minute`);
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
// Log recommendations if any
|
|
244
|
+
if (this.recommendations.length > 0) {
|
|
245
|
+
this.logger.info('Performance optimization recommendations', {
|
|
246
|
+
recommendations: this.recommendations,
|
|
247
|
+
metrics: this.metrics
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Analyze performance trends
|
|
253
|
+
*/
|
|
254
|
+
analyzeTrends() {
|
|
255
|
+
const trends = [];
|
|
256
|
+
if (this.history.length < 10) {
|
|
257
|
+
return trends; // Not enough data
|
|
258
|
+
}
|
|
259
|
+
// Get recent history
|
|
260
|
+
const recent = this.history.slice(-20);
|
|
261
|
+
const older = this.history.slice(-40, -20);
|
|
262
|
+
// Compare key metrics
|
|
263
|
+
const metricsToAnalyze = [
|
|
264
|
+
'errorRate',
|
|
265
|
+
'averageLatency',
|
|
266
|
+
'operationsPerSecond',
|
|
267
|
+
'memoryUsage',
|
|
268
|
+
'healthScore'
|
|
269
|
+
];
|
|
270
|
+
metricsToAnalyze.forEach(metric => {
|
|
271
|
+
const recentAvg = recent.reduce((sum, m) => sum + m[metric], 0) / recent.length;
|
|
272
|
+
const olderAvg = older.length > 0
|
|
273
|
+
? older.reduce((sum, m) => sum + m[metric], 0) / older.length
|
|
274
|
+
: recentAvg;
|
|
275
|
+
const changeRate = olderAvg !== 0 ? (recentAvg - olderAvg) / olderAvg : 0;
|
|
276
|
+
let direction = 'stable';
|
|
277
|
+
if (Math.abs(changeRate) > 0.05) { // 5% threshold
|
|
278
|
+
// For error rate and latency, increase is bad
|
|
279
|
+
if (metric === 'errorRate' || metric === 'averageLatency' || metric === 'memoryUsage') {
|
|
280
|
+
direction = changeRate > 0 ? 'degrading' : 'improving';
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
// For throughput and health score, increase is good
|
|
284
|
+
direction = changeRate > 0 ? 'improving' : 'degrading';
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
// Simple linear prediction
|
|
288
|
+
const prediction = recentAvg + (recentAvg * changeRate);
|
|
289
|
+
trends.push({
|
|
290
|
+
metric,
|
|
291
|
+
direction,
|
|
292
|
+
changeRate,
|
|
293
|
+
prediction
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
return trends;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Reset counters
|
|
300
|
+
*/
|
|
301
|
+
resetCounters() {
|
|
302
|
+
this.metrics.totalOperations = 0;
|
|
303
|
+
this.metrics.successfulOperations = 0;
|
|
304
|
+
this.metrics.failedOperations = 0;
|
|
305
|
+
this.operationSizes = [];
|
|
306
|
+
this.lastReset = Date.now();
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Get current metrics
|
|
310
|
+
*/
|
|
311
|
+
getMetrics() {
|
|
312
|
+
return { ...this.metrics };
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Get performance trends
|
|
316
|
+
*/
|
|
317
|
+
getTrends() {
|
|
318
|
+
return this.analyzeTrends();
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Get recommendations
|
|
322
|
+
*/
|
|
323
|
+
getRecommendations() {
|
|
324
|
+
return [...this.recommendations];
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Get performance report
|
|
328
|
+
*/
|
|
329
|
+
getReport() {
|
|
330
|
+
return {
|
|
331
|
+
metrics: this.getMetrics(),
|
|
332
|
+
trends: this.getTrends(),
|
|
333
|
+
recommendations: this.getRecommendations(),
|
|
334
|
+
socketConfig: getGlobalSocketManager().getConfig(),
|
|
335
|
+
backpressureStatus: getGlobalBackpressure().getStatus()
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Enable/disable auto-optimization
|
|
340
|
+
*/
|
|
341
|
+
setAutoOptimize(enabled) {
|
|
342
|
+
this.autoOptimizeEnabled = enabled;
|
|
343
|
+
this.logger.info(`Auto-optimization ${enabled ? 'enabled' : 'disabled'}`);
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Reset all metrics and history
|
|
347
|
+
*/
|
|
348
|
+
reset() {
|
|
349
|
+
this.metrics = {
|
|
350
|
+
totalOperations: 0,
|
|
351
|
+
successfulOperations: 0,
|
|
352
|
+
failedOperations: 0,
|
|
353
|
+
averageLatency: 0,
|
|
354
|
+
p95Latency: 0,
|
|
355
|
+
p99Latency: 0,
|
|
356
|
+
operationsPerSecond: 0,
|
|
357
|
+
bytesPerSecond: 0,
|
|
358
|
+
memoryUsage: 0,
|
|
359
|
+
cpuUsage: 0,
|
|
360
|
+
socketUtilization: 0,
|
|
361
|
+
queueDepth: 0,
|
|
362
|
+
errorRate: 0,
|
|
363
|
+
healthScore: 100
|
|
364
|
+
};
|
|
365
|
+
this.history = [];
|
|
366
|
+
this.operationLatencies = [];
|
|
367
|
+
this.operationSizes = [];
|
|
368
|
+
this.recommendations = [];
|
|
369
|
+
this.lastReset = Date.now();
|
|
370
|
+
this.logger.info('Performance monitor reset');
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
// Global singleton instance
|
|
374
|
+
let globalMonitor = null;
|
|
375
|
+
/**
|
|
376
|
+
* Get the global performance monitor instance
|
|
377
|
+
*/
|
|
378
|
+
export function getGlobalPerformanceMonitor() {
|
|
379
|
+
if (!globalMonitor) {
|
|
380
|
+
globalMonitor = new PerformanceMonitor();
|
|
381
|
+
}
|
|
382
|
+
return globalMonitor;
|
|
383
|
+
}
|
|
384
|
+
//# sourceMappingURL=performanceMonitor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"performanceMonitor.js","sourceRoot":"","sources":["../../src/utils/performanceMonitor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAA;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAA;AAiCjE;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAA/B;QACU,WAAM,GAAG,kBAAkB,CAAC,oBAAoB,CAAC,CAAA;QAEzD,kBAAkB;QACV,YAAO,GAAuB;YACpC,eAAe,EAAE,CAAC;YAClB,oBAAoB,EAAE,CAAC;YACvB,gBAAgB,EAAE,CAAC;YACnB,cAAc,EAAE,CAAC;YACjB,UAAU,EAAE,CAAC;YACb,UAAU,EAAE,CAAC;YACb,mBAAmB,EAAE,CAAC;YACtB,cAAc,EAAE,CAAC;YACjB,WAAW,EAAE,CAAC;YACd,QAAQ,EAAE,CAAC;YACX,iBAAiB,EAAE,CAAC;YACpB,UAAU,EAAE,CAAC;YACb,SAAS,EAAE,CAAC;YACZ,WAAW,EAAE,GAAG;SACjB,CAAA;QAED,qCAAqC;QAC7B,YAAO,GAAyB,EAAE,CAAA;QAClC,mBAAc,GAAG,IAAI,CAAA;QAE7B,qBAAqB;QACb,uBAAkB,GAAa,EAAE,CAAA;QACjC,mBAAc,GAAa,EAAE,CAAA;QAC7B,cAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QACtB,kBAAa,GAAG,KAAK,CAAA,CAAE,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QACV,IAAI,CAAC,OAAO,GAAG;YACb,eAAe,EAAE,CAAC;YAClB,oBAAoB,EAAE,CAAC;YACvB,gBAAgB,EAAE,CAAC;YACnB,cAAc,EAAE,CAAC;YACjB,UAAU,EAAE,CAAC;YACb,UAAU,EAAE,CAAC;YACb,mBAAmB,EAAE,CAAC;YACtB,cAAc,EAAE,CAAC;YACjB,WAAW,EAAE,CAAC;YACd,QAAQ,EAAE,CAAC;YACX,iBAAiB,EAAE,CAAC;YACpB,UAAU,EAAE,CAAC;YACb,SAAS,EAAE,CAAC;YACZ,WAAW,EAAE,GAAG;SACjB,CAAA;QAED,IAAI,CAAC,OAAO,GAAG,EAAE,CAAA;QACjB,IAAI,CAAC,kBAAkB,GAAG,EAAE,CAAA;QAC5B,IAAI,CAAC,cAAc,GAAG,EAAE,CAAA;QACxB,IAAI,CAAC,eAAe,GAAG,EAAE,CAAA;QACzB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QAE3B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAA;IAC/C,CAAC;CACF;AAED,4BAA4B;AAC5B,IAAI,aAAa,GAA8B,IAAI,CAAA;AAEnD;;GAEG;AACH,MAAM,UAAU,2BAA2B;IACzC,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,aAAa,GAAG,IAAI,kBAAkB,EAAE,CAAA;IAC1C,CAAC;IACD,OAAO,aAAa,CAAA;AACtB,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request Coalescer
|
|
3
|
+
* Batches and deduplicates operations to reduce S3 API calls
|
|
4
|
+
* Automatically flushes based on size, time, or pressure
|
|
5
|
+
*/
|
|
6
|
+
interface CoalescedOperation {
|
|
7
|
+
type: 'write' | 'read' | 'delete';
|
|
8
|
+
key: string;
|
|
9
|
+
data?: any;
|
|
10
|
+
resolve: (value: any) => void;
|
|
11
|
+
reject: (error: any) => void;
|
|
12
|
+
timestamp: number;
|
|
13
|
+
}
|
|
14
|
+
interface BatchStats {
|
|
15
|
+
totalOperations: number;
|
|
16
|
+
coalescedOperations: number;
|
|
17
|
+
deduplicated: number;
|
|
18
|
+
batchesProcessed: number;
|
|
19
|
+
averageBatchSize: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Coalesces multiple operations into efficient batches
|
|
23
|
+
*/
|
|
24
|
+
export declare class RequestCoalescer {
|
|
25
|
+
private logger;
|
|
26
|
+
private writeQueue;
|
|
27
|
+
private readQueue;
|
|
28
|
+
private deleteQueue;
|
|
29
|
+
private maxBatchSize;
|
|
30
|
+
private maxBatchAge;
|
|
31
|
+
private minBatchSize;
|
|
32
|
+
private flushTimer;
|
|
33
|
+
private lastFlush;
|
|
34
|
+
private stats;
|
|
35
|
+
private processor;
|
|
36
|
+
constructor(processor: (batch: CoalescedOperation[]) => Promise<void>, options?: {
|
|
37
|
+
maxBatchSize?: number;
|
|
38
|
+
maxBatchAge?: number;
|
|
39
|
+
minBatchSize?: number;
|
|
40
|
+
});
|
|
41
|
+
/**
|
|
42
|
+
* Add a write operation to be coalesced
|
|
43
|
+
*/
|
|
44
|
+
write(key: string, data: any): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Add a read operation to be coalesced
|
|
47
|
+
*/
|
|
48
|
+
read(key: string): Promise<any>;
|
|
49
|
+
/**
|
|
50
|
+
* Add a delete operation to be coalesced
|
|
51
|
+
*/
|
|
52
|
+
delete(key: string): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Check if we should flush the queues
|
|
55
|
+
*/
|
|
56
|
+
private checkFlush;
|
|
57
|
+
/**
|
|
58
|
+
* Flush all queued operations
|
|
59
|
+
*/
|
|
60
|
+
flush(reason?: string): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Get current statistics
|
|
63
|
+
*/
|
|
64
|
+
getStats(): BatchStats;
|
|
65
|
+
/**
|
|
66
|
+
* Get current queue sizes
|
|
67
|
+
*/
|
|
68
|
+
getQueueSizes(): {
|
|
69
|
+
writes: number;
|
|
70
|
+
reads: number;
|
|
71
|
+
deletes: number;
|
|
72
|
+
total: number;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Adjust batch parameters based on load
|
|
76
|
+
*/
|
|
77
|
+
adjustParameters(pending: number): void;
|
|
78
|
+
/**
|
|
79
|
+
* Force immediate flush of all operations
|
|
80
|
+
*/
|
|
81
|
+
forceFlush(): Promise<void>;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Get or create a coalescer for a storage instance
|
|
85
|
+
*/
|
|
86
|
+
export declare function getCoalescer(storageId: string, processor: (batch: any[]) => Promise<void>): RequestCoalescer;
|
|
87
|
+
/**
|
|
88
|
+
* Clear all coalescers
|
|
89
|
+
*/
|
|
90
|
+
export declare function clearCoalescers(): void;
|
|
91
|
+
export {};
|