perf(server): fix broadcast loops, avoid locking db on index, eliminate O(N*M) search, and fix db loss
This commit is contained in:
1 parent
1e39122e05
commit
27aba454e2
4 files changed
+69
-54
No files matched your search
+21
-20
@@ -124,26 +124,27 @@ impl MemoryState {
|
||||
let idx = new_idx.clone();
|
||||
|
||||
tokio::task::spawn_blocking(move || {
|
||||
state.graph.read_with(|g| {
|
||||
for e in g.entities.values() {
|
||||
idx.add_entity_sync(e);
|
||||
}
|
||||
});
|
||||
state.tasks.read_with(|tasks| {
|
||||
for t in tasks {
|
||||
idx.add_task_sync(t);
|
||||
}
|
||||
});
|
||||
state.snippets.read_with(|snippets| {
|
||||
for s in snippets {
|
||||
idx.add_snippet_sync(s);
|
||||
}
|
||||
});
|
||||
state.adrs.read_with(|adrs| {
|
||||
for a in adrs {
|
||||
idx.add_adr_sync(a);
|
||||
}
|
||||
});
|
||||
let entities: Vec<_> = state
|
||||
.graph
|
||||
.read_with(|g| g.entities.values().cloned().collect());
|
||||
for e in entities {
|
||||
idx.add_entity_sync(&e);
|
||||
}
|
||||
|
||||
let tasks = state.tasks.read_with(|t| t.clone());
|
||||
for t in tasks {
|
||||
idx.add_task_sync(&t);
|
||||
}
|
||||
|
||||
let snippets = state.snippets.read_with(|s| s.clone());
|
||||
for s in snippets {
|
||||
idx.add_snippet_sync(&s);
|
||||
}
|
||||
|
||||
let adrs = state.adrs.read_with(|a| a.clone());
|
||||
for a in adrs {
|
||||
idx.add_adr_sync(&a);
|
||||
}
|
||||
})
|
||||
.await
|
||||
.unwrap_or_else(|e| {
|
||||
|
||||
Reference in new issue
Block a user