Skip to content
This repository has been archived by the owner on Apr 24, 2020. It is now read-only.

Slow command execution #718

Closed
lukaszog opened this issue Jan 10, 2018 · 22 comments
Closed

Slow command execution #718

lukaszog opened this issue Jan 10, 2018 · 22 comments
Assignees
Labels

Comments

@lukaszog
Copy link

Hi,
I'm using Windows 10 with WSL VcxServer and Gnome Terminal. Yesterday I installed oh my zsh and fonts. Everything working good and fast, next I add powerlevel9k as a theme to my .zshrc after this execution of commands has slowed down, the prompt is loading for a long time. Why? Can I fix it?

longloading

My config

#If you come from bash you might have to change your $PATH.
export LS_COLORS="ow=01;36;35"
export TERM="xterm-256color"   
export PATH=$HOME/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games  

# Path to your oh-my-zsh installation.
  export ZSH=/home/lukasz/.oh-my-zsh

# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
POWERLEVEL9K_MODE='nerdfont-complete'
ZSH_THEME="powerlevel9k/powerlevel9k"

# Set list of themes to load
# Setting this variable when ZSH_THEME=random
# cause zsh load theme from this variable instead of
# looking in ~/.oh-my-zsh/themes/
# An empty array have no effect
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )

# Uncomment the following line to use case-sensitive completion.
CASE_SENSITIVE="true"

# Uncomment the following line to use hyphen-insensitive completion. Case
# sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"

# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"

# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13

# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"

# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"

# Uncomment the following line to enable command auto-correction.
ENABLE_CORRECTION="true"

# Uncomment the following line to display red dots whilst waiting for completion.
# COMPLETION_WAITING_DOTS="true"

# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
DISABLE_UNTRACKED_FILES_DIRTY="true"

# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# HIST_STAMPS="mm/dd/yyyy"

# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder

# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(
  git
)

source $ZSH/oh-my-zsh.sh
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(os_icon context dir)
	POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator background_jobs history time)
# User configuration

# export MANPATH="/usr/local/man:$MANPATH"

# You may need to manually set your language environment
# export LANG=en_US.UTF-8

# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
#   export EDITOR='vim'
# else
#   export EDITOR='mvim'
# fi

# Compilation flags
# export ARCHFLAGS="-arch x86_64"

# ssh
# export SSH_KEY_PATH="~/.ssh/rsa_id"

# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
unsetopt BG_NICE
export DISPLAY=localhost:0
@lukaszog
Copy link
Author

Anyone can help?

@bhilburn
Copy link
Member

bhilburn commented Feb 2, 2018

Hey @lukaszog - sorry for the delayed response! And wow, you're right, that's painfully slow. Looking at the list of segments you are using, I don't see anything that should cause that - those are all fairly simple segments.

I don't have any direct experience using P9k on WSL, so I wonder if there is something specific to WSL that might be happening. Pinging @jldeen in case she has any insight.

Can you tell me what version of P9k you are using and how you installed it?

@bhilburn bhilburn self-assigned this Feb 2, 2018
@jldeen
Copy link

jldeen commented Feb 2, 2018

Thanks for looping me in @bhilburn! @lukaszog - I will test your config on WSL in my own environment ASAP and will circle back. Can you also confirm the version of WSL / Windows you're using? Are you on an Insider build?

@ghost
Copy link

ghost commented Feb 10, 2018

I have the same issue on my machine. The symptoms are the same as the ones described above, but the VCS segment is particularly bad: Building the prompt takes about 2.5 seconds whenever I am in a git repo. Note that the reop doesn't seem to matter much, this time is the same in a newly initialized repo and a populated one, so it's probably something else.

My device is a Surface Pro 3 and I am running the current Windows 10 release (1709, Build 16299.192) with CMDer/ConEmu as my terminal emulator. However, the issue also appears when using the Windows built-in terminal.

Here is my .zshrc

#Gerneral
export ZSH=~/.oh-my-zsh
POWERLEVEL9K_MODE='nerdfont-complete'
ZSH_THEME="powerlevel9k/powerlevel9k"

#WSL-specific stuff
umask 022

#Oh-my-zsh Settings
COMPLETION_WAITING_DOTS="true"
plugins=(git)
source $ZSH/oh-my-zsh.sh

#External
export SSH_KEY_PATH="~/.ssh/rsa_id"
export EDITOR='nano'
source ~/.aliases
eval $(dircolors ~/.dircolors)

