Fix find_files slowness with SQLite FindIndex (#354).#366
Open
false200 wants to merge 1 commit into
Open
Conversation
Replace per-call os.walk with a cached filename index and watchdog updates while keeping existing path semantics and output shape.
Contributor
Author
|
@makiroll1125 I've pushed an improvement for this issue. There isn't really a single best solution since each approach has tradeoffs, but this should make search work better than the previous one. Would appreciate a review. |
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.
Fixes #354
So basically I added a new file,
app/utils/file_index.py, that builds a SQLite index of filenames (FTS5 trigram on the basename). It lives at{base_directory}/.craftbot/findindex.db.From the outside,
find_filesbehaves the same:base_directorystill goes to home$Recycle.Binstatus,matches, andmessage- all matches, nohead_limitThe difference is recursive searches hit the index instead of running
os.walkevery single time. Non recursive is unchanged - still just a top level glob.After the first build,
watchdogkeeps the index updated with a 5 second debounce.Also added
**/.craftbot/to.gitignoreso those runtime DB files don't get committed.