fix(emergency): drastically lower high-volume mode activation thresholds
EMERGENCY FIX for bluesky-package socket exhaustion despite v0.54.1 🚨 CRITICAL CHANGES: - Activation threshold: 100 → 1 pending operation (configurable) - Add socket utilization trigger: >10% usage activates buffering - Add environment variables: - BRAINY_BUFFER_THRESHOLD=1 (when to start buffering) - BRAINY_FORCE_BUFFERING=true (force enable) - Add comprehensive logging with emojis for visibility: - '🚨 HIGH-VOLUME MODE ACTIVATED 🚨' when buffering starts - '🚀 BATCH FLUSH: N items → 1 bulk S3 operation' for batch writes - '📈 BUFFER GROWTH: N items buffered' every 100 additions PROBLEM: v0.54.1 buffering not activating with 7,500 pending requests SOLUTION: Activate buffering at first sign of load (1+ pending operations) This should immediately activate buffering in bluesky-package production.
This commit is contained in:
parent
a0d736472c
commit
b989e72be4
5 changed files with 151 additions and 23 deletions
|
|
@ -31,10 +31,10 @@ export class WriteBuffer<T> {
|
|||
// Buffer storage
|
||||
private buffer = new Map<string, BufferedWrite<T>>()
|
||||
|
||||
// Configuration
|
||||
private maxBufferSize = 1000 // Maximum items before forced flush
|
||||
private flushInterval = 1000 // Flush every second
|
||||
private minFlushSize = 100 // Minimum items to flush (unless timeout)
|
||||
// Configuration - More aggressive for high volume
|
||||
private maxBufferSize = 2000 // Allow larger buffers
|
||||
private flushInterval = 500 // Flush more frequently (0.5 seconds)
|
||||
private minFlushSize = 50 // Lower minimum to flush sooner
|
||||
private maxRetries = 3 // Maximum retry attempts
|
||||
|
||||
// State
|
||||
|
|
@ -115,6 +115,11 @@ export class WriteBuffer<T> {
|
|||
|
||||
this.totalWrites++
|
||||
|
||||
// Log buffer growth periodically
|
||||
if (this.totalWrites % 100 === 0) {
|
||||
this.logger.info(`📈 BUFFER GROWTH: ${this.buffer.size} ${this.type} items buffered (${this.totalWrites} total writes, ${this.duplicatesRemoved} deduplicated)`)
|
||||
}
|
||||
|
||||
// Check if we should flush
|
||||
this.checkFlush()
|
||||
}
|
||||
|
|
@ -203,7 +208,7 @@ export class WriteBuffer<T> {
|
|||
this.buffer.delete(id)
|
||||
}
|
||||
|
||||
this.logger.debug(`Flushing ${itemsToFlush.size} ${this.type} items - reason: ${reason}`)
|
||||
this.logger.warn(`🔄 BUFFERING: Flushing ${itemsToFlush.size} ${this.type} items (buffer had ${this.buffer.size + itemsToFlush.size}) - reason: ${reason}`)
|
||||
|
||||
try {
|
||||
// Request permission from backpressure system
|
||||
|
|
@ -220,7 +225,7 @@ export class WriteBuffer<T> {
|
|||
this.lastFlush = Date.now()
|
||||
|
||||
const duration = Date.now() - startTime
|
||||
this.logger.info(`Flushed ${itemsToFlush.size} items in ${duration}ms`)
|
||||
this.logger.warn(`🚀 BATCH FLUSH: ${itemsToFlush.size} ${this.type} items → 1 bulk S3 operation (${duration}ms, reason: ${reason})`)
|
||||
|
||||
return {
|
||||
successful: itemsToFlush.size,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue