feat: implement global index registry for O(1) index discovery#199
Open
majiayu000 wants to merge 3 commits into
Open
feat: implement global index registry for O(1) index discovery#199majiayu000 wants to merge 3 commits into
majiayu000 wants to merge 3 commits into
Conversation
Fixes StarTrail-org#122 The `leann list` command was scanning entire directory trees using `rglob()`, causing extremely slow performance when run in large directories like $HOME. Changes: - Add `_find_meta_files_limited()` method with max_depth parameter - Skip common large directories (node_modules, .venv, .git, etc.) - Apply limited search in `_discover_indexes_in_project()` and `_find_all_matching_indexes()` - Add `_has_app_indexes_limited()` in registry.py for faster checks - Add comprehensive tests for the new functionality Signed-off-by: majiayu000 <1835304752@qq.com>
Address reviewer feedback by making the directory scan depth configurable instead of hardcoding it to 3. Users with deeply nested project structures can now increase the depth limit as needed. - Add --max-depth argument to list command (default: 3) - Update list_indexes() and _discover_indexes_in_project() to accept max_depth - Add tests for the new CLI option and custom depth behavior 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implements a centralized index registry at ~/.leann/indexes.json that stores all LEANN index paths, enabling O(1) lookup instead of directory scanning. Changes: - Add register_index/unregister_index/list_registered_indexes functions - Update leann build to register indexes in global registry - Update leann list to use registry when available (with scan fallback) - Update leann remove to unregister indexes from registry - Auto-cleanup stale registry entries on list - Add comprehensive tests for registry functionality When registry is used, `leann list` output shows: ⚡ Using global registry (O(1) lookup) When falling back to scan: 🔍 Using directory scan (run 'leann build' to enable fast registry) Closes StarTrail-org#198 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Contributor
Author
|
Note: This PR builds on top of #196 (which adds The relationship:
Recommended merge order:
This PR should be rebased onto #196 once it's merged. |
4 tasks
ngmks
added a commit
to ngmks/LEANN
that referenced
this pull request
Feb 3, 2026
…org#195, StarTrail-org#196, StarTrail-org#199 - Fix unused variable `zmq_port` in warmup() method (F841) - Remove unused imports in test_cli_list_performance.py (F401) - Sort imports in test files (I001) - Fix test_warmup.py: correct attribute name `_warmup_enabled` → `_warmup` - Add skipif for DiskANN test when backend is not installed - Apply ruff format to all modified files Co-Authored-By: Claude Opus 4.5 <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
Implements a centralized index registry at
~/.leann/indexes.jsonthat stores all LEANN index paths, enabling O(1) lookup instead of directory scanning.Changes
register_index/unregister_index/list_registered_indexesfunctions inregistry.pyleann buildto register indexes in global registryleann listto use registry when available (with scan fallback)leann removeto unregister indexes from registryHow it works
When registry is used,
leann listoutput shows:When falling back to scan (for legacy indexes):
Test plan
Closes #198
🤖 Generated with Claude Code