swiper icon indicating copy to clipboard operation
swiper copied to clipboard

counsel-fzf is slow when ran on the home directory

Open ghost opened this issue 6 years ago • 9 comments

when using fzf in the terminal there is no lag what so ever, but using it with counsel-fzf in large directories like the home directory makes it slow

ghost avatar Dec 29 '19 08:12 ghost

Same issue here.

ianyepan avatar Dec 30 '19 07:12 ianyepan

This is because counsel-fzf is synchronously in the background. Meaning they have to scan every file before they return. fzf in the terminal is constantly scanning while you are typing so there is no delay.

CeleritasCelery avatar Jan 15 '20 21:01 CeleritasCelery

@CeleritasCelery, counsel-fzf-function calls counsel--async-command, so it's rather asynchronous, plus :dynamic-collection t. As a result, at least for me, it's rocket-fast, and always was. Those who claim issues, should at least post versions of all the software stack they use, environment variables, and output of profiler-report.

Alexander-Shukaev avatar Jan 16 '20 16:01 Alexander-Shukaev

it is async, but it waits for the process to exit before it collects the candidates. And dynamic-collection means that it has to be rerun after every input, which can also make it slow.

https://github.com/abo-abo/swiper/blob/master/counsel.el#L208

The terminal version does not have the limitation.

counsel-fzf is quite slow for me as well. I get much better performance from counsel-file-jump because it is not a dynamic collection.

CeleritasCelery avatar Jan 16 '20 16:01 CeleritasCelery

I am experiencing some kinds of slowness as well, it is when C-n and C-p, navigating the ivy prompt, it feels a bit unresponsive. If I were to edit the prompt, ivy actually updates quite quickly. I think this is the behaviour for all ivy-read that has :dynamic-collection as t, which is what as of now, what I think what all these commands that are slow has in common, such as counsel-fzf, counsel-ag, counsel-grep.

Inc0n avatar Sep 18 '20 15:09 Inc0n

I have just now realized that for these commands that seems slow to me, it is actually because the ivy prompt would not update selection (highlight) with consecutive C-n or C-p, until some certain delay, which is actually controlled by ivy-dynamic-exhibit-delay-ms. After i set it to 0, it's fine for me now This might mean that my issue is slightly different from what is described is this thread!

Inc0n avatar Sep 18 '20 15:09 Inc0n

Got this as well, though I was able to get a snappier experience with fd: (setq counsel-fzf-cmd "fd -c never \"%s\"")

Uthar avatar Apr 21 '22 17:04 Uthar

@Uthar thats for sharing, thats really awesome. Really snappy. With -H you also geht hidden but not ignored files.

;; counsel
(use-package counsel :ensure t
  :config
  (counsel-mode 1)
  (setq counsel-fzf-cmd "fd -H -c never \"%s\""))

Maybe this should be the default? It's insane how much faster this is.

foosinn avatar Apr 26 '22 08:04 foosinn

Maybe this should be the default? It's insane how much faster this is.

This, or maybe lets add a counsel-fd function? Should be very easy, and won't break current configs.

Uthar avatar Apr 29 '22 16:04 Uthar