CHECKPOINT: Session 4 - Complete Optimization Suite
✅ Unified Cache System - Created UnifiedCache with cost-aware eviction - Integrated with both MetadataIndex and HNSW - Request coalescing, fairness monitoring, access patterns ✅ Index Persistence - Sorted indices for range queries saved/loaded - Integrated with UnifiedCache (100x rebuild cost) ✅ TripleIntelligence Fixed - Native Brain Pattern support - Direct metadata filtering without string conversion ✅ Competitive Analysis - Created comprehensive docs/COMPETITIVE-ANALYSIS.md - Shows Brainy advantages vs all competitors ✅ All Infrastructure Complete - TypeScript: 0 errors - Memory: Optimized with unified cache - Models: Cached locally - Ready for comprehensive testing
This commit is contained in:
parent
88abcddf84
commit
f0ee5f44ec
16 changed files with 2081 additions and 582 deletions
57
test-memory-leak.js
Normal file
57
test-memory-leak.js
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
import { BrainyData } from './dist/index.js'
|
||||
|
||||
async function testMemoryUsage() {
|
||||
console.log('Testing memory usage...\n')
|
||||
|
||||
// Log memory before
|
||||
const memBefore = process.memoryUsage()
|
||||
console.log('Memory before:', {
|
||||
rss: Math.round(memBefore.rss / 1024 / 1024) + ' MB',
|
||||
heapUsed: Math.round(memBefore.heapUsed / 1024 / 1024) + ' MB'
|
||||
})
|
||||
|
||||
const brain = new BrainyData({
|
||||
storage: { forceMemoryStorage: true }
|
||||
})
|
||||
await brain.init()
|
||||
console.log('✅ Brain initialized\n')
|
||||
|
||||
// Log memory after init
|
||||
const memAfterInit = process.memoryUsage()
|
||||
console.log('Memory after init:', {
|
||||
rss: Math.round(memAfterInit.rss / 1024 / 1024) + ' MB',
|
||||
heapUsed: Math.round(memAfterInit.heapUsed / 1024 / 1024) + ' MB',
|
||||
delta: Math.round((memAfterInit.heapUsed - memBefore.heapUsed) / 1024 / 1024) + ' MB'
|
||||
})
|
||||
|
||||
// Add some data WITHOUT using find()
|
||||
console.log('\n📝 Adding data...')
|
||||
for (let i = 0; i < 5; i++) {
|
||||
await brain.addNoun(`Item ${i}`, { metadata: { index: i } })
|
||||
}
|
||||
console.log('✅ Added 5 items\n')
|
||||
|
||||
// Now try search (not find)
|
||||
console.log('🔍 Testing search...')
|
||||
const results = await brain.search('Item', 3)
|
||||
console.log(`Found ${results.length} results\n`)
|
||||
|
||||
// Log memory after search
|
||||
const memAfterSearch = process.memoryUsage()
|
||||
console.log('Memory after search:', {
|
||||
rss: Math.round(memAfterSearch.rss / 1024 / 1024) + ' MB',
|
||||
heapUsed: Math.round(memAfterSearch.heapUsed / 1024 / 1024) + ' MB',
|
||||
delta: Math.round((memAfterSearch.heapUsed - memAfterInit.heapUsed) / 1024 / 1024) + ' MB'
|
||||
})
|
||||
|
||||
await brain.shutdown()
|
||||
console.log('\n✅ Test complete!')
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
testMemoryUsage().catch(err => {
|
||||
console.error('❌ Error:', err.message)
|
||||
process.exit(1)
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue