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

Agnoster theme prompt extremly slow in mercurial #4116

Open
MerliX opened this Issue Jul 2, 2015 · 20 comments

Comments

Projects
None yet
8 participants
@MerliX

MerliX commented Jul 2, 2015

Code here

prompt_hg() {
runs very slow (mac yosemite)

@apjanke

This comment has been minimized.

Show comment
Hide comment
@apjanke

apjanke Jul 2, 2015

Contributor

FYI, if you're going to link to lines of code (or files for that matter) in a bug report, you should link to a specific commit, instead of "master" or another branch name. Otherwise, later commits may shift around line numbers and your link will be pointing at a different piece of code. (For example, we're about to merge a commit to agnoster that will probably shift everything down a few lines, and your link will be pointing in to the zstyle commands inside prompt_git.)

prompt_hg() {

Contributor

apjanke commented Jul 2, 2015

FYI, if you're going to link to lines of code (or files for that matter) in a bug report, you should link to a specific commit, instead of "master" or another branch name. Otherwise, later commits may shift around line numbers and your link will be pointing at a different piece of code. (For example, we're about to merge a commit to agnoster that will probably shift everything down a few lines, and your link will be pointing in to the zstyle commands inside prompt_git.)

prompt_hg() {

@MerliX

This comment has been minimized.

Show comment
Hide comment
@MerliX

MerliX Jul 3, 2015

@apjanke thanks for advice

MerliX commented Jul 3, 2015

@apjanke thanks for advice

@apjanke

This comment has been minimized.

Show comment
Hide comment
@apjanke

apjanke Jul 3, 2015

Contributor

How slow is "extremely slow" for you? This stuff is all relative. :)

I'm trying it out on OS X 10.9.5 Mavericks, on an SSD MacBook Pro. In a newly created Hg repo, it feels like it takes between half a second and a second to issue the prompt. That feels pretty slow to me. But is also not a huge surprise: this is not a very fast theme, and it's doing hg shellouts.

This could maybe be improved by consolidating the hg calls and doing parsing with native zsh string stuff afterwards. And the hg prompt test could be done once at theme load time.

Contributor

apjanke commented Jul 3, 2015

How slow is "extremely slow" for you? This stuff is all relative. :)

I'm trying it out on OS X 10.9.5 Mavericks, on an SSD MacBook Pro. In a newly created Hg repo, it feels like it takes between half a second and a second to issue the prompt. That feels pretty slow to me. But is also not a huge surprise: this is not a very fast theme, and it's doing hg shellouts.

This could maybe be improved by consolidating the hg calls and doing parsing with native zsh string stuff afterwards. And the hg prompt test could be done once at theme load time.

@apjanke

This comment has been minimized.

Show comment
Hide comment
@apjanke

apjanke Jul 3, 2015

Contributor

Oh, yeah, we can totally speed this up. Half those hg calls are unnecessary. I'll give it a try when I have some free time, maybe later today.

Contributor

apjanke commented Jul 3, 2015

Oh, yeah, we can totally speed this up. Half those hg calls are unnecessary. I'll give it a try when I have some free time, maybe later today.

@MerliX

This comment has been minimized.

Show comment
Hide comment
@MerliX

MerliX Jul 3, 2015

I did a quick fix for this, but it is not so functional. However, probably it will help

prompt_hg() {
  local rev_branch st hg_status
  rev_branch=$(hg id -n -b 2>/dev/null)

  if [ ! -z "$rev_branch" ] ; then
    st=""
    hg_status=`hg st`
    if `echo $hg_status | grep -q "^\?"`; then
      prompt_segment red black
      st='±'
    elif `echo $hg_status | grep -q "^[MA]"`; then
      prompt_segment yellow black
      st='±'
    else
      prompt_segment green black
    fi
    echo -n "☿ $rev_branch" $st
  fi
}

By the way, I switched my console to https://github.com/bhilburn/powerlevel9k witch is way more fast from-the-box

MerliX commented Jul 3, 2015

I did a quick fix for this, but it is not so functional. However, probably it will help

prompt_hg() {
  local rev_branch st hg_status
  rev_branch=$(hg id -n -b 2>/dev/null)

  if [ ! -z "$rev_branch" ] ; then
    st=""
    hg_status=`hg st`
    if `echo $hg_status | grep -q "^\?"`; then
      prompt_segment red black
      st='±'
    elif `echo $hg_status | grep -q "^[MA]"`; then
      prompt_segment yellow black
      st='±'
    else
      prompt_segment green black
    fi
    echo -n "☿ $rev_branch" $st
  fi
}

By the way, I switched my console to https://github.com/bhilburn/powerlevel9k witch is way more fast from-the-box

@apjanke

This comment has been minimized.

Show comment
Hide comment
@apjanke

apjanke Jul 3, 2015

Contributor

Thanks!

Interesting. PowerLevel9K is relying entirely on zsh's own vcs_info for the Hg stuff, instead of rolling its own. I'll look in to that and see if it's an option for us, too.

Contributor

apjanke commented Jul 3, 2015

Thanks!

Interesting. PowerLevel9K is relying entirely on zsh's own vcs_info for the Hg stuff, instead of rolling its own. I'll look in to that and see if it's an option for us, too.

@dritter

This comment has been minimized.

Show comment
Hide comment
@dritter

dritter Jul 10, 2015

Contributor

@apjanke Jep. vcs_info uses mostly hexdump to get the information from the repository and invokes mercurial only once.

Contributor

dritter commented Jul 10, 2015

@apjanke Jep. vcs_info uses mostly hexdump to get the information from the repository and invokes mercurial only once.

@apjanke

This comment has been minimized.

Show comment
Hide comment
@apjanke

apjanke Jul 11, 2015

Contributor

Oh, nice. I see some vcs_info in my future, in that case.

Contributor

apjanke commented Jul 11, 2015

Oh, nice. I see some vcs_info in my future, in that case.

@apjanke

This comment has been minimized.

Show comment
Hide comment
@apjanke

apjanke Nov 6, 2015

Contributor

Agnoster now has its own repo, https://github.com/agnoster/agnoster-zsh-theme, and is using Zsh vcs_info. Can you give the upstream theme a try and see if it's still slow for you?

Contributor

apjanke commented Nov 6, 2015

Agnoster now has its own repo, https://github.com/agnoster/agnoster-zsh-theme, and is using Zsh vcs_info. Can you give the upstream theme a try and see if it's still slow for you?

@MerliX

This comment has been minimized.

Show comment
Hide comment
@MerliX

MerliX Nov 9, 2015

Well, its not slow anymore, but it neither shows hg info in zsh prompt =) Built-in agnoster theme is still slow in hg repo. I am happy with powerlevel9k theme by the way

MerliX commented Nov 9, 2015

Well, its not slow anymore, but it neither shows hg info in zsh prompt =) Built-in agnoster theme is still slow in hg repo. I am happy with powerlevel9k theme by the way

@apjanke

This comment has been minimized.

Show comment
Hide comment
@apjanke

apjanke Nov 9, 2015

Contributor

Oh yeah, the hg support was an OMZ addition. Nevermind about asking upstream. :)

Contributor

apjanke commented Nov 9, 2015

Oh yeah, the hg support was an OMZ addition. Nevermind about asking upstream. :)

@mcornella mcornella added the mercurial label Dec 16, 2015

@Cypher1

This comment has been minimized.

Show comment
Hide comment
@Cypher1

Cypher1 Jan 24, 2017

Will this improve anytime soon? I'm having similar issues with bullettrain (which is based on agnoster).
I'm having multiple seconds of waiting time between prompt renders in a largish hg repo.

Cypher1 commented Jan 24, 2017

Will this improve anytime soon? I'm having similar issues with bullettrain (which is based on agnoster).
I'm having multiple seconds of waiting time between prompt renders in a largish hg repo.

@caugner

This comment has been minimized.

Show comment
Hide comment
@caugner

caugner Sep 14, 2017

Steps to reproduce:

hg clone https://hg.mozilla.org/mozilla-central
cd mozilla-central
time (prompt_hg > /dev/null)
# ( prompt_hg > /dev/null; )  2.77s user 1.19s system 99% cpu 3.971 total 

caugner commented Sep 14, 2017

Steps to reproduce:

hg clone https://hg.mozilla.org/mozilla-central
cd mozilla-central
time (prompt_hg > /dev/null)
# ( prompt_hg > /dev/null; )  2.77s user 1.19s system 99% cpu 3.971 total 
@caugner

This comment has been minimized.

Show comment
Hide comment
@caugner

caugner Sep 14, 2017

The lag stems from the three calls to hg id on lines 155 and 172/173 and hg st on line 174/177:

hg clone https://hg.mozilla.org/mozilla-central
cd mozilla-central

time hg id
# hg id  0.66s user 0.35s system 99% cpu 1.020 total

time hg id -n
# hg id -n  0.65s user 0.38s system 99% cpu 1.032 total

time hg id -b
# hg id -b  0.08s user 0.03s system 99% cpu 0.117 total

time hg st
# hg st  1.32s user 0.41s system 99% cpu 1.733 total

caugner commented Sep 14, 2017

The lag stems from the three calls to hg id on lines 155 and 172/173 and hg st on line 174/177:

hg clone https://hg.mozilla.org/mozilla-central
cd mozilla-central

time hg id
# hg id  0.66s user 0.35s system 99% cpu 1.020 total

time hg id -n
# hg id -n  0.65s user 0.38s system 99% cpu 1.032 total

time hg id -b
# hg id -b  0.08s user 0.03s system 99% cpu 0.117 total

time hg st
# hg st  1.32s user 0.41s system 99% cpu 1.733 total
@caugner

This comment has been minimized.

Show comment
Hide comment
@caugner

caugner Sep 14, 2017

In theory, there is some potential:

hg clone https://hg.mozilla.org/mozilla-central
cd mozilla-central
  1. Replace hg id with hg root:
# hg id  0.70s user 0.40s system 99% cpu 1.103 total
# hg root  0.10s user 0.04s system 99% cpu 0.137 total
  1. Replace double hg st with single ( hg st -uma | cut -c -1 | sort | uniq | paste -d, -s; )
