From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 285d3353 for ; Sun, 8 Sep 2019 15:42:23 +0000 (UTC) Received: (qmail 17973 invoked by alias); 8 Sep 2019 15:42:13 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 24241 Received: (qmail 28398 invoked by uid 1010); 8 Sep 2019 15:42:13 -0000 X-Qmail-Scanner-Diagnostics: from mail-io1-f65.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.101.2/25559. spamassassin: 3.4.2. Clear:RC:0(209.85.166.65):SA:0(-2.0/5.0):. Processed in 2.515162 secs); 08 Sep 2019 15:42:13 -0000 X-Envelope-From: roman.perepelitsa@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.166.65 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xuIht0rrLvAcTTYhr1uSCb8vLemAJakFAFrY3fpVQTg=; b=SU23RX4r2QWTC37HgNVRcehrx1JVwWIllhOyhJ0+pe36vBrmjuylk909Ul4oEO1pTW Iy2KUbhEGB4wEJ3m0pZg7f7/fPgK07oNxyheYEeusMetzrtKYbsrMOsyW3wTCLBGpN0f yJgImMC1OAwoLeU2oJQQ+9mVDex1ai5aqAdTG6xys6q6Ug0HRgAIeD3IVvmfivefCtSU 9c7Okwrr6otLwBSm2Swl5TjwUmUr8h+N85yU6YWBaB3hnXxUQh1JWb8p1jT+TCRuHR4I pjIAqt5jk9ayGRe8wh6eVsVmp1SAIVBbRaaOioo3OoVqGUIPvMAHrxZ4JCuzTmwzP7Jw ne7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xuIht0rrLvAcTTYhr1uSCb8vLemAJakFAFrY3fpVQTg=; b=tm2rxc+KvJTdu+a8qoc8c5zs6e05ETeb4GlFOsWgvmhcBYn2Eek4G8aOhtpLu/cJG0 eDGnaySiuf8fFvUo6RVqqXX/sE87ld7FoO+6Q93faKTP5LShUon+NYSxRfkgsTFu5tMA i6nkL9gWWlIc9T82XEHYZ4A4VnRGLa9MIvWi/GmRQ/rKSzIcOaRc+/pcKbWtgNTauEUB rG4XzqNsgBRWpg7pL8uOdWpuZ8sHKpn1Nb83KKFnNoddyH7sipQoEamo5ccIqHHRxrM/ 0UAAinuFZtNKm2MqsGsKH6zx+Fl5f9lo8L3s75xc7GMUzACjX5BbzLH2xRKszs+bPLr2 RUSw== X-Gm-Message-State: APjAAAWYLNCDbdWFHTUPOEp+iVOLrkCa8obCcFbx5MVgbGcD5Rchb/lo 8ZxvsJB8wA5tvnYnGzyoDXXNqvcpflDZRuS/6mY= X-Google-Smtp-Source: APXvYqxXv3AoMynQpBL++4Aiu3FIif+bKS0k5MrcoM+/+QCutVW45kTaXnY7yVSj/ag5J/e3Ew1qktkOW6BDyUZfPRU= X-Received: by 2002:a5d:97cf:: with SMTP id k15mr22085791ios.151.1567957296700; Sun, 08 Sep 2019 08:41:36 -0700 (PDT) MIME-Version: 1.0 References: <87woejhnct.fsf@ft.bewatermyfriend.org> In-Reply-To: From: Roman Perepelitsa Date: Sun, 8 Sep 2019 17:41:26 +0200 Message-ID: Subject: Re: Is it worthwhile to use oh-my-zsh? To: Bart Schaefer Cc: Frank Terbeck , Peng Yu , zsh-users Content-Type: text/plain; charset="UTF-8" On Sun, Sep 8, 2019 at 2:33 AM Bart Schaefer wrote: > > On Sat, Sep 7, 2019 at 1:19 PM Frank Terbeck 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 }