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

Showing prompt is very slow #374

Closed
tweety3d opened this Issue Jan 10, 2017 · 23 comments

Comments

Projects
None yet
8 participants
@tweety3d

tweety3d commented Jan 10, 2017

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

This comment has been minimized.

Show comment
Hide comment
@Tritlo

Tritlo Jan 10, 2017

Collaborator

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.

Collaborator

Tritlo commented Jan 10, 2017

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

This comment has been minimized.

Show comment
Hide comment
@tweety3d

tweety3d Jan 10, 2017

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

tweety3d commented Jan 10, 2017

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

@Tritlo

This comment has been minimized.

Show comment
Hide comment
@Tritlo

Tritlo Jan 10, 2017

Collaborator

What segments are you using?

Collaborator

Tritlo commented Jan 10, 2017

What segments are you using?

@tweety3d

This comment has been minimized.

Show comment
Hide comment
@tweety3d

tweety3d Jan 10, 2017

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.

tweety3d commented Jan 10, 2017

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

This comment has been minimized.

Show comment
Hide comment
@dritter

dritter Jan 10, 2017

Collaborator

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.

Collaborator

dritter commented Jan 10, 2017

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

This comment has been minimized.

Show comment
Hide comment
@tweety3d

tweety3d Jan 11, 2017

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 :)

tweety3d commented Jan 11, 2017

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

This comment has been minimized.

Show comment
Hide comment
@dritter

dritter Jan 12, 2017

Collaborator

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?

Collaborator

dritter commented Jan 12, 2017

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

This comment has been minimized.

Show comment
Hide comment
@tweety3d

tweety3d Jan 12, 2017

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.

tweety3d commented Jan 12, 2017

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

This comment has been minimized.

Show comment
Hide comment
@dritter

dritter Jan 12, 2017

Collaborator

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.

Collaborator

dritter commented Jan 12, 2017

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

This comment has been minimized.

Show comment
Hide comment
@jshort

jshort Jan 18, 2017

Contributor

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?

Contributor

jshort commented Jan 18, 2017

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

This comment has been minimized.

Show comment
Hide comment
@rjorgenson

rjorgenson Jan 18, 2017

Collaborator

@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.

Collaborator

rjorgenson commented Jan 18, 2017

@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

This comment has been minimized.

Show comment
Hide comment
@jshort

jshort Jan 18, 2017

Contributor

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

Is this it?

16283fc

Contributor

jshort commented Jan 18, 2017

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

Is this it?

16283fc

@rjorgenson

This comment has been minimized.

Show comment
Hide comment
@rjorgenson

rjorgenson Jan 18, 2017

Collaborator

@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

Collaborator

rjorgenson commented Jan 18, 2017

@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

This comment has been minimized.

Show comment
Hide comment
@jshort

jshort Jan 18, 2017

Contributor

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.

Contributor

jshort commented Jan 18, 2017

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

This comment has been minimized.

Show comment
Hide comment
@jshort
Contributor

jshort commented Jan 18, 2017

@bhilburn

This comment has been minimized.

Show comment
Hide comment
@bhilburn

bhilburn Jan 21, 2017

Owner

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

Owner

bhilburn commented Jan 21, 2017

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

@bhilburn bhilburn self-assigned this Jan 21, 2017

@tweety3d

This comment has been minimized.

Show comment
Hide comment
@tweety3d

tweety3d Jan 23, 2017

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

tweety3d commented Jan 23, 2017

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

@bhilburn

This comment has been minimized.

Show comment
Hide comment
@bhilburn

bhilburn Jan 23, 2017

Owner

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!

Owner

bhilburn commented Jan 23, 2017

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

This comment has been minimized.

Show comment
Hide comment
@davidawad

davidawad Jan 23, 2017

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

davidawad commented Jan 23, 2017

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

This comment has been minimized.

Show comment
Hide comment
@tweety3d

tweety3d Jan 24, 2017

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...

tweety3d commented Jan 24, 2017

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

This comment has been minimized.

Show comment
Hide comment
@bhilburn

bhilburn Feb 14, 2017

Owner

@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!

Owner

bhilburn commented Feb 14, 2017

@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

This comment has been minimized.

Show comment
Hide comment
@ijoseph

ijoseph Aug 30, 2018

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 Aug 30, 2018

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

This comment has been minimized.

Show comment
Hide comment
@ijoseph

ijoseph Aug 30, 2018

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

ijoseph commented Aug 30, 2018

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

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