#Powerlevel9k Segments
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(root_indicator dir_writable host dir vcs)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status command_execution_time time)

#Powerlevel9k Settings
POWERLEVEL9K_CONTEXT_TEMPLATE='@%m'
POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD='2'
POWERLEVEL9K_STATUS_OK='false'

#Powerlevel9k Colors
POWERLEVEL9K_ROOT_INDICATOR_BACKGROUND='red'
POWERLEVEL9K_ROOT_INDICATOR_FOREGROUND='white'
POWERLEVEL9K_HOST_LOCAL_BACKGROUND='white'
POWERLEVEL9K_HOST_REMOTE_BACKGROUND='green'
POWERLEVEL9K_HOST_LOCAL_FOREGROUND='black'
POWERLEVEL9K_HOST_REMOTE_FOREGROUND='black'
POWERLEVEL9K_CONTEXT_DEFAULT_BACKGROUND='white'
POWERLEVEL9K_CONTEXT_DEFAULT_FOREGROUND='black'
POWERLEVEL9K_DIR_HOME_FOREGROUND="black"
POWERLEVEL9K_DIR_HOME_SUBFOLDER_FOREGROUND="black"
POWERLEVEL9K_DIR_DEFAULT_FOREGROUND='black'
POWERLEVEL9K_COMMAND_EXECUTION_TIME_BACKGROUND='yellow'
POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND='black'
POWERLEVEL9K_STATUS_OK_BACKGROUND='blue'
POWERLEVEL9K_STATUS_OK_FOREGROUND='black'
POWERLEVEL9K_STATUS_ERROR_BACKGROUND='red'
POWERLEVEL9K_STATUS_ERROR_FOREGROUND='white'
POWERLEVEL9K_TIME_FOREGROUND='black'
POWERLEVEL9K_TIME_BACKGROUND='white'
POWERLEVEL9K_IP_BACKGROUND='blue'```

@jldeen
Copy link

jldeen commented Feb 12, 2018

@ThaneDE @lukaszog I've played with this a bit and I too can replicate the slowness. What's weird is I can replicate this on both WSL and MacOS. I'm wondering if it's something other than a WSL issue. I seem to have the issue with the VCS segment enabled. While the below is not a gif, you can see the spacing between where I enter a new line without cd'ing into a Git branch (using VCS) and then when I do.

image

@bhilburn Are you able to work with me offline at dissecting this? I'm wondering if it's something in my dotfiles/install.sh that needs to be tweaked. I can then update it for WSL and MacOS w/ P9K.

@lukaszog
Copy link
Author

@bhilburn I have newest version of powerlevel9k. I install it with instructions on github.
@jldeen I'm in insider preview, my version: Linux luklab 4.4.0-43-Microsoft #1-Microsoft Wed Dec 31 14:42:53 PST 2014 x86_64 x86_64 x86_64 GNU/Linux. Do you known how to disable this prompt lag?

@ghost
Copy link

ghost commented Feb 14, 2018

So, I decided to investigate this issue a little more closely - so far I've made two observations that might be relevant:

First, the prompt build speed seems to depend on the hardware used. My Surface Pro 3 (i5-4300U, 8 GB RAM) is slower (the than my custom-built PC (Ryzen 5 1600, 16 GB RAM) when running the same Windows version and zsh config. My Surface takes over 2.5-ish seconds, while my PC is done in less than 2. There is also quite a bit of CPU load whenever I make a call within a git repo, but I don't think this is related as it also happens on the VM (see below). I still attached a screenshot, just in case (the red spike is calling ls in a git repo, the blue one is ls outside of a repository).
unbenannt

I've also tested an older version of Windows 10 (1607) in a VM and found it to be significantly faster than the current build. In the gif below, the left side is my custom-built PC, to the right side is a VirtualBox VM running said Windows version. As you can see, there is still some delay but it's much more manageable than on the current build.
comparsion

If there is anything else I can help with, I'm happy to, well, help

@lukaszog
Copy link
Author

@jldeen @bhilburn @ThaneDE anyone can fix it? It possible?

@bhilburn
Copy link
Member

@ThaneDE - Wow! Thanks so much for the in-depth investigation! This is really helpful. Also, 2.5 seconds is really bad. I've never seen it take that long.

Also, the results your experiment are really interesting to me. Can you post a table of the software in use on the two systems? What version of Windows, ZSH, git, and P9k?

@lukaszog @jldeen - It looks like we have two issues, here. Based on @ThaneDE's experiment, one seems to be somehow linked to versioning in some Windows software (not necessarily Windows itself). Another is just the VCS segment being a pain.

We are already working on speeding up the VCS segment (#732) - note that the next branch is frozen while @onaforeignshore and I do some heavy refactoring of the code-base to allow us to more easily integrate an async library.

Once we get more details from @ThaneDE on his versions, above, we can look into that further, too.

Thanks, everyone, for your time, feedback, and input in this! It's a really important issue, and your help in tracking down the issues and getting them fixed is superb =)

@ghost
Copy link

ghost commented Mar 13, 2018

@bhilburn Sure thing!

Both systems are running the most recent version of Windows 10 (1709) and the corresponding WSL version (Ubuntu 16.04 wizh zsh 5.1.1). P9k is at v.0.6.4 on both systems. The only difference with the VM was the Windows Version - 1607 instead of 1709. The slow build also happens regardless of terminal/theme. I also don't have any other software interfering with the WSL installed. Here is a full list of all installed packages: https://pastebin.com/N27D34mw

I should mention that I tested some other ZSH themes (specifically Agnoster), and while there is some delay there too, it's not quite as bad as in P9k. My best guess is that Microsoft recently (read: last few releases) changed something in the WSL compatibility layer that slows down the vcs module (perhaps something I/O-related?). But that's just a guess.

Also, the vcs prompt builds really fast when I run Linux on the same machine, so it's definitely something Windows-related.

@lukaszog
Copy link
Author

Anyone make progress in this topic?

@williamstrong
Copy link

I have experienced this issue as well. My understanding is that I/O in WSL is known to be slow and therefore git is slow.

This issue on the WSL repo highlights the problem with git which effects the execution time of the vcs segment: microsoft/WSL#981. There is also a script which some users provided giving a temporary fix for git (use the windows executable).

This is the main issue descripting the I/O issues: microsoft/WSL#873.

I've been looking for a fix for this for awhile, but it may be that this is something that needs to be fixed in WSL.

@bhilburn
Copy link
Member

bhilburn commented Jul 9, 2018

@lukaszog, @williamstrong, et al. -

We are actually making some progress, here. The slowness does appear to be coming from a number of sources, most of which we don't have direct control over. We can, however, try to work around them in some cases.

I am about to tag a v0.6.5 release, and almost immediately following that, we are going to go to v0.7.0 (#863). The v0.7.0 codebase is completely re-written, thanks to a tremendous effort from @onaforeignshore with support from @dritter, and will allow us to use different "generators" for the segments, including asynchronous generators. This should help us keep the prompt speedy, even if something in a particular segment takes a long time to process & return a value.

@williamstrong
Copy link

Fantastic! I'm looking forward to this. Can we expect v0.7.0 today?

@bhilburn
Copy link
Member

bhilburn commented Jul 9, 2018

@williamstrong - v0.6.5 will get tagged today (hopefully!). v0.7.0 will be shortly after (in the next couple of weeks). I'll update this thread as soon as we go :)

@bhilburn
Copy link
Member

bhilburn commented Oct 8, 2018

Hey all -

v0.6.5 was tagged back in July, and v0.6.6 was tagged more recently with even more speed-ups. The v0.7.0 codebase currently exists on the next branch. If you are up for it, check out the latest next and let us know how its going!

I am going to close this issue and try to move all conversations relative to speed / performance to #732. @lukaszog, @williamstrong @ThaneDE - If you're interested in continuing to contribute to this effort, please try out next and join the discussion in #732! =)

@bhilburn bhilburn closed this as completed Oct 8, 2018
@monokal
Copy link

monokal commented Mar 7, 2019

Same issue. Unusabley laggy with stock config on the latest version.

@dnetguru
Copy link

I'm having the same issue with the stock installation using oh-my-zsh on Ubuntu running under wsl.
The stock installation works perfectly on my normal Ubuntu boxes.

@romkatv
Copy link

romkatv commented Apr 15, 2019

@dnetguru Is it also slow with Powerlevel10k?

@dnetguru
Copy link

@romkatv I hadn't try powerlevel10k and I just did and the latency is barely noticeable now!
I'm going to switch to 10k on my ubuntu boxes as well.

@mituso89
Copy link

mituso89 commented Sep 5, 2019

Anyone make progress in this topic?

@pbuzulan
Copy link

@dnetguru Is it also slow with Powerlevel10k?

Just came here because Powerlevel9k was so slow for me on macos. Instantly installed Powerlevel10k, and it's 10x faster.

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

No branches or pull requests

9 participants