Skip to content

Feature: Change File Search to use mfind#206

Merged
unsecretised merged 4 commits intoRustCastLabs:masterfrom
tanishq-dubey:master
Mar 22, 2026
Merged

Feature: Change File Search to use mfind#206
unsecretised merged 4 commits intoRustCastLabs:masterfrom
tanishq-dubey:master

Conversation

@tanishq-dubey
Copy link
Copy Markdown
Contributor

This PR changes the standard file search to use the mfind utilty on MacOS.

mfind uses the OS build Spotlight index to make searching faster, and bias results with usage and recency statistics. This implementation calls out to mfind and streams results back. Because this uses a prebuilt index, serach speeds are stable even as search scope increases. This means we can change the default search path to the entire home directory.

It should be noted that this implementation should be replaced with a native call to NSMetadataQuery or similar in the future to avoid the shell call.

Below is a benchmark comparing the previous method and the mfind method across ~/Documents + ~/Desktop + ~/Downloads and ~, demonstrating stable speeds as scope increases:

============================================
  BENCHMARK: ~/Documents + ~/Desktop + ~/Downloads
============================================

=== WalkBuilder file search benchmark ===
Dirs: ["~/Documents", "~/Desktop", "~/Downloads"]  |  Iterations per query: 5
Query          Min (ms)   Max (ms)   Avg (ms)  Results
--------------------------------------------------------
pdf               14.46      15.89      14.90       33
png               13.94      14.45      14.11      323
doc               13.83      14.49      14.10        9
screen            14.05      14.57      14.29       18
note              14.26      15.49      14.83        4

=== mdfind file search benchmark ===
Dirs: ["~/Documents", "~/Desktop", "~/Downloads"]  |  Iterations per query: 5
Query          Min (ms)   Max (ms)   Avg (ms)  Results
--------------------------------------------------------
pdf               25.34      26.20      25.74       30
png               28.91      32.98      30.50      314
doc               24.39      26.15      25.26        8
screen            25.09      26.62      25.98       20
note              23.88      24.92      24.51        5

============================================
  BENCHMARK: ~ (entire home directory)
============================================

=== WalkBuilder file search benchmark ===
Dirs: ["~"]  |  Iterations per query: 5
Query          Min (ms)   Max (ms)   Avg (ms)  Results
--------------------------------------------------------
pdf            11705.89   17497.28   13041.27      168
png              365.70    1199.77     533.60      400
doc              172.10     186.17     175.55      400
screen         10696.30   11556.99   11344.42      172
note           11461.39   12046.75   11694.27      245

=== mdfind file search benchmark ===
Dirs: ["~"]  |  Iterations per query: 5
Query          Min (ms)   Max (ms)   Avg (ms)  Results
--------------------------------------------------------
pdf               31.99      57.67      37.98      205
png              211.85     481.31     268.02      400
doc               50.02     221.23      85.31      400
screen            31.30      51.75      36.66      147
note              31.64      48.37      35.30      173

@unsecretised
Copy link
Copy Markdown
Collaborator

It should be noted that this implementation should be replaced with a native call to NSMetadataQuery or similar in the future to avoid the shell call.

Would it be possible to do this implementation now itself?

@unsecretised unsecretised merged commit 4a7eff1 into RustCastLabs:master Mar 22, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants