Powerlevel9k / powerlevel9k

Powerlevel9k was a tool for building a beautiful and highly functional CLI, customized for you. P9k had a substantial impact on CLI UX, and its legacy is now continued by P10k.
https://github.com/romkatv/powerlevel10k
MIT License
13.46k stars 946 forks source link

Showing prompt is very slow #374

Closed tweety3d closed 7 years ago

tweety3d commented 7 years ago

Hi, I noticed that showing prompt is very slow, takes 0,5 to 1 second, meaning that after each command there is almost one second gap. The easiest way to see it is press ENTER and hold, you'll see prompts not appearing immediately and them appearing one at a time. Can't imagine what takes so much time there... It's very sad, because this theme looks very nice and has nice features. I'm using Prezto version.

Tritlo commented 7 years ago

Is your home directory tracked in Git? If so, the cause is very probably the VCS segment slowing things down. You can try turning that off, and see if it improves the performance.

We are currently working on an async implementation, and it should be ready soon.

tweety3d commented 7 years ago

It's not, it runs that slow in my untracked home dir. In any git dir it runs even slower.

Tritlo commented 7 years ago

What segments are you using?

tweety3d commented 7 years ago

Having only context dir and time is working fine 95% of times (once a while it doesn't finish empty command before it gets next ENTER), but it's still fine. Adding vsc just kills it.

dritter commented 7 years ago

This may have various causes:

  1. Big repository Obviously, on big repositories, git cannot be super fast.

  2. Many untracked files This is a flaw in git. If you have a lot of untracked files it gets slow, because git computes (compares them against .gitignore) a list of all these files and gives us the whole list..

  3. Old git version The git guys have done a lot of performance tweaking. So, you should upgrade your git, if you use an old version. This is for instance the case if you use a standard OSX. The shipped version of git is quite old. In that case you should consider installing git with a package manager (like homebrew.

  4. Slow HDD At last, it boils down to raw I/O performance. The VCS segment does a lot of filesystem lookups. As @Tritlo said, we are working on rendering the segments asynchronously. You can see if that brings remedy. The PR is #344

I hope that at least one of that helps.

tweety3d commented 7 years ago

But, as I mentioned earlier, it happens when not in git repository. Just in my home folder or any folder for that matter. And I have SSD so hard to make it faster :)

dritter commented 7 years ago

Okay. Could you post the output of git --version anyway?

And is the prompt more usable in another directory that is not within your home folder (like /tmp)?

And how fast is it if you disable the vcs segment?

tweety3d commented 7 years ago

git version 2.11.0.390.gc69c2f50cf-goog

With vcs segment, my "hold enter test" in tmp:

/tmp                                                                                                                                      13:55 

 /tmp                                                                                                                                      13:55 

 /tmp                                                                                                                                      13:55 

 /tmp                                                                                                                                      13:55 
 /tmp                                                                                                                                      13:55 

meaning it gets 2-3 'enter' keys before it renders prompt.

And in git repo:

~/repos/code1   basee | merge                                                                                                       13:56 

 ~/repos/code1   basee | merge                                                                                                       13:56 

 ~/repos/code1   basee | merge                                                                                                       13:56 

meaning, it gets 8 'enter' keys before it renders prompt.

Removing vcs segment makes it much faster, 95% of time rendering prompt on time.

Unfortunately, after checking out zsh-async-integration zsh won't start at all. No errors, just hangs I guess.

dritter commented 7 years ago

Well. I don't think we can do anything about that (except for more profiling, and disabling hooks one by one). The vcs segment is quite heavyweight. That is one of the main reasons why we started implementing the segments asynchronously.

Btw. the zsh-async-integration branch is not the one I meant. The right one is not a branch, but a fork on my side (you can find the code here: https://github.com/dritter/powerlevel9k/tree/async_all_the_segments). Try that one, and let us know if that is fast enough.

jshort commented 7 years ago

I got powerlevel9k setup yesterday and in the early stages it seemed just as fast to render as, say agnoster, but as I started configuring it, it became very slow.

After some iteration this morning, I found that the battery segment is the culprit fwiw. Is there anything that can be done to speed that segment up? Maybe only checking level modulo 5 minutes or 5 prompts or something?

rjorgenson commented 7 years ago

@jshort hmmm, what operating system are you on? I just tested my prompt with and without the battery segment and couldn't notice any difference on OS X. The battery segment doesn't really do anything system intensive, just read some values and simple math. I'm on next branch right now which has a new method of getting battery information on OS X but in my tests the new method wasn't any faster than the old version, just a bit cleaner.

jshort commented 7 years ago

OSX El Capitan. Link to the git commit you are on please?

Is this it?

https://github.com/bhilburn/powerlevel9k/commit/16283fc8ee5c2f249723ed185abe70a111e479ca

rjorgenson commented 7 years ago

@jshort yes those are the changes that I'm using, but I'm actually on commit c5909e7 which has a few other non-related changes. But I didn't notice any speed difference between pre 16283fc and post 16283fc

jshort commented 7 years ago

On the HEAD of branch next, the battery indicator (and my prompt in general) renders very fast.

@tweety3d Can you try the next branch to see if that speeds things up for you?

Granted the battery segment does not turn red below 10% on the next branch.

jshort commented 7 years ago

@rjorgenson

See https://github.com/bhilburn/powerlevel9k/pull/376

bhilburn commented 7 years ago

@tweety3d - I just merged @jshort's fix in #376. Can you check out the HEAD of next and let us know if it helps?

tweety3d commented 7 years ago

Hi, I've checkout out newest next and still the same lag...

bhilburn commented 7 years ago

Okay, so the battery segment changes fixed @jshort's problems, but not @tweety3d's. It sounds like @tweety3d's issues are indeed vcs related, but it's very strange that it's happening even outside of a git directory. git-2.11 is the latest version, so this isn't an "ancient version" problem, either.

@dritter's async branch would be the ideal solution. @tweety3d it sounds like you tried the zsh-async-integration branch, but what we actually want you to try is this fork: https://github.com/dritter/powerlevel9k/tree/async_all_the_segments

Go into your powerlevel9k.git directory, and:

git remote add dritter https://github.com/dritter/powerlevel9k.git
git remote update -p
git checkout -b async -t dritter/async_all_the_segments

Then restart your terminal and let us know how it goes!

davidawad commented 7 years ago

Trying the fork for myself after reading this it is a little faster, I should also add that if you have a lot of extra directories in your $PATH variable it can slow down loading the prompt.

Take a look in your bashrc and zshrc and see if anything there is adding a lot to the $PATH variable.

You can also check it with echo $PATH

tweety3d commented 7 years ago

Wow! So much better! In /tmp it's successful 95% of time, while in git directory it doesn't display git part in 40% of time, but still new prompt appears immediately, which is great. Thanks, I'm hoping you can merge that branch soon :)

The only thing, sometimes when I hold ENTER in git directory some errors appear: serialize_segment:84: no such file or directory: /tmp/p9k/p9k_14971_left_003_prompt_vcs.sh

To add to this, when in git repository it takes about one second for the git segment to appear, but the prompt is ready and I'm able to type during this second.

But I wonder, what takes one second there? Executing 'git branch' or 'git log' takes no-time, so even parsing that text and displaying segment should also take up to 1 ms I would say...

bhilburn commented 7 years ago

@DavidAwad - Great advice!

@tweety3d - So glad you like @dritter's work on the async stuff! He is putting a lot of time & effort into it, and we are really excited to get it merged once it's ready =)

Thanks for trying out the branch and providing feedback! I'm going to close this bug since we are already tracking the async stuff on a number of other branches. If as you are using the branch, @tweety3d, you see issues, can you open new bugs and specifically mention 'async' in the title? That will make it easier for us to follow the discussion!

ijoseph commented 6 years ago

I should also add that if you have a lot of extra directories in your $PATH variable it can slow down loading the prompt.

@davidawad , what counts as "a lot"? I have 13.

Also, on the practical side typeset -aU path on the end of .zshrc gets rid of duplicate $PATH entries.

ijoseph commented 6 years ago

Unfortunately, #344 dritter/async_all_the_segments fork did not solve my slow rendering issues.

WaqqasI commented 5 years ago

@bhilburn I'm trying the async branch with your code in ~/.oh-my-zsh/custom/themes/powerlevel9k and it seems to have broken everything. Every time I run a command it's throwing all of this

touch: cannot touch '/home/light/.cache/powerlevel9k/p9k_5_dummy': No such file or directory
build_left_prompt:16: nice(5) failed: operation not permitted
build_left_prompt:16: nice(5) failed: operation not permitted
build_left_prompt:16: nice(5) failed: operation not permitted
serialize_segment:88: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_002_prompt_conte                                                   xt.sh
build_left_prompt:16: nice(5) failed: operation not permitted
serialize_segment:88: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_001_prompt_os_ic                                                   on.sh
serialize_segment:89: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_002_prompt_conte                                                   xt.sh
build_left_prompt:11: nice(5) failed: operation not permitted
serialize_segment:89: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_001_prompt_os_ic                                                   on.sh
serialize_segment:90: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_002_prompt_conte                                                   xt.sh
build_left_prompt:16: nice(5) failed: operation not permitted
serialize_segment:90: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_001_prompt_os_ic                                                   on.sh
build_left_prompt:16: nice(5) failed: operation not permitted
serialize_segment:91: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_002_prompt_conte                                                   xt.sh
build_left_prompt:16: nice(5) failed: operation not permitted
build_left_prompt:16: nice(5) failed: operation not permitted
serialize_segment:88: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_005_prompt_custo                                                   m.sh
serialize_segment:91: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_001_prompt_os_ic                                                   on.sh
serialize_segment:88: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_003_prompt_dir.s                                                   h
build_right_prompt:13: nice(5) failed: operation not permitted
serialize_segment:92: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_002_prompt_conte                                                   xt.sh
serialize_segment:88: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_006_prompt_comma                                                   nd_execution_time.sh
build_right_prompt:13: nice(5) failed: operation not permitted
build_right_prompt:13: nice(5) failed: operation not permitted
build_right_prompt:13: nice(5) failed: operation not permitted
serialize_segment:89: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_005_prompt_custo                                                   m.sh
serialize_segment:92: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_001_prompt_os_ic                                                   on.sh
build_right_prompt:13: nice(5) failed: operation not permitted
serialize_segment:89: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_003_prompt_dir.s                                                   h
build_right_prompt:13: nice(5) failed: operation not permitted
serialize_segment:93: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_002_prompt_conte                                                   xt.sh
build_right_prompt:13: nice(5) failed: operation not permitted
serialize_segment:89: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_006_prompt_comma                                                   nd_execution_time.sh
serialize_segment:88: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_007_prompt_disk_                                                   usage.sh
serialize_segment:88: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_001_prompt_stat                                                   us.sh
serialize_segment:90: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_005_prompt_custo                                                   m.sh
serialize_segment:93: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_001_prompt_os_ic                                                   on.sh
serialize_segment:88: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_003_prompt_root                                                   _indicator.sh
serialize_segment:88: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_002_prompt_dir_                                                   writable.sh
serialize_segment:88: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_008_prompt_load.                                                   sh
serialize_segment:88: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_005_prompt_hist                                                   ory.sh
serialize_segment:90: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_003_prompt_dir.s                                                   h
serialize_segment:88: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_006_prompt_time                                                   .sh
serialize_segment:94: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_002_prompt_conte                                                   xt.sh
serialize_segment:89: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_001_prompt_stat                                                   us.sh
serialize_segment:89: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_003_prompt_root                                                   _indicator.sh
serialize_segment:89: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_002_prompt_dir_                                                   writable.sh
serialize_segment:89: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_007_prompt_disk_                                                   usage.sh
serialize_segment:89: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_008_prompt_load.                                                   sh

╭─
╰─ serialize_segment:91: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_003_prompt_di                                                   r.sh
serialize_segment:91: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_005_prompt_custo                                                   m.sh
serialize_segment:90: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_002_prompt_dir_                                                   writable.sh
serialize_segment:94: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_001_prompt_os_ic                                                   on.sh
serialize_segment:90: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_007_prompt_disk_                                                   usage.sh
serialize_segment:90: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_008_prompt_load.                                                   sh
serialize_segment:92: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_003_prompt_dir.s                                                   h
serialize_segment:92: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_005_prompt_custo                                                   m.sh
serialize_segment:89: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_005_prompt_hist                                                   ory.sh
serialize_segment:90: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_006_prompt_comma                                                   nd_execution_time.sh
serialize_segment:89: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_006_prompt_time                                                   .sh
serialize_segment:95: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_002_prompt_conte                                                   xt.sh
serialize_segment:90: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_001_prompt_stat                                                   us.sh
serialize_segment:90: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_003_prompt_root                                                   _indicator.sh
serialize_segment:91: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_002_prompt_dir_                                                   writable.sh
serialize_segment:95: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_001_prompt_os_ic                                                   on.sh
serialize_segment:91: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_007_prompt_disk_                                                   usage.sh
serialize_segment:91: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_008_prompt_load.                                                   sh
serialize_segment:88: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_004_prompt_back                                                   ground_jobs.sh
serialize_segment:93: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_003_prompt_dir.s                                                   h
serialize_segment:93: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_005_prompt_custo                                                   m.sh
serialize_segment:90: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_005_prompt_hist                                                   ory.sh
serialize_segment:91: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_006_prompt_comma                                                   nd_execution_time.sh
serialize_segment:90: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_006_prompt_time                                                   .sh
serialize_segment:96: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_002_prompt_conte                                                   xt.sh
serialize_segment:91: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_001_prompt_stat                                                   us.sh
serialize_segment:91: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_003_prompt_root                                                   _indicator.sh
serialize_segment:92: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_002_prompt_dir_                                                   writable.sh
serialize_segment:96: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_001_prompt_os_ic                                                   on.sh
serialize_segment:92: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_007_prompt_disk_                                                   usage.sh
serialize_segment:92: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_008_prompt_load.                                                   sh
serialize_segment:89: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_004_prompt_back                                                   ground_jobs.sh
serialize_segment:94: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_003_prompt_dir.s                                                   h
serialize_segment:94: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_005_prompt_custo                                                   m.sh
serialize_segment:91: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_005_prompt_hist                                                   ory.sh
serialize_segment:92: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_006_prompt_comma                                                   nd_execution_time.sh
serialize_segment:91: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_006_prompt_time                                                   .sh
serialize_segment:97: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_002_prompt_conte                                                   xt.sh
serialize_segment:92: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_001_prompt_stat                                                   us.sh
serialize_segment:92: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_003_prompt_root                                                   _indicator.sh
serialize_segment:93: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_002_prompt_dir_                                                   writable.sh
serialize_segment:97: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_001_prompt_os_ic                                                   on.sh
serialize_segment:93: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_007_prompt_disk_                                                   usage.sh
serialize_segment:93: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_008_prompt_load.                                                   sh
serialize_segment:90: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_004_prompt_back                                                   ground_jobs.sh
serialize_segment:95: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_003_prompt_dir.s                                                   h
serialize_segment:95: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_005_prompt_custo                                                   m.sh
serialize_segment:92: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_005_prompt_hist                                                   ory.sh
serialize_segment:93: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_006_prompt_comma                                                   nd_execution_time.sh
serialize_segment:92: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_006_prompt_time                                                   .sh
serialize_segment:98: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_002_prompt_conte                                                   xt.sh
serialize_segment:93: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_001_prompt_stat                                                   us.sh
serialize_segment:93: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_003_prompt_root                                                   _indicator.sh
serialize_segment:94: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_002_prompt_dir_                                                   writable.sh
serialize_segment:98: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_001_prompt_os_ic                                                   on.sh
serialize_segment:94: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_007_prompt_disk_                                                   usage.sh
serialize_segment:94: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_008_prompt_load.                                                   sh
serialize_segment:91: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_004_prompt_back                                                   ground_jobs.sh
serialize_segment:96: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_003_prompt_dir.s                                                   h
serialize_segment:96: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_005_prompt_custo                                                   m.sh
serialize_segment:93: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_005_prompt_hist                                                   ory.sh
serialize_segment:94: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_006_prompt_comma                                                   nd_execution_time.sh
serialize_segment:93: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_006_prompt_time                                                   .sh
serialize_segment:94: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_001_prompt_stat                                                   us.sh
serialize_segment:94: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_003_prompt_root                                                   _indicator.sh
serialize_segment:95: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_002_prompt_dir_                                                   writable.sh
serialize_segment:95: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_007_prompt_disk_                                                   usage.sh
serialize_segment:95: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_008_prompt_load.                                                   sh
serialize_segment:92: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_004_prompt_back                                                   ground_jobs.sh
serialize_segment:97: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_003_prompt_dir.s                                                   h
serialize_segment:97: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_005_prompt_custo                                                   m.sh
serialize_segment:94: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_005_prompt_hist                                                   ory.sh
serialize_segment:95: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_006_prompt_comma                                                   nd_execution_time.sh
serialize_segment:94: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_006_prompt_time                                                   .sh
serialize_segment:95: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_001_prompt_stat                                                   us.sh
serialize_segment:95: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_003_prompt_root                                                   _indicator.sh
serialize_segment:96: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_002_prompt_dir_                                                   writable.sh
serialize_segment:96: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_007_prompt_disk_                                                   usage.sh
serialize_segment:96: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_008_prompt_load.                                                   sh
serialize_segment:93: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_004_prompt_back                                                   ground_jobs.sh
serialize_segment:98: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_003_prompt_dir.s                                                   h
serialize_segment:98: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_005_prompt_custo                                                   m.sh
serialize_segment:95: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_005_prompt_hist                                                   ory.sh
serialize_segment:96: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_006_prompt_comma                                                   nd_execution_time.sh
serialize_segment:95: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_006_prompt_time                                                   .sh
serialize_segment:96: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_001_prompt_stat                                                   us.sh

╭─
╰─ serialize_segment:97: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_007_prompt_di                                                   sk_usage.sh
serialize_segment:97: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_002_prompt_dir_                                                   writable.sh
serialize_segment:94: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_004_prompt_back                                                   ground_jobs.sh
serialize_segment:97: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_008_prompt_load.                                                   sh
serialize_segment:96: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_005_prompt_hist                                                   ory.sh
serialize_segment:97: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_006_prompt_comma                                                   nd_execution_time.sh
serialize_segment:96: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_006_prompt_time                                                   .sh
serialize_segment:97: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_001_prompt_stat                                                   us.sh
serialize_segment:97: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_003_prompt_root                                                   _indicator.sh
serialize_segment:98: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_007_prompt_disk_                                                   usage.sh
serialize_segment:98: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_002_prompt_dir_                                                   writable.sh
serialize_segment:95: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_004_prompt_back                                                   ground_jobs.sh
serialize_segment:98: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_008_prompt_load.                                                   sh
serialize_segment:97: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_005_prompt_hist                                                   ory.sh
serialize_segment:98: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_006_prompt_comma                                                   nd_execution_time.sh
serialize_segment:97: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_006_prompt_time                                                   .sh
serialize_segment:98: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_001_prompt_stat                                                   us.sh
serialize_segment:98: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_003_prompt_root                                                   _indicator.sh
serialize_segment:96: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_004_prompt_back                                                   ground_jobs.sh
serialize_segment:98: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_005_prompt_hist                                                   ory.sh
serialize_segment:98: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_006_prompt_time                                                   .sh
serialize_segment:97: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_right_004_prompt_back                                                   ground_jobs.sh

╭─
╰─ serialize_segment:88: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_009_prompt_vc                                                   s.sh
serialize_segment:89: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_009_prompt_vcs.s                                                   h
serialize_segment:90: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_009_prompt_vcs.s                                                   h
serialize_segment:91: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_009_prompt_vcs.s                                                   h
serialize_segment:92: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_009_prompt_vcs.s                                                   h
serialize_segment:93: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_009_prompt_vcs.s                                                   h
serialize_segment:94: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_009_prompt_vcs.s                                                   h
serialize_segment:95: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_009_prompt_vcs.s                                                   h
serialize_segment:96: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_009_prompt_vcs.s                                                   h
serialize_segment:97: no such file or directory: /home/light/.cache/powerlevel9k/p9k_5_left_009_prompt_vcs.s                                                   h

By the way, I'm using WSL.

NOTE: It does slightly work when I do sudo -s but the order and layout of my segments are broken, with no newline and date. Without sudo -s, it doesn't work at all

dritter commented 5 years ago

@ijoseph @LightningsFury #344 turned out to be a dead end - unfortunately. Our current development branch is next, where we did some great speed improvements. Could you try out this branch, and tell us your experience?

ijoseph commented 5 years ago

@dritter Will do within the week, and check back. Thanks for checking in.

ijoseph commented 5 years ago

Quite an improvement. From about 0.5 seconds to render the prompt each time, down to about 0.1 seconds (on non-git directories). Happily, crossed the threshold of usability from unusuable to usable.

dritter commented 5 years ago

Awesome @ijoseph

ijoseph commented 5 years ago

@dritter I've actually been putting in quite a bit of effort to figure out why my prompt renders so slowly. Confoundingly, on my work MacBook, it (used to be) significantly slower than my home MacBook (0.5 seconds versus 0.1 seconds).

After changing to the next branch, long story short, is that the command (function?) +vi-git-untracked seems to be taking the Lion's Share of the rendering time.

Long story longer but not fully-extended: this notebook where I was messing around with the xtrace result and by which I came to the above conclusion. The code profiled by the above is print -P $PS1 $RPS1.

ijoseph commented 5 years ago

Actually, hold that thought. This may not have been a fair comparison as I may have added git tracking to the directory in question, thus leading to the additional time spent by git post-next branch changing.

dritter commented 5 years ago

Is this repo a big one? In #1046 I've written down some scenarios and some simple measurements. Could you quantify your repo on that terms?

ijoseph commented 5 years ago
time (repeat 10; do; command git status --porcelain >/dev/null; done;)
( repeat 10; do; command git status --porcelain > /dev/null; done; )  0.03s user 0.04s system 58% cpu 0.114 total

time (repeat 10; do; command git ls-files --others --exclude-standard >/dev/null || command git submodule foreach --quiet --recursive 'git ls-files --others --exclude-standard' >/dev/null; d\
one;)
( repeat 10; do; command git ls-files --others --exclude-standard > /dev/null)  0.02s user 0.02s system 62% cpu 0.070 total

time (repeat 10; do; prompt_vcs left 1 false >/dev/null; done;)
( repeat 10; do; prompt_vcs left 1 false > /dev/null; done; )  0.67s user 0.78s system 71% cpu 2.034 total

time (repeat 10; do; prompt_vcs left 1 false >/dev/null; done;)
( repeat 10; do; prompt_vcs left 1 false > /dev/null; done; )  0.78s user 0.90s system 70% cpu 2.364 total
ijoseph commented 5 years ago

In short, it's not a big repo. Furthermore, after switching to the next branch, the rendering time on this repo is livable, if not ideal. About 0.5 seconds.

ijoseph commented 5 years ago

I did the profiling again, this time definitely not on a version-controlled directory (/tmp). See the bottom of the updated notebook. Still, +vi-git-untracked is the most time-consuming command, it seems like.

dritter commented 5 years ago

That duration is in seconds? Tbh, I am not sure how to interpret these graphs. Two things are odd about +vi-git-untracked:

ijoseph commented 5 years ago

Duration is in microseconds. I think my previous analysis was erroneous, though, although I've now reached a similar conclusion: vcs_info is taking most of the time. So if my profiling code is working, it's saying that vcs_info takes about 0.05 seconds. Not terrible, I guess.

Sorry for confusion -- didn't expect to be showing it to anyone else, and I haven't had time to clean it up for that purpose.

Thanks for the update. Makes sense regarding why that function should not be called.

dritter commented 5 years ago

Thanks for clearing that up. And no need to apology. I think these graphs are awesome. Maybe it would be possible to extend them to a more generic point. I wish we had some kind of performance testing within travis. But this seems to be impossible.

About vcs_comm[gitdir] is set by vcs_info.

romkatv commented 5 years ago

I implemented a custom binary in C (using libgit2) that prints everything relevant about the current git repo in an easy-to-parse form. It's about 40% faster than a single git status call and an order of magnitude faster than vcs_info, which makes a dozen git calls. I also integrated it with Powerlevel9k. If you want to try it in your current shell without any permanent changes, copy-paste the command from https://github.com/bhilburn/powerlevel9k/issues/1170#issuecomment-467977064 and see if your prompt becomes more responsive.

gshanbhag525 commented 4 years ago

There is powerlevel10k now. It's 10 times faster than powerlevel9k and backward-compatible with its configs. You can switch theme without changing any of your POWERLEVEL9K options to keep the same prompt you are used to while making it blazingly fast.

First, clone powerlevel10k. git clone https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k

gshanbhag525 commented 4 years ago

There is powerlevel10k now. It's 10 times faster than powerlevel9k and backward-compatible with its configs. You can switch theme without changing any of your POWERLEVEL9K options to keep the same prompt you are used to while making it blazingly fast.

First, clone powerlevel10k. git clone https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k

Then set ZSH_THEME=powerlevel10k/powerlevel10k in your ~/.zshrc and restart zsh.

SimonSelg commented 4 years ago

@gshanbhag525 thank you so much for bringing this to my attention.