prezto icon indicating copy to clipboard operation
prezto copied to clipboard

'prompt' module slowing down navigation in sshfs mounted directories

Open ahuber21 opened this issue 5 years ago • 12 comments

Description

Navigating inside a directory that is mounted via sshfs is extremely slow. I narrowed it down to some features inside the prompt module. A simple ls takes several seconds. This is because some git commands are run in the background.

I tried various versions of

zstyle ':vcs_info:*' disable-patterns "${(b)HOME}/dev(|/*)"
zstyle ':vcs_info:*' disable-patterns "/sshfs(|/*)"

but none of them fixed the issue.

I tried git-info off without effect.

I tried git config --global oh-my-zsh.hide-status 1 without effect.

Also, entirely removing all contents of modules/prompt/external (i.e. the powerlevel9k / powerlevel10k stuff) does not fix the issue.

This behaviour is observed with an outdated version from ~6 months ago and the latest master, that I pulled just now (of course I started a fresh shell after pulling).

Expected behavior

Simple commands like cd, ls, less, etc. should work without lag.

Actual behavior

Intermediate calls to git that are executed in the background slow down everything by orders of magnitude.

Steps to Reproduce

  1. Start a new shell, no theme selected
  2. Navigate to a sshfs-mounted directory
  3. Observe that shell is still very responsive
  4. Enable a thema, e.g. spaceship (all git features deactivated)
  5. Shell became painfully slow

prezto

Side note: I can select any other theme, the result is the same. I've used spaceship for a while now and I know that in this theme I already got rid of all git related stuff.

Versions

  • Prezto commit: e94b6b2078ccd0b289293dc4b996983a96a34681
  • ZSH version: zsh 5.3 (x86_64-apple-darwin17.0)
  • OS information: macOS 10.13.6

ahuber21 avatar Jul 12 '19 18:07 ahuber21

I believe this is occurring because the git-info command is still running. We use git config --bool prompt.showinfo to check if git-info should be run, but it's the second git command in git-info. It may be worth providing a zstyle option to completely disable git-info so we can short-circuit any calls to git.

belak avatar Jul 16 '19 00:07 belak

Hi @belak, thanks for your comment. Is there anything I can try/do?

I agree, a killswitch, similar to the vcs disable-patterns, would be the right thing. I still want to have the advantages in non-sshfs directories.

ahuber21 avatar Jul 16 '19 09:07 ahuber21

Have you tried it with a zsh version that's not 5.3? 5.3 is known to have multiple issues.

johnpneumann avatar Jul 16 '19 13:07 johnpneumann

Hi @johnpneumann I just installed

➜ zsh --version
zsh 5.7.1 (x86_64-apple-darwin17.7.0)

with homebrew. I can tell that the git commands are still being run in the sshfs directory. However, I can't tell if it sped it any way, as I'm currently in an office with a much better connection to the server from which I'm mounting the dirs. But I guess commands like git rev-parse, git ls-files, etc. shouldn't run faster with a different zsh version.

Would you have expected that any settings I tried before to disable the git commands work with a newer zsh version? It looks like this is not the case.

ahuber21 avatar Jul 16 '19 13:07 ahuber21

If you're willing to live without it, you could disable the prezto git module. You would lose additional git related functionality, but it wouldn't run additional git commands.

belak avatar Jul 16 '19 18:07 belak

And how would I do that? Could this be done conditional? I.e. only in certain paths?

ahuber21 avatar Jul 17 '19 07:07 ahuber21

In your zpreztorc, there should be a list of enabled modules. If you remove or comment out the git module, this will be disabled. It's unfortunately not possible to do in certain paths.

belak avatar Jul 17 '19 17:07 belak

Hi @belak,

I removed git from the zstyle ':prezto:load' pmodule list but as soon as I start prompt spaceship the git commands run again.

Edit: Okay, I'll do some more testing at home, when I'm back with the slower internet connection, maybe your suggestion did help.

I'm saying that git is still running because it briefly shows "git" in the terminal name (which doesn't happen before executing prompt).

But I just aliased all git commands that I have on my machine to echo some information, but nothing is echoed to screen.

This is a quite bad attempt in trying to understand what's going on. Is there maybe a debug option that prints everything that's happening between me typing ls <Enter> and the next prompt showing up?

ahuber21 avatar Jul 18 '19 09:07 ahuber21

Okay quick update: I tested it back at home and removing git from .zpreztorc doesn't change anything.

I'm really wondering what exactly is calling git..

Edit: By the way, removing prompt from .zpreztorc does fix the issue.

ahuber21 avatar Jul 19 '19 07:07 ahuber21

Okay, as this discussion is dying down let me try to ask a precise question.

  • How can I profile which processes are running after I enter any command (e.g. ls)?
  • If that's not possible, how would you try to identify the source of the delay?

ahuber21 avatar Jul 24 '19 09:07 ahuber21

Alright, I realised that I had another git installation directly from Xcode.

Here is what I was able to find out. I replaced /Applications/Xcode.app/Contents/Developer/usr/bin/git with a simple script

#!/bin/bash

echo "git $@ called by $PPID - $(ps aux | grep $PPID)"
exit 0

and the text pops up in the directory name. Does this help?

Screen Shot 2019-07-29 at 08 51 22

Edit: Well, okay, I realised that not for every theme additional output appears on the screen. For example prompt sorin works fine and fast, but prompt steeef has the lags. Now I'm not sure if this is still the right place for the ticket. I somehow think that there should be a central place in prezto to make sure that extensions like themes don't run expensive commands. But you might argue that it's there and the themes are just ignoring the settings. Let me know what you think, and, if necessary, feel free to close the issue.

Edit2: Spoke too soon again, I modified my script such that it also outputs everything to a debug file and realised that even a ls from within a prompt steef runs

git rev-parse --is-inside-work-tree called by 32436 - ahoenle          32436   0.8  0.0  4335164   5416 s002  S    12Jul19   0:03.92 -zsh
git rev-parse --git-dir called by 32436 - ahoenle          32436   0.1  0.0  4335164   5416 s002  S+   12Jul19   0:03.93 -zsh
git symbolic-ref HEAD called by 32436 - ahoenle          32436   0.2  0.0  4335180   5424 s002  S+   12Jul19   0:03.93 -zsh
git rev-parse --show-toplevel called by 32436 - ahoenle          32436   0.2  0.0  4335164   5420 s002  S+   12Jul19   0:03.93 -zsh
git rev-parse --git-dir called by 70928 - ahoenle          70928   0.0  0.0  4334892    908 s002  S+    9:03AM   0:00.00 -zsh
git rev-parse --is-inside-work-tree called by 70944 - ahoenle          70944   0.1  0.0  4334988    576 s018  SN+   9:03AM   0:00.00 -zsh

It appears to me as if the part displaying the current working directory is trying to find the git top level in order to display the cwd relative to the top level. Man... I don't need this

ahuber21 avatar Jul 29 '19 06:07 ahuber21

Run this to output the calls being made to a file:

zsh -xv &> >(tee ~/debug.log 2>/dev/null)

Can you post your full zpreztorc as well

johnpneumann avatar Jul 29 '19 12:07 johnpneumann