@soulcraft/brainy 0.54.0 → 0.54.2
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/storage/adapters/s3CompatibleStorage.d.ts +43 -0
- package/dist/storage/adapters/s3CompatibleStorage.js +263 -0
- package/dist/storage/adapters/s3CompatibleStorage.js.map +1 -1
- 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 +328 -0
- package/dist/utils/writeBuffer.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Write Buffer
|
|
3
|
+
* Accumulates writes and flushes them in bulk to reduce S3 operations
|
|
4
|
+
* Implements intelligent deduplication and compression
|
|
5
|
+
*/
|
|
6
|
+
import { createModuleLogger } from './logger.js';
|
|
7
|
+
import { getGlobalBackpressure } from './adaptiveBackpressure.js';
|
|
8
|
+
/**
|
|
9
|
+
* High-performance write buffer for bulk operations
|
|
10
|
+
*/
|
|
11
|
+
export class WriteBuffer {
|
|
12
|
+
constructor(type, writeFunction, options) {
|
|
13
|
+
this.logger = createModuleLogger('WriteBuffer');
|
|
14
|
+
// Buffer storage
|
|
15
|
+
this.buffer = new Map();
|
|
16
|
+
// Configuration - More aggressive for high volume
|
|
17
|
+
this.maxBufferSize = 2000; // Allow larger buffers
|
|
18
|
+
this.flushInterval = 500; // Flush more frequently (0.5 seconds)
|
|
19
|
+
this.minFlushSize = 50; // Lower minimum to flush sooner
|
|
20
|
+
this.maxRetries = 3; // Maximum retry attempts
|
|
21
|
+
// State
|
|
22
|
+
this.flushTimer = null;
|
|
23
|
+
this.isFlushing = false;
|
|
24
|
+
this.lastFlush = Date.now();
|
|
25
|
+
this.pendingFlush = null;
|
|
26
|
+
// Statistics
|
|
27
|
+
this.totalWrites = 0;
|
|
28
|
+
this.totalFlushes = 0;
|
|
29
|
+
this.failedWrites = 0;
|
|
30
|
+
this.duplicatesRemoved = 0;
|
|
31
|
+
// Backpressure integration
|
|
32
|
+
this.backpressure = getGlobalBackpressure();
|
|
33
|
+
this.type = type;
|
|
34
|
+
this.writeFunction = writeFunction;
|
|
35
|
+
if (options) {
|
|
36
|
+
this.maxBufferSize = options.maxBufferSize || this.maxBufferSize;
|
|
37
|
+
this.flushInterval = options.flushInterval || this.flushInterval;
|
|
38
|
+
this.minFlushSize = options.minFlushSize || this.minFlushSize;
|
|
39
|
+
}
|
|
40
|
+
// Start periodic flush
|
|
41
|
+
this.startPeriodicFlush();
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Add item to buffer
|
|
45
|
+
*/
|
|
46
|
+
async add(id, data) {
|
|
47
|
+
// Check if we're already at capacity
|
|
48
|
+
if (this.buffer.size >= this.maxBufferSize) {
|
|
49
|
+
// Wait for current flush to complete
|
|
50
|
+
if (this.pendingFlush) {
|
|
51
|
+
await this.pendingFlush;
|
|
52
|
+
}
|
|
53
|
+
// Force flush if still at capacity
|
|
54
|
+
if (this.buffer.size >= this.maxBufferSize) {
|
|
55
|
+
await this.flush('capacity');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// Check for duplicate and update if newer
|
|
59
|
+
const existing = this.buffer.get(id);
|
|
60
|
+
if (existing) {
|
|
61
|
+
// Update with newer data
|
|
62
|
+
existing.data = data;
|
|
63
|
+
existing.timestamp = Date.now();
|
|
64
|
+
this.duplicatesRemoved++;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
// Add new item
|
|
68
|
+
this.buffer.set(id, {
|
|
69
|
+
id,
|
|
70
|
+
data,
|
|
71
|
+
timestamp: Date.now(),
|
|
72
|
+
type: this.type,
|
|
73
|
+
retryCount: 0
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
this.totalWrites++;
|
|
77
|
+
// Log buffer growth periodically
|
|
78
|
+
if (this.totalWrites % 100 === 0) {
|
|
79
|
+
this.logger.info(`📈 BUFFER GROWTH: ${this.buffer.size} ${this.type} items buffered (${this.totalWrites} total writes, ${this.duplicatesRemoved} deduplicated)`);
|
|
80
|
+
}
|
|
81
|
+
// Check if we should flush
|
|
82
|
+
this.checkFlush();
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Check if we should flush
|
|
86
|
+
*/
|
|
87
|
+
checkFlush() {
|
|
88
|
+
const bufferSize = this.buffer.size;
|
|
89
|
+
const timeSinceFlush = Date.now() - this.lastFlush;
|
|
90
|
+
// Immediate flush conditions
|
|
91
|
+
if (bufferSize >= this.maxBufferSize) {
|
|
92
|
+
this.flush('size');
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
// Time-based flush with minimum size
|
|
96
|
+
if (timeSinceFlush >= this.flushInterval && bufferSize >= this.minFlushSize) {
|
|
97
|
+
this.flush('time');
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
// Adaptive flush based on system load
|
|
101
|
+
const backpressureStatus = this.backpressure.getStatus();
|
|
102
|
+
if (backpressureStatus.queueLength > 1000 && bufferSize > 10) {
|
|
103
|
+
// System under pressure - flush smaller batches more frequently
|
|
104
|
+
this.flush('pressure');
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Flush buffer to storage
|
|
109
|
+
*/
|
|
110
|
+
async flush(reason = 'manual') {
|
|
111
|
+
// Prevent concurrent flushes
|
|
112
|
+
if (this.isFlushing) {
|
|
113
|
+
if (this.pendingFlush) {
|
|
114
|
+
return this.pendingFlush;
|
|
115
|
+
}
|
|
116
|
+
return { successful: 0, failed: 0, duration: 0 };
|
|
117
|
+
}
|
|
118
|
+
// Nothing to flush
|
|
119
|
+
if (this.buffer.size === 0) {
|
|
120
|
+
return { successful: 0, failed: 0, duration: 0 };
|
|
121
|
+
}
|
|
122
|
+
this.isFlushing = true;
|
|
123
|
+
const startTime = Date.now();
|
|
124
|
+
// Create flush promise
|
|
125
|
+
this.pendingFlush = this.doFlush(reason, startTime);
|
|
126
|
+
try {
|
|
127
|
+
const result = await this.pendingFlush;
|
|
128
|
+
return result;
|
|
129
|
+
}
|
|
130
|
+
finally {
|
|
131
|
+
this.isFlushing = false;
|
|
132
|
+
this.pendingFlush = null;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Perform the actual flush
|
|
137
|
+
*/
|
|
138
|
+
async doFlush(reason, startTime) {
|
|
139
|
+
const itemsToFlush = new Map();
|
|
140
|
+
const flushingItems = new Map();
|
|
141
|
+
// Take items from buffer
|
|
142
|
+
let count = 0;
|
|
143
|
+
for (const [id, item] of this.buffer.entries()) {
|
|
144
|
+
itemsToFlush.set(id, item.data);
|
|
145
|
+
flushingItems.set(id, item);
|
|
146
|
+
count++;
|
|
147
|
+
// Limit batch size for better performance
|
|
148
|
+
if (count >= 500) {
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
// Remove from buffer
|
|
153
|
+
for (const id of itemsToFlush.keys()) {
|
|
154
|
+
this.buffer.delete(id);
|
|
155
|
+
}
|
|
156
|
+
this.logger.warn(`🔄 BUFFERING: Flushing ${itemsToFlush.size} ${this.type} items (buffer had ${this.buffer.size + itemsToFlush.size}) - reason: ${reason}`);
|
|
157
|
+
try {
|
|
158
|
+
// Request permission from backpressure system
|
|
159
|
+
const opId = `flush-${Date.now()}`;
|
|
160
|
+
await this.backpressure.requestPermission(opId, 2); // Higher priority
|
|
161
|
+
try {
|
|
162
|
+
// Perform bulk write
|
|
163
|
+
await this.writeFunction(itemsToFlush);
|
|
164
|
+
// Success
|
|
165
|
+
this.backpressure.releasePermission(opId, true);
|
|
166
|
+
this.totalFlushes++;
|
|
167
|
+
this.lastFlush = Date.now();
|
|
168
|
+
const duration = Date.now() - startTime;
|
|
169
|
+
this.logger.warn(`🚀 BATCH FLUSH: ${itemsToFlush.size} ${this.type} items → 1 bulk S3 operation (${duration}ms, reason: ${reason})`);
|
|
170
|
+
return {
|
|
171
|
+
successful: itemsToFlush.size,
|
|
172
|
+
failed: 0,
|
|
173
|
+
duration
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
// Release with error
|
|
178
|
+
this.backpressure.releasePermission(opId, false);
|
|
179
|
+
throw error;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
this.logger.error(`Flush failed: ${error}`);
|
|
184
|
+
// Put items back with retry count
|
|
185
|
+
for (const [id, item] of flushingItems.entries()) {
|
|
186
|
+
item.retryCount++;
|
|
187
|
+
if (item.retryCount < this.maxRetries) {
|
|
188
|
+
// Put back for retry
|
|
189
|
+
this.buffer.set(id, item);
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
// Max retries exceeded
|
|
193
|
+
this.failedWrites++;
|
|
194
|
+
this.logger.error(`Max retries exceeded for ${this.type} ${id}`);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
const duration = Date.now() - startTime;
|
|
198
|
+
return {
|
|
199
|
+
successful: 0,
|
|
200
|
+
failed: itemsToFlush.size,
|
|
201
|
+
duration
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Start periodic flush timer
|
|
207
|
+
*/
|
|
208
|
+
startPeriodicFlush() {
|
|
209
|
+
if (this.flushTimer) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
this.flushTimer = setInterval(() => {
|
|
213
|
+
if (this.buffer.size > 0) {
|
|
214
|
+
const timeSinceFlush = Date.now() - this.lastFlush;
|
|
215
|
+
// Flush if we have items and enough time has passed
|
|
216
|
+
if (timeSinceFlush >= this.flushInterval) {
|
|
217
|
+
this.flush('periodic').catch(error => {
|
|
218
|
+
this.logger.error('Periodic flush failed:', error);
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}, Math.min(100, this.flushInterval / 2));
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Stop periodic flush timer
|
|
226
|
+
*/
|
|
227
|
+
stop() {
|
|
228
|
+
if (this.flushTimer) {
|
|
229
|
+
clearInterval(this.flushTimer);
|
|
230
|
+
this.flushTimer = null;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Force flush all pending writes
|
|
235
|
+
*/
|
|
236
|
+
async forceFlush() {
|
|
237
|
+
// Flush everything regardless of size
|
|
238
|
+
const oldMinSize = this.minFlushSize;
|
|
239
|
+
this.minFlushSize = 0;
|
|
240
|
+
try {
|
|
241
|
+
const result = await this.flush('force');
|
|
242
|
+
// Flush any remaining items
|
|
243
|
+
while (this.buffer.size > 0) {
|
|
244
|
+
const additionalResult = await this.flush('force-remaining');
|
|
245
|
+
result.successful += additionalResult.successful;
|
|
246
|
+
result.failed += additionalResult.failed;
|
|
247
|
+
result.duration += additionalResult.duration;
|
|
248
|
+
}
|
|
249
|
+
return result;
|
|
250
|
+
}
|
|
251
|
+
finally {
|
|
252
|
+
this.minFlushSize = oldMinSize;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Get buffer statistics
|
|
257
|
+
*/
|
|
258
|
+
getStats() {
|
|
259
|
+
return {
|
|
260
|
+
bufferSize: this.buffer.size,
|
|
261
|
+
totalWrites: this.totalWrites,
|
|
262
|
+
totalFlushes: this.totalFlushes,
|
|
263
|
+
failedWrites: this.failedWrites,
|
|
264
|
+
duplicatesRemoved: this.duplicatesRemoved,
|
|
265
|
+
avgFlushSize: this.totalFlushes > 0 ? this.totalWrites / this.totalFlushes : 0
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Adjust parameters based on load
|
|
270
|
+
*/
|
|
271
|
+
adjustForLoad(pendingRequests) {
|
|
272
|
+
if (pendingRequests > 10000) {
|
|
273
|
+
// Extreme load - buffer more aggressively
|
|
274
|
+
this.maxBufferSize = 5000;
|
|
275
|
+
this.flushInterval = 500;
|
|
276
|
+
this.minFlushSize = 500;
|
|
277
|
+
}
|
|
278
|
+
else if (pendingRequests > 1000) {
|
|
279
|
+
// High load
|
|
280
|
+
this.maxBufferSize = 2000;
|
|
281
|
+
this.flushInterval = 1000;
|
|
282
|
+
this.minFlushSize = 200;
|
|
283
|
+
}
|
|
284
|
+
else if (pendingRequests > 100) {
|
|
285
|
+
// Moderate load
|
|
286
|
+
this.maxBufferSize = 1000;
|
|
287
|
+
this.flushInterval = 2000;
|
|
288
|
+
this.minFlushSize = 100;
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
// Low load - optimize for latency
|
|
292
|
+
this.maxBufferSize = 500;
|
|
293
|
+
this.flushInterval = 5000;
|
|
294
|
+
this.minFlushSize = 50;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
// Global write buffers
|
|
299
|
+
const writeBuffers = new Map();
|
|
300
|
+
/**
|
|
301
|
+
* Get or create a write buffer
|
|
302
|
+
*/
|
|
303
|
+
export function getWriteBuffer(id, type, writeFunction) {
|
|
304
|
+
if (!writeBuffers.has(id)) {
|
|
305
|
+
writeBuffers.set(id, new WriteBuffer(type, writeFunction));
|
|
306
|
+
}
|
|
307
|
+
return writeBuffers.get(id);
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Flush all write buffers
|
|
311
|
+
*/
|
|
312
|
+
export async function flushAllBuffers() {
|
|
313
|
+
const promises = [];
|
|
314
|
+
for (const buffer of writeBuffers.values()) {
|
|
315
|
+
promises.push(buffer.forceFlush());
|
|
316
|
+
}
|
|
317
|
+
await Promise.all(promises);
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Clear all write buffers
|
|
321
|
+
*/
|
|
322
|
+
export function clearWriteBuffers() {
|
|
323
|
+
for (const buffer of writeBuffers.values()) {
|
|
324
|
+
buffer.stop();
|
|
325
|
+
}
|
|
326
|
+
writeBuffers.clear();
|
|
327
|
+
}
|
|
328
|
+
//# sourceMappingURL=writeBuffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writeBuffer.js","sourceRoot":"","sources":["../../src/utils/writeBuffer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAA;AAgBjE;;GAEG;AACH,MAAM,OAAO,WAAW;IA+BtB,YACE,IAAkC,EAClC,aAAuD,EACvD,OAIC;QArCK,WAAM,GAAG,kBAAkB,CAAC,aAAa,CAAC,CAAA;QAElD,iBAAiB;QACT,WAAM,GAAG,IAAI,GAAG,EAA4B,CAAA;QAEpD,kDAAkD;QAC1C,kBAAa,GAAG,IAAI,CAAA,CAAM,uBAAuB;QACjD,kBAAa,GAAG,GAAG,CAAA,CAAO,sCAAsC;QAChE,iBAAY,GAAG,EAAE,CAAA,CAAS,gCAAgC;QAC1D,eAAU,GAAG,CAAC,CAAA,CAAY,yBAAyB;QAE3D,QAAQ;QACA,eAAU,GAA0B,IAAI,CAAA;QACxC,eAAU,GAAG,KAAK,CAAA;QAClB,cAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QACtB,iBAAY,GAAgC,IAAI,CAAA;QAExD,aAAa;QACL,gBAAW,GAAG,CAAC,CAAA;QACf,iBAAY,GAAG,CAAC,CAAA;QAChB,iBAAY,GAAG,CAAC,CAAA;QAChB,sBAAiB,GAAG,CAAC,CAAA;QAM7B,2BAA2B;QACnB,iBAAY,GAAG,qBAAqB,EAAE,CAAA;QAW5C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;QAElC,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,IAAI,CAAC,aAAa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