Skip to content

Fix find_files slowness with SQLite FindIndex (#354). - #366

Merged
makiroll1125 merged 7 commits into
CraftOS-dev:V1.4.1from
false200:fix/find-files-index-354
Jul 8, 2026
Merged

Fix find_files slowness with SQLite FindIndex (#354).#366
makiroll1125 merged 7 commits into
CraftOS-dev:V1.4.1from
false200:fix/find-files-index-354

Conversation

@false200

@false200 false200 commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

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_files behaves the same:

  • empty base_directory still goes to home
  • the agent can still search wherever it wants
  • we still crawl everything, including stuff like $Recycle.Bin
  • the response is still just status, matches, and message - all matches, no head_limit

The difference is recursive searches hit the index instead of running os.walk every single time. Non recursive is unchanged - still just a top level glob.

After the first build, watchdog keeps the index updated with a 5 second debounce.

Also added **/.craftbot/ to .gitignore so those runtime DB files don't get committed.

namabeeru and others added 2 commits July 3, 2026 23:27
Signed-off-by: namabeeru <github.body594@passmail.com>
…heck

fix: detect source checkout updates
@false200

false200 commented Jul 4, 2026

Copy link
Copy Markdown
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.

@makiroll1125
makiroll1125 self-requested a review July 6, 2026 00:50

@makiroll1125 makiroll1125 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I listed some suggestions regarding search patterns and issues I noticed.

Comment thread app/utils/file_index.py
Comment thread app/utils/file_index.py Outdated
Comment thread app/utils/file_index.py Outdated
Comment thread app/data/action/find_files.py Outdated
Replace per-call os.walk with a cached filename index and watchdog updates while keeping existing path semantics and output shape.
@false200
false200 force-pushed the fix/find-files-index-354 branch from 1821fb1 to da0be4a Compare July 6, 2026 14:00
@false200

false200 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

I listed some suggestions regarding search patterns and issues I noticed.

I’ve implemented the required changes, please review when you’re free.

@false200
false200 requested a review from makiroll1125 July 6, 2026 14:12
@makiroll1125

Copy link
Copy Markdown
Collaborator

I’ve implemented the required changes, please review when you’re free.

New commit here: f71d591
Please take a look when you have time. I made changes regarding prewarming all drives. CraftBot kicks off a background thread at launch that builds the index for every local fixed drive before the user asks. It is also much faster and has great performance.

I also noticed some other issues regarding incorrectly set parameters that was causing CraftBot to rebuild the entire index each time find_files was called. Try running some tests (ask CraftBot to search for files with a specific tag in their title) and let me know how it runs. Assuming no issues, could you pull the commit to your branch so that I can merge the PR?

@false200

false200 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

I’ve implemented the required changes, please review when you’re free.

New commit here: f71d591 Please take a look when you have time. I made changes regarding prewarming all drives. CraftBot kicks off a background thread at launch that builds the index for every local fixed drive before the user asks. It is also much faster and has great performance.

I also noticed some other issues regarding incorrectly set parameters that was causing CraftBot to rebuild the entire index each time find_files was called. Try running some tests (ask CraftBot to search for files with a specific tag in their title) and let me know how it runs. Assuming no issues, could you pull the commit to your branch so that I can merge the PR?

Sure!

@false200

false200 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@makiroll1125 I've pulled it to my local branch. Feel free to merge it.

@makiroll1125 makiroll1125 added priority: medium Improvement Optimization and improvement over existing feature labels Jul 8, 2026

@makiroll1125 makiroll1125 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to go

@makiroll1125
makiroll1125 merged commit e80d21e into CraftOS-dev:V1.4.1 Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Improvement Optimization and improvement over existing feature priority: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants