Skip to content
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

Very Slow on WSL 2 #1038

Closed
HymanZHAN opened this issue Apr 1, 2020 · 6 comments
Closed

Very Slow on WSL 2 #1038

HymanZHAN opened this issue Apr 1, 2020 · 6 comments
Labels
🐛 bug Something isn't working as expected.

Comments

@HymanZHAN
Copy link

HymanZHAN commented Apr 1, 2020

To be honest I don't know if I should post the issue here or on WSL's repo but considering a vanilla zsh does not have this problem I will post the issue here first.

Current Behavior

zsh with starship is super slow on WSL2. For example, after hitting Enter, I need to wait for 5 to 20 seconds before the new prompt appears.

Expected Behavior

Adding starship prompt should not hinder performance this much.

Additional context/Screenshots

  • Oh-my-zsh has a similar if not worse performance issue. (I was using the spaceship theme.)

  • This performance issue is not that bad if the current directory does not contain a lot of files.

  • zsh without starship:
    zsh_no_starship

  • zsh with starship
    zsh_with_starship

Environment

  • Starship version: 0.38.1
  • zsh version: zsh 5.4.2 (x86_64-ubuntu-linux-gnu)
  • Operating system: Ubuntu 18.04
  • Terminal emulator: Windows Terminal

Relevant Shell Configuration

# personal aliases
alias mooc="cd /mnt/c/Users/zhanx/Development/MOOC"
alias proj="cd /mnt/c/Users/zhanx/Development/Projects"
alias pk="cd /mnt/c/Users/zhanx/Development/Packages"
alias wk="cd /mnt/c/Users/zhanx/Development/Work"
alias da="deactivate"
alias dcu="docker-compose up"
alias dcud="docker-compose up -d"
alias dex="docker-compose exec"
alias dcd="docker-compose down"
alias dcs="docker-compose stop"
alias dcl="docker-compose logs"
alias vim="nvim"
alias ls="lsd"
alias ll="lsd -l"

# added for miniconda3
export PATH="/home/xzhan/miniconda3/bin:$PATH"

# added for pipenv
export PIPENV_VENV_IN_PROJECT=True
eval "$(pipenv --completion)"

# added for rust
export PATH="/home/xzhan/.cargo/bin:$PATH"

# added for nvm
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

eval "$(starship init zsh)"

Starship Configuration

add_new_line = false

[character] 
symbol = ">" 


[aws]
symbol = ""

[battery]
full_symbol = ""
charging_symbol = ""
discharging_symbol = ""

[conda]
symbol = ""

[git_branch]
symbol = ""
style = "bold yellow"

[golang]
symbol = ""

[hg_branch]
symbol = ""

[java]
symbol = ""

[memory_usage]
symbol = ""

[nodejs]
symbol = ""

[package]
symbol = ""

[php]
symbol = ""

[python]
symbol = ""

[ruby]
symbol = ""

[rust]
symbol = ""
@HymanZHAN HymanZHAN added the 🐛 bug Something isn't working as expected. label Apr 1, 2020
@chipbuster
Copy link
Contributor

Does this issue occur in all paths or just ones with git repos?

We've been getting a number of reports of slow performance of starship in git repos even not in WSL2, but if this occurs outside of git repos then it's probably an unrelated issue.

@HymanZHAN
Copy link
Author

@chipbuster Thanks for the reply. I can provide some additional (and related) findings but there's some more digging I would like to do on WSL2. Once that's done I will report back.

So last night I switched back to WSL 1 and did some testing, and I had the following findings:

  • Locally on Win10, Powershell Core 7 with starship works great on any path (even large git repo). No performance issue noticed.
  • In WSL 1, inside that repo in the GIF shell performance with starship is still bad. It's noticeably better though (printing a new line takes about 7s now compared to over 30s).
  • Interestingly, I cloned the same repo to a new folder, installed all the Python and Node packages, and the shell performance was actually normal/good. I somewhat expected so because I have been using oh-my-zsh on WSL 1 without significant frustration for quite some time.

I am going to switch back to WSL 2, do some more testing and report back.

@HymanZHAN
Copy link
Author

HymanZHAN commented Apr 2, 2020

Hah, I think I spotted the pattern here!

In WSL 2, when the current directory is in the Windows C: drive (/mnt/c/ in WSL), starship performance will become super slow, which can be seen from the attached GIF:

zsh_wsl2_with_starship_linux_path

I will file an issue in WSL's repo, or link a similar issue if I found one.

Update: Related discussion microsoft/WSL#4197

@HymanZHAN
Copy link
Author

I will close this for now as the problem is mostly on the WSL 2 side.

@jonahsnider
Copy link

jonahsnider commented Apr 24, 2020

I believe this has to do with how WSL 2 optimizes FS access between the virtual Linux disk and the Windows physical disk:

You will notice slower file speeds compared to WSL 1 when accessing Windows files from a Linux application, or accessing Linux files from a Windows application. This is a result of the architectural changes in WSL 2, and is something that the WSL team is actively investigating on how we can improve this experience

[source]

@DanielAtKrypton
Copy link

@pizzafox try this. It may shed some light on how to make Starship correctly within WSL2.

This is how my Zsh terminal currently looks like:
Imgur

These are the prompts I use:

  • Within Powershell core in Windows I use Starship.
  • Within Debian in WSL2 I use Powerlevel 10k.

One of the most useful features in my opinion is git tab completion.

It even detects branch names and auto complete them on tab.

This works best on Zsh. But it would be nice to see the same functionality in Starship regardless if using Zsh prompt or any other.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working as expected.
Projects
None yet
Development

No branches or pull requests

4 participants