starship: git_status is so slow...
Current Behavior
inside even a small repo (git ls-files | xargs wc -l returns 3564 total lines) running env STARSHIP_LOG=trace starship timings gives the following
git_status - 185ms - "[$!] "
nodejs - 30ms - "via v12.8.0 "
directory - 5ms - "catppuccin-noctis "
battery - 2ms - ""
pulumi - 2ms - ""
git_branch - <1ms - "on main "
python - <1ms - "via 🐍 cd"
line_break - <1ms - "\n"
character - <1ms - "❯ "
this is the best timing I can get, most repos I have are way worse than this, upwards of 250ms, or 300ms.
Expected Behavior
I expect it to be way less than that. Probably 10x less. Somewhere on the order of 20-30ms tops. Anything above this is unusable
Additional context/Screenshots
I have tried certain things like running brew update && brew upgrade I have also tried git gc inside the repo, tried disabling unused modules in starship, nothing seems to help
Possible Solution
Environment
- Starship version: 1.10.2
- zsh version: zsh 5.9 (x86_64-apple-darwin21.3.0)
- Operating system: Mac OS 12.5.1
- Terminal emulator: iTerm.app 3.4.16
- Git Commit Hash:
- Branch/Tag:
- Rust Version: rustc 1.63.0
- Rust channel: release
- Build Time: 2022-08-19 02:43:05 +00:00
Relevant Shell Configuration
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source /usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh
eval "$(starship init zsh)"
Starship Configuration
# Inserts a blank line between shell prompts
add_newline = true
# Replace the "❯" symbol in the prompt with "➜"
# [character] # The name of the module we are configuring is "character"
# success_symbol = "[➜](bold green)" # The "success_symbol" segment is being set to "➜" with the color "bold green"
# Disable the package module, hiding it from the prompt completely
[package]
disabled = true
[docker_context]
# format = "via [🐋 $context](blue bold)"
disabled = true
[aws]
# format = 'on [$symbol($profile )(\($region\) )]($style)'
# style = "bold blue"
# symbol = "🅰 "
# [aws.region_aliases]
# ap-southeast-2 = "au"
# us-east-1 = "va"
disabled = true
[gcloud]
# format = 'on [$symbol$account(@$domain)(\($project\))]($style) '
disabled = true
[python]
pyenv_version_name = true
python_binary = ["python"]
format = 'via [${symbol}${version}]($style)'
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 20 (9 by maintainers)
Commits related to this issue
- starship: faster prompt by using gitstatus See https://github.com/starship/starship/issues/4305 for detailed steps to improve starthip prompt: - use `starthip timings` to evaluate what is slow - `gi... — committed to l-lin/dotfiles by l-lin 4 years ago
- fix(git): performance optimizations See https://github.blog/2022-06-29-improve-git-monorepo-performance-with-a-file-system-monitor/ for more info See https://github.com/starship/starship/issues/4305... — committed to dalisoft/dotfiles by dalisoft 3 years ago
This will also improve performance a bit:
There have been lots of improvements to git for large repos recently: https://github.blog/2022-06-29-improve-git-monorepo-performance-with-a-file-system-monitor/
To summarise, git has a built in file system monitor daemon, which
git statuscommunicates with using IPC to retrieve a list of changed files, instead of having to read the actual files on disk. The article claims it improves other commands likediff,add .,restoreandcheckoutas well.If you’re on Mac or Windows, you can try these config options to speed up
git status(ensuregit --versionis >= 2.37.0):There is support coming for the built-in fsmonitor on linux, see https://github.com/git/git/pull/1352. You can still use watchman with the git hook described in the article on linux (I think).
Another thing to try is
git config feature.manyFiles trueAs a possible workaround, I recently changed my setup to use gitstatusd, a background daemon that tracks status and makes it available very quickly to shell prompts even with massive repos.
It makes various status fields available as env vars, which you can then further process as you like. Ultimately, I use the zsh gitstatusd plugin, wrap it in a shellscript to format how I like and export formatted env vars, and then display it in my starship using a the
env_varmodule. Here’s my relevant:Can this project async display git status? don’t hold and drag the prompt until get all info?
just instant draw the prompt and the doing git stuffs in background and display whenever its avail or if not just abandon it.
because if we can’t have an
instant prompt, no user can actually do their work.@colemickens apologies, had to make the repo private - here’s the relevant parts in a gist: https://gist.github.com/junosuarez/400a66bcb90d8a9238303fb072a1ae98
it’s slow because there’s no git info-feeder for it which is arguably an starship issue or not. i.e: powerlevel10k has another project
gitstatusto feed git info, starship doesn’t.@domsleee Recent git versions also come with the
scalartool, which can apply performance optimizations on large repositories viascalar register.Enabling
features.manyfilesorcore.fsmonitorcan improve git performance, but right now it is limited by the performance of git itself. In the future, gitoxide may improve the performance to some degree. You may also want to follow #301.