Skip to content

__fish_complete_directories is slow on WSL2 #9574

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

Closed
eero-lehtinen opened this issue Feb 13, 2023 · 2 comments
Closed

__fish_complete_directories is slow on WSL2 #9574

eero-lehtinen opened this issue Feb 13, 2023 · 2 comments

Comments

@eero-lehtinen
Copy link

❯ fish --version
fish, version 3.6.0

❯ uname -a
Linux EeroPC 5.15.83.1-microsoft-standard-WSL2 #1 SMP Wed Dec 14 23:16:32 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

The fish command __fish_complete_directories is slow compared to __fish_complete_cd on WSL2.

~/test
❯ set CDPATH ./

~/test
❯ time __fish_complete_cd
./test1/        CDPATH ./
./test2/        CDPATH ./

________________________________________________________
Executed in  858.00 micros    fish           external
   usr time   89.00 micros   89.00 micros    0.00 micros
   sys time  750.00 micros  750.00 micros    0.00 micros


~/test
❯ time __fish_complete_directories
test1/  Directory
test2/  Directory

________________________________________________________
Executed in  139.07 millis    fish           external
   usr time    2.57 millis    2.57 millis    0.00 micros
   sys time   21.88 millis   21.88 millis    0.00 micros

This seems to be because fish searches the whole path for commands thanks to of this hack https://github.com/fish-shell/fish-shell/blob/904839dccee9aad844889b57c2c56a818cde9905/share/functions/__fish_complete_directories.fish#LL18. On WSL2, $PATH includes a lot of mounted windows paths that are slow to search, e.g. /mnt/c/WINDOWS/system32.

We really should find a solution for this hack to make __fish_complete_directories acceptably fast on WSL2. I am running into this problem because zoxide uses this command. It makes completions annoyingly slow on fish while other shells don't have any issues.

@eero-lehtinen
Copy link
Author

eero-lehtinen commented Feb 13, 2023

As a workaround, one can add

[interop]
appendWindowsPath = false

to the file /etc/wsl.conf.

This weirdly makes __fish_complete_directories even faster than __fish_complete_cd at least for me.

~/test
❯ time __fish_complete_directories
test1/  Directory
test2/  Directory

________________________________________________________
Executed in  555.00 micros    fish           external
   usr time  211.00 micros  211.00 micros    0.00 micros
   sys time  344.00 micros  344.00 micros    0.00 micros

@faho faho added this to the fish 3.6.1 milestone Feb 14, 2023
@faho faho closed this as completed in 2000959 Feb 14, 2023
zanchey pushed a commit that referenced this issue Feb 27, 2023
@tenzinhl
Copy link

tenzinhl commented Oct 4, 2023

Heyo!

I'm on fish version 3.6.1:

> fish --version
fish, version 3.6.1

Just wanted to note that hitting tab on an empty prompt (unsure what underlying function this calls) still leads to slow performance on WSL2 if the workaround eero-lehtinen proposed isn't used (thanks for that btw! Works great). Fix definitely works great for directory completion though.

I guess this is expected? (I think this searches the PATH for all commands to auto-complete, which for mount directories is super slow). Noting it either way though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants