-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
Description
Issue Description
Dashboard is experiencing 8-10 second query times, significantly slower than expected 2-5s performance.
Root Cause Analysis
The bottleneck is in the get_stats()
and dashboard_get_stats()
methods in server.py
:
# WARNING: This can be very slow and memory-intensive on large collections.
all_metadatas_results = collection.get(include=['metadatas'])
Problems:
- Inefficient tag counting: Loads ALL metadata from ALL documents to count unique tags
- Frequent calls: Stats refresh after every operation (search, store, recall, init, refresh button)
- Memory intensive: Entire collection metadata loaded into memory
- No caching: Same expensive operation repeated frequently
Performance Impact
- Query times: 8-10 seconds (should be 2-5s)
- User experience: Noticeable lag after every interaction
- Memory usage: Unnecessary memory consumption loading full metadata
Proposed Solutions
Short-term fix:
- Add caching with TTL (Time To Live) for stats
- Reduce call frequency - don't refresh stats after every operation
- Lazy loading - only refresh when user explicitly requests
Long-term optimization:
- Maintain tag index separately in metadata or cache
- Batch operations - update stats incrementally
- Background updates - refresh stats periodically vs. on-demand
Files Affected
src/memory_dashboard/server.py
(primary)src/MemoryDashboard.tsx
(call frequency)
Priority
High - Significantly impacts user experience
Memory-Driven Development Notes
- Archive current implementation before changes
- Test systematically: minimal → simplified → complex
- Create backup of current performance measurements