问题描述
在 agentManager/memory/memory_system.py 中,MemorySystem 类的每个方法都创建新的 SQLite 连接,这会导致性能问题。
受影响的代码
def store(self, entry: MemoryEntry) -> str:
with sqlite3.connect(self.db_path) as conn: # 每次都创建新连接
# ...
def retrieve(self, entry_id: str) -> Optional[MemoryEntry]:
with sqlite3.connect(self.db_path) as conn: # 每次都创建新连接
# ...
潜在问题
- 频繁创建/销毁数据库连接导致性能下降
- 在高并发场景下性能会显著下降
- 数据库连接池没有被利用
建议修复
- 使用连接池(例如:sqlite3 连接池或 SQLAlchemy)
- 实现连接缓存机制
- 添加性能测试用例
- 考虑使用异步数据库驱动
优先级
中 - 这是一个性能优化问题
问题描述
在
agentManager/memory/memory_system.py中,MemorySystem类的每个方法都创建新的 SQLite 连接,这会导致性能问题。受影响的代码
潜在问题
建议修复
优先级
中 - 这是一个性能优化问题