Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Is it worthwhile to use oh-my-zsh?





I've tried various VCS prompts out and my favourite so far is https://github.com/woefe/git-prompt.zsh which is fast and also asynchronous.

Nick



On 08/09/2019 16:41, Roman Perepelitsa wrote:
On Sun, Sep 8, 2019 at 2:33 AM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:

On Sat, Sep 7, 2019 at 1:19 PM Frank Terbeck <ft@xxxxxxxxxxxxxxxxxxx> wrote:

Roman Perepelitsa wrote:
Note that vcs_info is likely to make your prompt noticeably sluggish.

Depends on configuration. The defaults avoid most features that are
particularly expensive.

I've been using the following lately ... note that I am pathologically
allergic to "setopt prompt_subst":

...

I ran a few benchmarks to measure prompt latency induced by vcs_info
with conservative settings. By prompt latency I mean the time it takes
for prompt to appear after you hit ENTER. I've measured 3
configurations:

- bart: plain bart theme.
- bart + vcs_info: the config posted by Bart on this thread.
- bart + gitstatus: functionally equivalent to bart + vcs_info but
using gitstatus instead of vcs_info [1].

Prompt latency in zsh Git repo on a high-end desktop running Linux:

- bart: 0.28ms
- bart + vcs_info: 28ms
- bart + gitstatus: 0.81ms

The slowdown from vcs_info is significant but the overall prompt
latency is still reasonably low. If you pay attention, you can notice
the lag but it's not jarring. Most people start being annoyed by
prompt lag when it reaches around 50ms.

The same machine running WSL:

- bart: 2.1ms
- bart + vcs_info: 87ms
- bart + gitstatus: 4.9ms

Here the lag induced by vcs_info cannot be ignored. Local shell feels
like SSH across the continent. bart + gitstatus stays far below the
perceptible lag threshold and feels instant.

A typical laptop running Linux or macOS falls somewhere in between my
two benchmark setups, with slower macbooks being close in performance
to WSL on my desktop.

To sum up, vcs_info with conservative settings adds enough prompt
latency to make it perceptible without any instruments. Whether it
makes prompt lag annoyingly high depends on the OS and hardware.

Interactive ZSH has a reputation for being slow primarily due to slow
themes, which are in turn slow primarily due to suboptimal Git
integration. The difference in performance between fast and slow ZSH
bindings for Git is over an order of magnitude. vcs_info, while being
flexible, is one of the slowest. It's convenient to use vcs_info
thanks to its being bundled with zsh but but this convenience comes at
a great cost.

Roman.

[1] bart + gitstatus configuration can be obtained by appending the
following code to bart + vcs_info.

if [[ ! -d ~/gitstatus ]]; then
   git checkout https://github.com/romkatv/gitstatus.git ~/gitstatus
fi

source ~/gitstatus/gitstatus.plugin.zsh

# Start gitstatusd in the background and give it ID 'MY'.
# It'll terminate when the parent shell terminates.
gitstatus_start MY

vcs-info-v() {
   if gitstatus_query -p MY && [[ $VCS_STATUS_RESULT == 'ok-sync' ]]; then
     # The current directory is inside a Git repo.
     RPS1='%F{5}(%fgit%F{5})%F{3}-%F{5}['
     # Branch or tag or commit.
     local b=$VCS_STATUS_LOCAL_BRANCH
     : ${b:=$VCS_STATUS_TAG}
     : ${b:=$VCS_STATUS_COMMIT[1,8]}
     [[ -o prompt_subst ]] && b='${:-'${(qqq)b}'}'
     RPS1+="%F{2}${b//\%/%%}%f"
     # Add '<'/'>' after branch name if there are changes to pull/push.
     (( VCS_STATUS_COMMITS_BEHIND )) && RPS1+='<'
     (( VCS_STATUS_COMMITS_AHEAD )) && RPS1+='>'
     # Action, a.k.a. state. For example, 'merge'.
     [[ -n $VCS_STATUS_ACTION ]] && RPS1+="%F{3}|%F{1}$VCS_STATUS_ACTION"
     RPS1+='%F{5}]%f'
   else
     # Not a Git repo. Call vcs_info in case it's a sv[nk]|bzr repo.
     vcs_info
     RPS1=${vcs_info_msg_0_% }
   fi
}




Messages sorted by: Reverse Date, Date, Thread, Author