zimfw / zimfw

Zim: Modular, customizable, and blazing fast Zsh framework
https://zimfw.sh
MIT License
3.89k stars 180 forks source link

Few tab completions on WSL2 takes 5-10 seconds #412

Open NoelJacob opened 4 years ago

NoelJacob commented 4 years ago

Description

In WSL2, tab completion is very slow on executable files and in certain directories

Steps to Reproduce

a<tab>
# Wait 5-10 seconds and it will eventually show the completion menu

The issue is much more evident when tab completing a specific file that is in the immediate directory and thus doesn't require the menu to appear:

cd ~
touch foo
chmod +x foo
./fo<tab>
# Wait 5-10 seconds and it will eventually complete the word foo

I'm not sure if this is a zsh issue or a prezto issue, however if I disable prezto and use vanilla zsh, the tab completion is instant. The vanilla tab completion doesn't use the menu however, so it could also be the menu's fault, but I'm not sure how to verify that.

I have noticed that WSL, by default, puts a lot of /mnt/c directories (such as /mnt/c/Windows/) on $PATH.

If I remove those directories, then tab completion is fast. For now, as a workaround I have the following in my profile which works:

export PATH=$(echo $PATH | tr ':' '\n' | grep -v "/mnt/c/" | tr '\n' ':')

With that workaround in place, everything is fast, however I can kind of force the issue anyway by doing:

cd /mnt/c/Windows/System32
a<tab>
# Wait 3-5 seconds for the completion menu to appear

My guess is something about these Windows directories is overloading completion, but I have no idea how to narrow this down any further. I've also tried the following to no effect: sudo updatedb rm -rf ~/.zcompdump

Versions

Prezto commit: [de7b3b7](https://github.com/sorin-ionescu/prezto/commit/de7b3b7fdc99f8a67320dc64085dea44914969c7)
ZSH version: `zsh 5.4.2 (x86_64-ubuntu-linux-gnu)`
OS information: `Ubuntu 18.04.4 LTS \n \l` on WSL2 - `Microsoft Windows [Version 10.0.19592.1001]`

By @Fryguy source: https://github.com/sorin-ionescu/prezto/issues/1820#issue-596987462

In a terminal, run zmanage info and paste the output below:

ZIM_HOME:      /root/.zim
Zsh version:   5.8
System info:   Linux JOEL 4.19.128-microsoft-standard #1 SMP Tue Jun 23 12:58:10 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
marciliocn commented 3 years ago

Aditional info: disabling only zmodule completion the problem was solved.

PatTheMav commented 3 years ago

I might be mistaken, but I fail to see how this is an issue with zimfw, as the completion-feature is built-in to zsh and it seems to me the root cause is Windows adding a whole lot of directories to the path that the shell needs to walk through for completions.

Fryguy commented 3 years ago

I'm not sure about zimfw, but when I reported this in prezto, the vanilla completion in zsh worked fine with all of the extra directories, but in prezto it was slow. See https://github.com/sorin-ionescu/prezto/issues/1820#issue-596987462

lnicola commented 3 years ago

Do you have syntax highlighting enabled? The original part here has a wrong link.

EDIT: yeah, PATH_DIRS sounds like trouble.