Repository navigation
feat(#185): lazy ONNX init — CLI cold start ~3s → ~20ms - #297
Merged
Merged
Conversation
… commands Embedding model is now loaded lazily on first use instead of eagerly at store open. Commands that don't need embedding (list, get, stats, tags, forget, namespace, aging, export, doctor, verify) start instantly. Commands that need embedding (remember, recall, search, import, consolidate with contradiction) still take ~3s on first use per process invocation — daemon mode (v0.1.0+) will solve this for repeated calls. Implementation: - embedder field changed from Mutex<EmbeddingEngine> to Mutex<Option<EmbeddingEngine>> - ensure_embedder() lazy-loads ONNX on first embedding call - All embed() call sites updated to use as_mut().expect() after ensure Closes #185 (Option 3: lazy init)
| "Unknown memory type '{memory_type}'. Valid types: fact, procedure, preference, decision, context" | ||
| )) | ||
| })?; | ||
| // Lazy-load embedder on first use |
| // Embed query outside any lock — CPU-intensive (~50ms), no shared state needed. | ||
| // Only the embedder Mutex is held here, allowing concurrent index reads. | ||
| // Lazy-load embedder on first use. | ||
| self.ensure_embedder()?; |
🔍 Cora AI Code Review❌ Blocked — critical issues found. 🔴 Error (2)
Review powered by cora-cli · BYOK · MIT |
ajianaz
added a commit
that referenced
this pull request
Aug 13, 2026
… commands (#297) Embedding model is now loaded lazily on first use instead of eagerly at store open. Commands that don't need embedding (list, get, stats, tags, forget, namespace, aging, export, doctor, verify) start instantly. Commands that need embedding (remember, recall, search, import, consolidate with contradiction) still take ~3s on first use per process invocation — daemon mode (v0.1.0+) will solve this for repeated calls. Implementation: - embedder field changed from Mutex<EmbeddingEngine> to Mutex<Option<EmbeddingEngine>> - ensure_embedder() lazy-loads ONNX on first embedding call - All embed() call sites updated to use as_mut().expect() after ensure Closes #185 (Option 3: lazy init)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
ONNX embedding model loaded lazily on first use instead of eagerly at store open.
Impact
uteke listuteke statsuteke tagsuteke forgetuteke namespace listuteke doctoruteke recalluteke rememberHow
embedderfield:Mutex<EmbeddingEngine>→Mutex<Option<EmbeddingEngine>>ensure_embedder()lazy-loads ONNX on first embedding callembed()call sites updated:as_mut().expect()afterensure_embedder()Closes
Closes #185 (Option 3: lazy init)