Optimize full graph rebuilds with batch indexing to prevent thread exhaustion, and fix adr/snippet search availability before restart

This commit is contained in:
Riz Ashraf committed 2026-09-21 05:56:58 +01:00
1 parent 84672a00b9
commit a9885a65d7
3 files changed
+102 -47

No files matched your search

+6 -31
View File
@@ -58,39 +58,14 @@ impl MemoryState {
pub async fn rebuild_index(&self) {
if let Ok(new_idx) = MemoryIndex::new(&self.base_dir) {
let mut handles = Vec::new();
{
let graph = self.graph.read();
for e in graph.entities.values() {
handles.push(new_idx.index_entity(e));
}
}
let entities = self.graph.read().entities.values().cloned().collect();
let tasks = self.tasks.read().clone();
let snippets = self.snippets.read().clone();
let adrs = self.adrs.read().clone();
{
let tasks = self.tasks.read();
for t in tasks {
handles.push(new_idx.index_task(&t));
}
}
{
let snippets = self.snippets.read();
for s in snippets {
handles.push(new_idx.index_snippet(&s));
}
}
{
let adrs = self.adrs.read();
for a in adrs {
handles.push(new_idx.index_adr(&a));
}
}
for handle in handles {
let _ = handle.await;
}
let handle = new_idx.index_batch(entities, tasks, snippets, adrs);
let _ = handle.await;
let _ = new_idx.commit().await;
if let Ok(mut w) = self.search_index.write() {