Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefer fd over rg for faster performance #198

Closed
zhengpd opened this issue May 20, 2024 · 1 comment · Fixed by #199
Closed

Prefer fd over rg for faster performance #198

zhengpd opened this issue May 20, 2024 · 1 comment · Fixed by #199

Comments

@zhengpd
Copy link
Contributor

zhengpd commented May 20, 2024

It might be faster to change the workspace_scan_cmd order to try fd before rg. fd is designed to list files while rg is designed to search files.

In my computer fd cost less time than rg with the tradeoff of higher cpu usage.

# files count: 9858
# timing:
rg -.g '!.git' --files  0.10s user 0.31s system 211% cpu 0.191 total
fd -Htf  0.09s user 0.21s system 561% cpu 0.054 total
@delphinus
Copy link
Contributor

I see. I also tried for 140,000 over files with hyperfine and found fd -Htf is faster than rg -.g "!.git" --files, which are the defaults in this plugin. I will set more precedence for fd over rg.

hyperfine --warmup 3 'rg -.g "!.git" --files' 'fd -Htf'

Benchmark 1: rg -.g "!.git" --files
  Time (mean ± σ):      1.035 s ±  0.048 s    [User: 0.735 s, System: 2.309 s]
  Range (min … max):    0.966 s …  1.130 s    10 runs

Benchmark 2: fd -Htf
  Time (mean ± σ):     845.0 ms ±  30.3 ms    [User: 708.9 ms, System: 2449.6 ms]
  Range (min … max):   816.9 ms … 914.6 ms    10 runs

Summary
  fd -Htf ran
    1.23 ± 0.07 times faster than rg -.g "!.git" --files

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 a pull request may close this issue.

2 participants