abo-abo / swiper

Ivy - a generic completion frontend for Emacs, Swiper - isearch with an overview, and more. Oh, man!
https://oremacs.com/swiper/
2.32k stars 338 forks source link

Performance problems with ivy / find-file over high-latency Tramp connections #1763

Open WJCFerguson opened 6 years ago

WJCFerguson commented 6 years ago

I'm looking for help making ivy usable over high-latency connections. I would be sad to have to disable it.

When trying to run find-file over a high latency Tramp connection each file is checked for existence separately, meaning in a directory with a lot of files, getting a prompt takes many seconds (in my case, 200 files in a directory => 10s).

I confirmed that emacs -Q with tab completion gives near instant response and doesn't quiz individually for file existence. Loading ivy into that pristine emacs -Q gives the 10s response time, so I don't think it's my config.

Is there a way to avoid this?

Thanks


From tramp debug log with tramp-verbose set to 9 (real pathname substituted):

09:32:44.937326 tramp-get-file-property (8) # <<pathname>> file-exists-p undef
09:32:44.937833 tramp-get-file-property (8) # <<pathname>> file-attributes-integer nil
09:32:44.938284 tramp-get-file-property (8) # <<pathname>> file-attributes-string nil
09:32:44.938617 tramp-get-connection-property (7) # file-exists test -e
09:32:44.939098 tramp-get-connection-property (7) # process-name nil
09:32:44.939409 tramp-get-connection-property (7) # process-name nil
09:32:44.939714 tramp-get-connection-property (7) # process-buffer nil
09:32:44.940033 tramp-get-connection-property (7) # last-cmd-time (23460 62204 885902 852000)
09:32:44.940375 tramp-get-connection-property (7) # process-name nil
09:32:44.940702 tramp-get-connection-property (7) # remote-echo nil
09:32:44.941002 tramp-send-command (6) # test -e <<pathname>> 2>/dev/null; echo tramp_exit_status $?
09:32:44.941301 tramp-get-connection-property (7) # process-name nil
09:32:44.941585 tramp-get-connection-property (7) # chunksize 0
09:32:44.941910 tramp-set-connection-property (7) # last-cmd-time (23460 62204 941809 501000)
09:32:44.942234 tramp-get-connection-property (7) # process-buffer nil
09:32:44.942682 tramp-get-connection-property (7) # check-remote-echo nil
09:32:44.943044 tramp-get-connection-property (7) # check-remote-echo nil
09:32:44.987853 tramp-get-connection-property (7) # check-remote-echo nil
09:32:44.988331 tramp-get-connection-property (7) # check-remote-echo nil
09:32:44.988677 tramp-wait-for-regexp (6) # 
tramp_exit_status 0
///994a1546dd5d78550dfd239a9745d33f#$
09:32:44.989312 tramp-get-connection-property (7) # process-buffer nil
09:32:44.989945 tramp-set-file-property (8) # <<pathname>> file-exists-p t
CeleritasCelery commented 5 years ago

I don't think there is much that can be done here. counsel does not check the existence of every file but uses read-file-name-internal which grabs all files at once. When I open a directory of 2000 files over tramp with counsel-find-file it takes about 3 seconds.

Alexander-Shukaev commented 5 years ago

Or use remotely installed fzf and be happy if possible. Other than that, this ticket can be closed I believe.

Alexander-Shukaev commented 5 years ago

Actually, you can also use counsel-file-jump and it should be faster because it uses find internally.

abo-abo commented 5 years ago

Here's what Ivy uses to produce a list of files:

(all-completions "" 'read-file-name-internal)

This works on remote via TRAMP as well. This is a combination of two built-in functions, not related to Ivy. If someone can propose a way to speed this up, I'd be willing to test and integrate it.