nvim-telescope / telescope-frecency.nvim

A telescope.nvim extension that offers intelligent prioritization when selecting files from your editing history.
MIT License
688 stars 35 forks source link

Prefer fd over rg for faster performance #198

Closed zhengpd closed 1 month ago

zhengpd commented 1 month ago

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 commented 1 month ago

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