junegunn / fzf

:cherry_blossom: A command-line fuzzy finder
https://junegunn.github.io/fzf/
MIT License
65.44k stars 2.41k forks source link

fzf is slow in large directory #1419

Closed heycam closed 6 years ago

heycam commented 6 years ago

I'm working in a project directory that has almost 300,000 files under it. I'd like to use fzf to avoid typing out long path names but it's too slow on my machine:

cam@zoo /z/moz/central $ time find . -type f | wc -l
289362

real    0m0.391s
user    0m0.172s
sys 0m0.236s
cam@zoo /z/moz/central $ time /z/fzf/bin/fzf -f properties.mako.rs | head -1
servo/components/style/properties/properties.mako.rs

real    1m22.918s
user    0m36.776s
sys 0m30.108s

Is there anything I can do to make fzf fast enough for interactive use?

DanielFGray commented 6 years ago

fzf is rarely ever the bottleneck in my usage. Consider using a different program to list files, for example export FZF_DEFAULT_COMMAND with your choice of ag rg or similar.

Compared to other filter related programs, eg selecta or fzy, fzf is the only I've found that doesn't buffer stdin and makes the UI visible and usable while the input program is still running. If you have ideas on how to improve "throughput" from stdin to the UI I would love to read your pull request.

heycam commented 6 years ago

Thanks for the hint, Daniel! It looks like the default command when FZF_DEFAULT_COMMAND is not set,

find -L . -mindepth 1 \( -path '*/\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \) -prune -o -type f -print -o -type l -print 2> /dev/null | cut -b3-

is just super slow. When I do use find . -type f, I get much more reasonable times:

cam@zoo /z/moz/central $ time FZF_DEFAULT_COMMAND='find . -type f' /z/fzf/bin/fzf -f properties.mako.rs | head -1
./servo/components/style/properties/properties.mako.rs

real    0m0.407s
user    0m0.360s
sys 0m0.320s
ogaida commented 5 months ago

i know it's old, but anyway a hint, i use --walker-skip=Library,.git,node_modules

johnrhunt commented 4 months ago

This shouldn't be closed? I'd expect this tool to be fast due to its indexing but it isn't.

DanielFGray commented 4 months ago

I'd expect this tool to be fast due to its indexing but it isn't.

fzf is not a file finder, it is an interactive filter for stdin, that just so happens to list files as a default behavior when not given stdin

afaik it does not index your file system, and on windows you are likely to experience some fairly noticeable performance issues due to windows antivirus hooks in the filesystem