Defer graph health computation to first trigger, not startup
Loading 23K nodes + building graph was blocking consciousness startup. Now computed on first trigger cycle (runs async from mind loop). Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
0d40f27098
commit
b7e053edc3
1 changed files with 4 additions and 6 deletions
|
|
@ -116,13 +116,11 @@ impl Unconscious {
|
|||
}
|
||||
agents.sort_by(|a, b| a.name.cmp(&b.name));
|
||||
|
||||
let mut s = Self {
|
||||
Self {
|
||||
agents, max_concurrent: 2,
|
||||
graph_health: None,
|
||||
last_health_check: None,
|
||||
};
|
||||
s.refresh_health();
|
||||
s
|
||||
}
|
||||
}
|
||||
|
||||
/// Toggle an agent on/off by name. Returns new enabled state.
|
||||
|
|
@ -167,10 +165,10 @@ impl Unconscious {
|
|||
|
||||
/// Reap finished agents and spawn new ones.
|
||||
pub async fn trigger(&mut self) {
|
||||
// Periodic graph health refresh
|
||||
// Periodic graph health refresh (also on first call)
|
||||
if self.last_health_check
|
||||
.map(|t| t.elapsed() > Duration::from_secs(600))
|
||||
.unwrap_or(false)
|
||||
.unwrap_or(true)
|
||||
{
|
||||
self.refresh_health();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue