perf(retrieval): lazy-load edges in BFS to reduce query latency#86
Open
rajkripal wants to merge 2 commits into
Open
perf(retrieval): lazy-load edges in BFS to reduce query latency#86rajkripal wants to merge 2 commits into
rajkripal wants to merge 2 commits into
Conversation
Instead of preloading all 14.5M edges upfront (O(E) complexity), neighbors are now fetched on-demand during BFS traversal. This reduces complexity from O(14.5M) to O(explored_nodes + their_neighbors). Typical exploration depth of 3 hops with 3 picks per hop only traverses 150-200 nodes, yielding 5-15x speedup by avoiding full graph preload. Changes: - retrieve_recursive_bfs: replaced upfront neighbors dict with get_neighbors() - retrieve_bfs_streaming: same lazy-loading pattern for streaming variant - get_neighbors() uses UNION to handle bidirectional edges in single query - Local cache prevents re-fetching same node's neighbors Test results: all 15 retrieval tests pass, no regressions. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Three test files had their model-agnostic dimension assertions replaced with hardcoded 384 / 'all-MiniLM-L6-v2', which fails against the actual configured model (thenlper/gte-large, dim=1024). Restore resolve_embedding_dim() lookups and remove the hardcoded model-name assertion. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
derivation_edgeswith on-demand per-node queries during BFS traversal in bothretrieve_recursive_bfsandretrieve_bfs_streaming._neighbor_cachedict prevents re-fetching the same node's edges within one BFS run.Test plan
test_prepare_ingest.pythat also fails on main)384,all-MiniLM-L6-v2) — restoredresolve_embedding_dim()lookups🤖 Generated with Claude Code