zsh-users
 help / Atom feed
From: Roman Perepelitsa <roman.perepelitsa@gmail.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Frank Terbeck <ft@bewatermyfriend.org>,
	Peng Yu <pengyu.ut@gmail.com>,  zsh-users <zsh-users@zsh.org>
Subject: Re: Is it worthwhile to use oh-my-zsh?
Date: Sun, 8 Sep 2019 17:41:26 +0200
Message-ID: <CAN=4vMq6oVYKT+3KCnS4CM7sqzY78j-9ymG9BctSzu43s95RFQ@mail.gmail.com> (raw)
In-Reply-To: <CAH+w=7aX-W2RRtZeMwedxD3gTQyT+ZzK7XPcVEHHoZ0nJuMMVg@mail.gmail.com>

On Sun, Sep 8, 2019 at 2:33 AM Bart Schaefer <schaefer@brasslantern.com> wrote:
>
> On Sat, Sep 7, 2019 at 1:19 PM Frank Terbeck <ft@bewatermyfriend.org> 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
}

  reply index

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-06 18:37 Peng Yu
     [not found] ` <CAO1rNLj9YA+4a+5SV+PURsfPJXNm8xY45i6kbrsPpF2NFY1fsg@mail.gmail.com>
2019-09-06 19:33   ` Peng Yu
2019-09-07  0:43     ` Danh Doan
2019-09-07  0:49       ` Yaro Kasear
2019-09-07  1:40       ` Peng Yu
2019-09-07  1:59         ` Danh Doan
2019-09-07 12:22       ` Daniel Shahaf
2019-09-07 13:58 ` Roman Perepelitsa
2019-09-07 20:18   ` Frank Terbeck
2019-09-08  0:33     ` Bart Schaefer
2019-09-08 15:41       ` Roman Perepelitsa [this message]
2019-09-08 19:05         ` Nick Cross
2019-09-08 19:41           ` Roman Perepelitsa

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAN=4vMq6oVYKT+3KCnS4CM7sqzY78j-9ymG9BctSzu43s95RFQ@mail.gmail.com' \
    --to=roman.perepelitsa@gmail.com \
    --cc=ft@bewatermyfriend.org \
    --cc=pengyu.ut@gmail.com \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

zsh-users

Archives are clonable: git clone --mirror http://inbox.vuxu.org/zsh-users

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.users


AGPL code for this site: git clone https://public-inbox.org/ public-inbox