Starship: Starship is slow in directories with many files

Created on 11 Jul 2020  ·  4Comments  ·  Source: starship/starship

Current Behavior

I have the official rust repository (with ~130k files) on my pc.
Every time I cd into the folder, starship loads for a few seconds until it
is fully loaded. If a cd again in the folder, it only loads for about 1 second.

Also, if I enter a command, or just press enter without any command, it
hangs for probably half a second.

Expected Behavior

Starship should be fast enough to cd into a directory with many files,
without a huge delay.

Environment

  • Starship version: 0.44.0
  • zsh version: zsh 5.8 (x86_64-pc-linux-gnu)
  • Operating system: Arch Linux rolling
  • Terminal emulator: Alacritty

Possible Solution

I will try to debug some things in starship to find out where it slows down.

Relevant Shell Configuration

<unknown config>

Starship Configuration

add_newline = true
prompt_order = [
    "kubernetes",
    "directory",
    "git_branch",
    "git_commit",
    "git_state",
    "git_status",
    "package",
    "dotnet",
    "golang",
    "java",
    "nodejs",
    "php",
    "python",
    "ruby",
    "rust",
    "terraform",
    "conda",
    "memory_usage",
    "aws",
    "env_var",
    "cmd_duration",
    "line_break",
    "jobs",
    "time",
    "battery",
    "character",
]

[character]
symbol = "λ ›"
vicmd_symbol = "λ ·"

[cmd_duration]
disabled = true

[aws]
symbol = " "

[battery]
full_symbol = ""
charging_symbol = ""
discharging_symbol = ""
disabled = true

[conda]
symbol = " "

[git_branch]
symbol = " "

[golang]
symbol = " "

[hg_branch]
symbol = " "

[java]
symbol = " "

[memory_usage]
symbol = " "
disabled = true

[nodejs]
symbol = " "

[package]
symbol = " "
disabled = true

[php]
symbol = " "

[python]
symbol = " "

[ruby]
symbol = " "

[rust]
symbol = " "
🐛 bug 🐣 optimization

Most helpful comment

Honestly, I think without asynchronous prompt rendering, this is never going to be completely "solved," since there's always a bigger repo. The benchmarks for gitstatusd on chromium repo look really good (because they are!), but they are running on some pretty nice hardware. When you swap that out for my not-new-but-still-not-bad desktop (a 3770K), the time to parse the chromium repo, even on a hot run, is 125ms, which is just a little bit high for interactive usage (esp. once you add the fact that this takes all my CPUs, so it would be competing with starship for CPU time). gitstatusd represents state of the art in terms of getting git status information quickly right now. It's unlikely that we'll be able to significantly beat it in the near-future.

@Stupremee This is almost certainly caused by the git status module, so if you want a quick-fix, you can disable that module by adding the following to your starship.toml:

[git_status]
disabled=true

You'll still get branch information, you just won't get the indicator telling you that files are dirty/clean/staged/stashed.

All 4 comments

This will be fixed by #1446 (see also #891 #597)
For what it's worth for listing directory contents with lots of files without git there's actually a timeout.

Honestly, I think without asynchronous prompt rendering, this is never going to be completely "solved," since there's always a bigger repo. The benchmarks for gitstatusd on chromium repo look really good (because they are!), but they are running on some pretty nice hardware. When you swap that out for my not-new-but-still-not-bad desktop (a 3770K), the time to parse the chromium repo, even on a hot run, is 125ms, which is just a little bit high for interactive usage (esp. once you add the fact that this takes all my CPUs, so it would be competing with starship for CPU time). gitstatusd represents state of the art in terms of getting git status information quickly right now. It's unlikely that we'll be able to significantly beat it in the near-future.

@Stupremee This is almost certainly caused by the git status module, so if you want a quick-fix, you can disable that module by adding the following to your starship.toml:

[git_status]
disabled=true

You'll still get branch information, you just won't get the indicator telling you that files are dirty/clean/staged/stashed.

Honestly, I think without asynchronous prompt rendering, this is never going to be completely "solved," since there's always a bigger repo.

Indeed. There is always a bigger repo, or a slower machine, or NTFS, or Windows.

This might help as a shortterm workaround: https://github.com/starship/starship/pull/1615

Was this page helpful?
0 / 5 - 0 ratings