# hg st  1.29s user 0.43s system 16% cpu 10.316 total
# ( hg st -uma | cut -c -1 | sort | uniq | paste -d, -s; )  1.36s user 0.42s system 101% cpu 1.758 total
  1. Replace hg id -n and hg id -b with single hg id -nb
# hg id -n  0.69s user 0.39s system 99% cpu 1.076 total
# hg id -b  0.10s user 0.03s system 99% cpu 0.124 total
# hg id -nb  0.66s user 0.39s system 99% cpu 1.057 total

In practice, this does improve the situation only slightly:

# Before
# ( prompt_hg > /dev/null; )  2.86s user 1.27s system 99% cpu 4.138 total
# After
# ( prompt_hg > /dev/null; )  2.17s user 0.87s system 100% cpu 3.024 total

caugner commented Sep 14, 2017

In theory, there is some potential:

hg clone https://hg.mozilla.org/mozilla-central
cd mozilla-central
  1. Replace hg id with hg root:
# hg id  0.70s user 0.40s system 99% cpu 1.103 total
# hg root  0.10s user 0.04s system 99% cpu 0.137 total
  1. Replace double hg st with single ( hg st -uma | cut -c -1 | sort | uniq | paste -d, -s; )
# hg st  1.29s user 0.43s system 16% cpu 10.316 total
# ( hg st -uma | cut -c -1 | sort | uniq | paste -d, -s; )  1.36s user 0.42s system 101% cpu 1.758 total
  1. Replace hg id -n and hg id -b with single hg id -nb
# hg id -n  0.69s user 0.39s system 99% cpu 1.076 total
# hg id -b  0.10s user 0.03s system 99% cpu 0.124 total
# hg id -nb  0.66s user 0.39s system 99% cpu 1.057 total

In practice, this does improve the situation only slightly:

# Before
# ( prompt_hg > /dev/null; )  2.86s user 1.27s system 99% cpu 4.138 total
# After
# ( prompt_hg > /dev/null; )  2.17s user 0.87s system 100% cpu 3.024 total
@maelvalais

This comment has been minimized.

Show comment
Hide comment
@maelvalais

maelvalais Jan 4, 2018

Wow, using chg instead of hg (just put alias hg=chg in your .zshrc) seems to make prompt_hg as fast as the git prompt!

Any drawbacks? I guess it is only available on the latest hg versions?

Update: I realized that a ~12MB Python process has to be kept running in background (but I guess I don't mind)

maelvalais commented Jan 4, 2018

Wow, using chg instead of hg (just put alias hg=chg in your .zshrc) seems to make prompt_hg as fast as the git prompt!

Any drawbacks? I guess it is only available on the latest hg versions?

Update: I realized that a ~12MB Python process has to be kept running in background (but I guess I don't mind)

@caugner

This comment has been minimized.

Show comment
Hide comment
@caugner

caugner Apr 25, 2018

I guess it is only available on the latest hg versions?

@maelvalais What version of hg do you run? Unfortunately, chg is not available for me in Mercurial 4.3.2.

caugner commented Apr 25, 2018

I guess it is only available on the latest hg versions?

@maelvalais What version of hg do you run? Unfortunately, chg is not available for me in Mercurial 4.3.2.

@sylvestre

This comment has been minimized.

Show comment
Hide comment
@sylvestre

sylvestre Sep 5, 2018

Looks like it is https://www.mercurial-scm.org/wiki/CHg (afaik, not shipped with mercurial)
And indeed, the mercurial extension isn't usable on large repo like Firefox...

sylvestre commented Sep 5, 2018

Looks like it is https://www.mercurial-scm.org/wiki/CHg (afaik, not shipped with mercurial)
And indeed, the mercurial extension isn't usable on large repo like Firefox...

@maelvalais

This comment has been minimized.

Show comment
Hide comment
@maelvalais

maelvalais Sep 5, 2018

Ahh... I just noticed that this chg is in contrib/ and thus probably not compiled/installed by default by standard package managers. The reason I have it is that Homebrew installs chg by default (see formula).

Unfortunate that it is not shipped by default...

maelvalais commented Sep 5, 2018

Ahh... I just noticed that this chg is in contrib/ and thus probably not compiled/installed by default by standard package managers. The reason I have it is that Homebrew installs chg by default (see formula).

Unfortunate that it is not shipped by default...

@caugner

This comment has been minimized.

Show comment
Hide comment
@caugner

caugner Sep 6, 2018

I have disabled the status in mercurial repositories now by adding functions[prompt_hg]="" to my .zshrc.

caugner commented Sep 6, 2018

I have disabled the status in mercurial repositories now by adding functions[prompt_hg]="" to my .zshrc.

jonas-schulze added a commit to jonas-schulze/dotfiles that referenced this issue Oct 15, 2018

Change theme to powerlevel9k
The agnoster theme still seems to be really slow in Mercurial repos.
I tried the custom repo of anoster, which out of the box was no better.
So let's give powerlevel9k a try.

robbyrussell/oh-my-zsh#4116
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment