Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

git prompt causes FISH to start very slowly on OS X #6625

Copy link
Copy link

Description

@duganchen
Issue body actions
dugan ) fish --version
fish, version 3.1.0
dugan ) echo $version
3.1.0
dugan ) uname -a
Darwin MacBook-Pro.local 19.3.0 Darwin Kernel Version 19.3.0: Thu Jan  9 20:58:23 PST 2020; root:xnu-6153.81.5~1/RELEASE_X86_64 x86_64
dugan ) echo $TERM
xterm-256color-italic
dugan ) sh -c 'env HOME=$(mktemp -d) fish'

I had the common OS X issue where FISH would take seconds to load. It would only happen once per reboot. The first time I tried to start FISH after a reboot, it would take seconds to start. If you tried to start it again, it would start instantly. At least, until the next reboot.

I profiled it: and the cause seems to be having a prompt with VCS information in it? This absolutely jumped out at me:

356	7369742	--> fish_vcs_prompt
360	379	---> source /usr/local/Cellar/fish/3.1.0/share/fish/functions/fish_vcs_prompt.fish
19	19	----> function fish_vcs_prompt --description "Print the prompts for all available vcsen"
    # If a prompt succeeded, we assume that it's printed the correct info.
    # This is so we don't try svn if git already worked.
    fish_git_prompt
    or fish_hg_prompt
    or fish_svn_prompt
...
394	5204357	---> fish_git_prompt

I tried switching to a prompt without VCS information, and now FISH starts instantly. Even right after a reboot.

Both profile results ("FISH Profile with git prompt" and "FISH profile with minimalist prompt" are here:

https://gist.github.com/duganchen/7467164add3bcfa6cae0e2f2741ca8bc

This, more precisely, is what's taking so much time on startup:

277	5194027	----> set -l repo_info (command git rev-parse --git-dir --is-inside-git-dir --is-bare-repository --is-inside-work-tree HEAD 2>/dev/null)
5193750	5193750	-----> command git rev-parse --git-dir --is-inside-git-dir --is-bare-repository --is-inside-work-tree HEAD 2>/dev/null

And no, I'm (obviously) not in a git repository when FISH starts.

If I change fish_prompt_git to call git with its absolute path: well, that makes no difference:

327	4283632	----> set -l repo_info (/usr/bin/git rev-parse --git-dir --is-inside-git-dir --is-bare-repository --is-inside-work-tree HEAD 2>/dev/null)
4283305	4283305	-----> /usr/bin/git rev-parse --git-dir --is-inside-git-dir --is-bare-repository --is-inside-work-tree HEAD 2>/dev/null

An as for why git is so slow the first time it starts on OS X: I don't know. This takes several seconds, the first time after a reboot it runs:

dugan@MacBook-Pro ~ % GIT_TRACE=1 /usr/bin/git rev-parse --git-dir --is-inside-git-dir --is-bare-repository --is-inside-work-tree HEAD
15:25:54.711033 exec-cmd.c:139          trace: resolved executable path from Darwin stack: /Applications/Xcode.app/Contents/Developer/usr/bin/git
15:25:54.727587 exec-cmd.c:236          trace: resolved executable dir: /Applications/Xcode.app/Contents/Developer/usr/bin
15:25:54.739887 git.c:419               trace: built-in: git rev-parse --git-dir --is-inside-git-dir --is-bare-repository --is-inside-work-tree HEAD
fatal: not a git repository (or any of the parent directories): .git
dugan@MacBook-Pro ~ %
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    macosmacOS-specific issuemacOS-specific issueperformancePurely performance-related enhancement without any changes in black box outputPurely performance-related enhancement without any changes in black box output

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.