JanDeDobbeleer / oh-my-posh

The most customisable and low-latency cross platform/shell prompt renderer
https://ohmyposh.dev
MIT License
17.53k stars 2.4k forks source link

oh-my-posh on WSL significantly slow #2406

Closed amzon-ex closed 2 years ago

amzon-ex commented 2 years ago

Code of Conduct

What happened?

After the update to v8.3.2, oh-my-posh has significantly slowed down on WSL (~10 ms to ~200 ms). On powershell it seems to be doing fine. The debug logs don't show anything interesting I guess, but still, I don't know why this is happening.

Theme

{
  "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
  "blocks": [
    {
      "alignment": "right",
      "newline": true,
      "horizontal_offset": 1,
      "segments": [
        {
          "foreground": "#FFD54F",
          "properties": {
            "text": "\uf2dd"
          },
          "style": "plain",
          "template": "\uf0e7 ",
          "type": "root"
        },
        {
          "foreground": "gray",
          "leading_diamond": "\ue0b6",
          "properties": {
            "threshold": 10
          },
          "style": "plain",
          "template": "\uf64f {{.FormattedMs}} ",
          "type": "executiontime"
        },
        {
          "properties": {
            "branch_icon": "\uf7a1 ",
            "fetch_stash_count": true,
            "fetch_status": false
          },
          "style": "plain",
          "template": "<#ffffff>on</> {{ .HEAD }} {{ .BranchStatus }}{{ if .Working.Changed }} \uf044 {{ .Working.String }}{{ end }}{{ if and (.Staging.Changed) (.Working.Changed) }} |{{ end }}{{ if .Staging.Changed }} \uf046 {{ .Staging.String }}{{ end }}{{ if gt .StashCount 0}} \uf692 {{ .StashCount }}{{ end }}{{ if gt .WorktreeCount 0}} \uf1bb {{ .WorktreeCount }}{{ end }} ",
          "type": "git"
        },
        {
          "foreground": "#9E7DFF",
          "properties": {
            "display_mode": "context"
          },
          "style": "plain",
          "template": "\ue606 {{ if .Error }}{{ .Error }}{{ else }}{{ if .Venv }}{{ .Venv }} {{ end }}{{ end }}",
          "type": "python"
        },
        {
          "foreground": "#7FD5EA",
          "style": "plain",
          "template": "\ufcd1 {{ if .Error }}{{ .Error }}{{ else }}{{ end }}",
          "type": "go"
        },
        {
          "foreground": "#98C379",
          "style": "plain",
          "template": "\ue718 {{ if .PackageManagerIcon }}{{ .PackageManagerIcon }} {{ end }}",
          "type": "node"
        },
        {
          "foreground": "#FC5548",
          "style": "plain",
          "template": "\ue791 {{ if .Error }}{{ .Error }}{{ else }}{{ end }}",
          "type": "ruby"
        },
        {
          "foreground": "#ea2d2e",
          "style": "plain",
          "template": "\ue738 {{ if .Error }}{{ .Error }}{{ else }}{{ end }}",
          "type": "java"
        },
        {
          "foreground": "#5F7DE1",
          "style": "plain",
          "template": "\ue624 {{ if .Error }}{{ .Error }}{{ else }}{{ end }}",
          "type": "julia"
        },
        {
          "foreground": "green",
          "properties": {
            "style": "folder"
          },
          "style": "plain",
          "template": "\ufc6e {{ .Path }} ",
          "type": "path"
        }
      ],
      "type": "prompt"
    },
    {
      "alignment": "left",
      "newline": true,
      "segments": [
        {
          "foreground": "cyan",
          "style": "plain",
          "template": "{{.Icon}} ",
          "type": "os"
        },
        {
          "foreground": "cyan",
          "style": "plain",
          "template": "\u2192 ",
          "type": "text"
        }
      ],
      "type": "prompt"
    }
  ],
  "console_title_template": "{{ .Shell }} in {{ .Folder }}",
  "osc99": true,
  "version": 2
}

What OS are you seeing the problem on?

Linux

Which shell are you using?

bash

Log output

Version: 8.3.2

Segments:

ConsoleTitle(true)   -   0 ms - bash in ~
root(false)          -   0 ms -
executiontime(false) -   0 ms -
git(false)           -   0 ms -
python(false)        -   0 ms -
go(false)            -   0 ms -
node(false)          -   0 ms -
ruby(false)          -   0 ms -
java(false)          -   0 ms -
julia(false)         -   0 ms -
path(true)           -   2 ms - ﱮ ~
os(true)             -   0 ms - 
text(true)           -   0 ms - →

Run duration: 4.026702ms

Cache path: /home/amzon-ex/.cache/oh-my-posh

Config path: /home/amzon-ex/.ompthemes/minamil.omp.json

Logs:

2022/06/12 20:40:48 debug: Getenv

2022/06/12 20:40:48 Getenv duration: 10.651µs, args: XDG_CACHE_HOME
2022/06/12 20:40:48 CachePath duration: 23.074µs, args:
2022/06/12 20:40:48 debug: Getenv
/home/amzon-ex/.ompthemes/minamil.omp.json
2022/06/12 20:40:48 Getenv duration: 1.953µs, args: POSH_THEME
2022/06/12 20:40:48 resolveConfigPath duration: 3.937µs, args:
2022/06/12 20:40:48 Init duration: 81.324µs, args:
2022/06/12 20:40:48 Flags duration: 40ns, args:
2022/06/12 20:40:48 config.loadConfig duration: 331.931µs, args:
2022/06/12 20:40:48 Flags duration: 40ns, args:
2022/06/12 20:40:48 debug: Getenv

2022/06/12 20:40:48 Getenv duration: 1.383µs, args: OMP_CACHE_DISABLED
2022/06/12 20:40:48 Root duration: 481ns, args:
2022/06/12 20:40:48 Shell duration: 312.725µs, args:
2022/06/12 20:40:48 ErrorCode duration: 30ns, args:
2022/06/12 20:40:48 debug: Getenv
Ubuntu-20.04
2022/06/12 20:40:48 Getenv duration: 1.433µs, args: WSL_DISTRO_NAME
2022/06/12 20:40:48 IsWsl duration: 2.805µs, args:
2022/06/12 20:40:48 debug: Pwd
/home/amzon-ex
2022/06/12 20:40:48 Pwd duration: 8.717µs, args:
2022/06/12 20:40:48 PathSeparator duration: 50ns, args:
2022/06/12 20:40:48 PathSeparator duration: 20ns, args:
2022/06/12 20:40:48 debug: User
amzon-ex
2022/06/12 20:40:48 User duration: 831ns, args:
2022/06/12 20:40:48 debug: Host
minami
2022/06/12 20:40:48 Host duration: 1.893µs, args:
2022/06/12 20:40:48 GOOS duration: 30ns, args:
2022/06/12 20:40:48 TemplateCache duration: 348.923µs, args:
2022/06/12 20:40:48 Flags duration: 60ns, args:
2022/06/12 20:40:48 debug: Pwd
/home/amzon-ex
2022/06/12 20:40:48 Pwd duration: 691ns, args:
2022/06/12 20:40:48 GOOS duration: 20ns, args:
2022/06/12 20:40:48 Root duration: 200ns, args:
2022/06/12 20:40:48 debug: Pwd
/home/amzon-ex
2022/06/12 20:40:48 Pwd duration: 1.362µs, args:
2022/06/12 20:40:48 GOOS duration: 30ns, args:
2022/06/12 20:40:48 ExecutionTime duration: 40ns, args:
2022/06/12 20:40:48 debug: Pwd
/home/amzon-ex
2022/06/12 20:40:48 Pwd duration: 601ns, args:
2022/06/12 20:40:48 GOOS duration: 20ns, args:
2022/06/12 20:40:48 debug: Getenv
Ubuntu-20.04
2022/06/12 20:40:48 Getenv duration: 751ns, args: WSL_DISTRO_NAME
2022/06/12 20:40:48 IsWsl duration: 1.793µs, args:
2022/06/12 20:40:48 debug: Pwd
/home/amzon-ex
2022/06/12 20:40:48 Pwd duration: 461ns, args:
2022/06/12 20:40:48 GOOS duration: 30ns, args:
2022/06/12 20:40:48 HasCommand duration: 13.085µs, args: git
2022/06/12 20:40:48 debug: Pwd
/home/amzon-ex
2022/06/12 20:40:48 Pwd duration: 481ns, args:
2022/06/12 20:40:48 error: HasParentFilePath
stat /.git: no such file or directory
2022/06/12 20:40:48 HasParentFilePath duration: 5.551µs, args: .git
2022/06/12 20:40:48 debug: Pwd
/home/amzon-ex
2022/06/12 20:40:48 Pwd duration: 762ns, args:
2022/06/12 20:40:48 GOOS duration: 20ns, args:
2022/06/12 20:40:48 debug: Pwd
/home/amzon-ex
2022/06/12 20:40:48 Pwd duration: 501ns, args:
2022/06/12 20:40:48 debug: Getenv

2022/06/12 20:40:48 Getenv duration: 761ns, args: VIRTUAL_ENV
2022/06/12 20:40:48 debug: Getenv

2022/06/12 20:40:48 Getenv duration: 641ns, args: CONDA_ENV_PATH
2022/06/12 20:40:48 debug: Getenv

2022/06/12 20:40:48 Getenv duration: 651ns, args: CONDA_DEFAULT_ENV
2022/06/12 20:40:48 debug: Pwd
/home/amzon-ex
2022/06/12 20:40:48 Pwd duration: 481ns, args:
2022/06/12 20:40:48 PathSeparator duration: 30ns, args:
2022/06/12 20:40:48 debug: HasFiles
false
2022/06/12 20:40:48 HasFiles duration: 45.576µs, args: *.py
2022/06/12 20:40:48 debug: Pwd
/home/amzon-ex
2022/06/12 20:40:48 Pwd duration: 511ns, args:
2022/06/12 20:40:48 PathSeparator duration: 30ns, args:
2022/06/12 20:40:48 debug: HasFiles
false
2022/06/12 20:40:48 HasFiles duration: 28.935µs, args: *.ipynb
2022/06/12 20:40:48 debug: Pwd
/home/amzon-ex
2022/06/12 20:40:48 Pwd duration: 481ns, args:
2022/06/12 20:40:48 PathSeparator duration: 30ns, args:
2022/06/12 20:40:48 debug: HasFiles
false
2022/06/12 20:40:48 HasFiles duration: 3.637µs, args: pyproject.toml
2022/06/12 20:40:48 debug: Pwd
/home/amzon-ex
2022/06/12 20:40:48 Pwd duration: 471ns, args:
2022/06/12 20:40:48 PathSeparator duration: 30ns, args:
2022/06/12 20:40:48 debug: HasFiles
false
2022/06/12 20:40:48 HasFiles duration: 4.208µs, args: venv.bak
2022/06/12 20:40:48 debug: HasFolder
false
2022/06/12 20:40:48 HasFolder duration: 1.303µs, args: .venv
2022/06/12 20:40:48 debug: HasFolder
false
2022/06/12 20:40:48 HasFolder duration: 1.133µs, args: venv
2022/06/12 20:40:48 debug: HasFolder
false
2022/06/12 20:40:48 HasFolder duration: 1.313µs, args: virtualenv
2022/06/12 20:40:48 debug: HasFolder
false
2022/06/12 20:40:48 HasFolder duration: 1.142µs, args: env
2022/06/12 20:40:48 debug: HasFolder
false
2022/06/12 20:40:48 HasFolder duration: 1.232µs, args: venv-win
2022/06/12 20:40:48 debug: HasFolder
false
2022/06/12 20:40:48 HasFolder duration: 1.202µs, args: pyenv-win
2022/06/12 20:40:48 debug: Pwd
/home/amzon-ex
2022/06/12 20:40:48 Pwd duration: 671ns, args:
2022/06/12 20:40:48 GOOS duration: 21ns, args:
2022/06/12 20:40:48 debug: Pwd
/home/amzon-ex
2022/06/12 20:40:48 Pwd duration: 561ns, args:
2022/06/12 20:40:48 debug: Pwd
/home/amzon-ex
2022/06/12 20:40:48 Pwd duration: 591ns, args:
2022/06/12 20:40:48 GOOS duration: 30ns, args:
2022/06/12 20:40:48 debug: Pwd
/home/amzon-ex
2022/06/12 20:40:48 Pwd duration: 551ns, args:
2022/06/12 20:40:48 debug: Pwd
/home/amzon-ex
2022/06/12 20:40:48 Pwd duration: 581ns, args:
2022/06/12 20:40:48 GOOS duration: 30ns, args:
2022/06/12 20:40:48 debug: Pwd
/home/amzon-ex
2022/06/12 20:40:48 Pwd duration: 471ns, args:
2022/06/12 20:40:48 debug: Getenv

2022/06/12 20:40:48 Getenv duration: 782ns, args: JAVA_HOME
2022/06/12 20:40:48 debug: Pwd
/home/amzon-ex
2022/06/12 20:40:48 Pwd duration: 480ns, args:
2022/06/12 20:40:48 GOOS duration: 30ns, args:
2022/06/12 20:40:48 debug: Pwd
/home/amzon-ex
2022/06/12 20:40:48 Pwd duration: 471ns, args:
2022/06/12 20:40:48 debug: Pwd
/home/amzon-ex
2022/06/12 20:40:48 Pwd duration: 1.252µs, args:
2022/06/12 20:40:48 GOOS duration: 30ns, args:
2022/06/12 20:40:48 debug: Pwd
/home/amzon-ex
2022/06/12 20:40:48 Pwd duration: 481ns, args:
2022/06/12 20:40:48 debug: Pwd
/home/amzon-ex
2022/06/12 20:40:48 Pwd duration: 711ns, args:
2022/06/12 20:40:48 GOOS duration: 30ns, args:
2022/06/12 20:40:48 debug: Pwd
/home/amzon-ex
2022/06/12 20:40:48 Pwd duration: 481ns, args:
2022/06/12 20:40:48 Flags duration: 30ns, args:
2022/06/12 20:40:48 debug: Pwd
/home/amzon-ex
2022/06/12 20:40:48 Pwd duration: 480ns, args:
2022/06/12 20:40:48 GOOS duration: 30ns, args:
2022/06/12 20:40:48 GOOS duration: 30ns, args:
2022/06/12 20:40:48 PathSeparator duration: 31ns, args:
2022/06/12 20:40:48 PathSeparator duration: 30ns, args:
2022/06/12 20:40:48 PathSeparator duration: 20ns, args:
2022/06/12 20:40:48 PathSeparator duration: 20ns, args:
2022/06/12 20:40:48 GOOS duration: 30ns, args:
2022/06/12 20:40:48 debug: Getenv
Ubuntu-20.04
2022/06/12 20:40:48 Getenv duration: 942ns, args: WSL_DISTRO_NAME
2022/06/12 20:40:48 IsWsl duration: 2.104µs, args:
2022/06/12 20:40:48 debug: RunCommand
//wsl.localhost/Ubuntu-20.04/home/amzon-ex
2022/06/12 20:40:48 RunCommand duration: 1.952961ms, args: wslpath -m /home/amzon-ex
2022/06/12 20:40:48 StackCount duration: 51ns, args:
2022/06/12 20:40:48 DirIsWritable duration: 3.156µs, args:
2022/06/12 20:40:48 TemplateCache duration: 60ns, args:
2022/06/12 20:40:48 TemplateCache duration: 90ns, args:
2022/06/12 20:40:48 Shell duration: 60ns, args:
2022/06/12 20:40:48 Flags duration: 40ns, args:
2022/06/12 20:40:48 debug: Pwd
/home/amzon-ex
2022/06/12 20:40:48 Pwd duration: 3.527µs, args:
2022/06/12 20:40:48 GOOS duration: 41ns, args:
2022/06/12 20:40:48 GOOS duration: 30ns, args:
2022/06/12 20:40:48 TemplateCache duration: 30ns, args:
2022/06/12 20:40:48 TemplateCache duration: 80ns, args:
2022/06/12 20:40:48 Shell duration: 50ns, args:
2022/06/12 20:40:48 debug: Pwd
/home/amzon-ex
2022/06/12 20:40:48 Pwd duration: 5.921µs, args:
2022/06/12 20:40:48 GOOS duration: 50ns, args:
2022/06/12 20:40:48 TemplateCache duration: 30ns, args:
2022/06/12 20:40:48 TemplateCache duration: 70ns, args:
2022/06/12 20:40:48 Shell duration: 60ns, args:
2022/06/12 20:40:48 debug: Getenv

2022/06/12 20:40:48 Getenv duration: 962ns, args: XDG_CACHE_HOME
2022/06/12 20:40:48 CachePath duration: 12.083µs, args:
2022/06/12 20:40:48 Flags duration: 20ns, args:
JanDeDobbeleer commented 2 years ago

@amzon-ex oh-my-posh itself literally takes 4ms so that's blazing fast. Which shell are you using? I'm assuming bash, but nothing really changed there either.

amzon-ex commented 2 years ago

Precisely. I don't see it in the log. I'm using bash.

JanDeDobbeleer commented 2 years ago

@amzon-ex are you using the Windows executable or the Linux one?

amzon-ex commented 2 years ago

Linux one. I followed the linux installation instructions. which oh-my-posh points to /usr/local/bin/oh-my-posh.

amzon-ex commented 2 years ago

Is there any other information I can provide to help you with this? This has become a trouble. I turned off oh-my-posh to check that my prompt becomes blazing fast again, so it's not any other issue I guess.

JanDeDobbeleer commented 2 years ago

@amzon-ex I have no immediate root cause in mind other than the executable being blocked in execution. Could it be WSL2 is somehow blocking it, or there's a mismatch between the Windows exe and the linux one? Can you rename the Linux executable and try that?

amzon-ex commented 2 years ago

I tried renaming, did not work. Interestingly, I chose an old version at random (v7.59.5 to be exact) and now the time's back to normal again :/

JanDeDobbeleer commented 2 years ago

I'll have a look at the diff between those.

JanDeDobbeleer commented 2 years ago

@amzon-ex I don't see anything odd in between those versions that could indicate a slowdown linked to something outside of the code (like the init script). Unless $BASH_VERSION doesn't resolve, I don't see what's causing the slowdown. Can you try upgrading bash?

amzon-ex commented 2 years ago

This might be a very naive question, but how do you update bash in WSL?

lewis-yeung commented 2 years ago

how do you update bash in WSL?

Taking Ubuntu as an example, a general way is sudo apt upgrade bash, just as in Linux.

amzon-ex commented 2 years ago

Oh I see, how silly of me. I think I didn't know it because I frequently update my packages, and bash never showed up in the update list.

In any case, I checked. bash is already at the latest version (5.1.16(1)).

kdpuvvadi commented 2 years ago

I can confirm this. when i tried this on ubuntu 20.04 & bash is 5.0.17. it's significantly slower than 22.04 with bash 5.1.16

JanDeDobbeleer commented 2 years ago

It's weird as I'm using bash on macOS and this isn't happening. I'll try to check on WSL2.

Shalankwa commented 2 years ago

I'm also experiencing slow performance when using oh-my-posh (v8.6.0) inside of WSL2 (ubuntu 22.04 - bash 5.1.16)

Powershell was also slightly slow as well, but excluding 'oh-my-posh.exe' from Window Security seemed to solve the issue. Not sure if the same is causing the prompt delay for WSL

JanDeDobbeleer commented 2 years ago

@Shalankwa can you try to exclude the unix binary as well?

Shalankwa commented 2 years ago

@JanDeDobbeleer Not sure if I understood properly, but I tried adding the oh-my-posh binary under the wsl distro, but I'm still seeing the same behaviour.

image

Short (simplet) description of what im experiencing: When executing commands, there is a large delay (in comparison to not using oh-my-posh) before the command finishes and the prompt returns. An easy test and is holding down 'enter' for a few seconds, then letting go. It will continue to enter newlines for a couple seconds after letting go due to the delay from oh-my-posh.

JanDeDobbeleer commented 2 years ago

@Shalankwa itvwas just a try. I'm grasping for straws here as I'm on the same version on macOS and everything works just fine. It's also not in the binary as that one displays a few milliseconds. Meaning it's environmental, which could be anything. There's also no difference on the script part when it comes to this version and one that's supposedly better, otherwise we'd easily find what's causing it. Somehow something is taking time and there are two possible causes:

Supposing you can run oh-my-posh from the CLI without slowdown (like debug for example), that rules out number 1. For 2 what we could do is add the full init script to .bashrc rather than the init command. You can get it using oh-my-posh init bash --printand then removing things until it's speedy again (reload the shell when you do at each step). Curious to understand the result.

Shalankwa commented 2 years ago

I copied the entire [init] script into the .bashrc and still getting the slowdown :( I'll mess around with it a bit more and see if I can narrow down anything

It looks like its coming from the executable, likely something from the OS. I'm still under the impression its Window Security... but not sure the best way to continue testing it.

I'll list my debug time here too if it helps:

shalankwa ❯ oh-my-posh debug

Version: 8.6.0

Segments:

ConsoleTitle(false)  -   0 ms -
path(true)           -   1 ms -  ~
git(false)           -   0 ms -
python(false)        -   0 ms -
go(false)            -   0 ms -
node(false)          -   0 ms -
ruby(false)          -   0 ms -
java(false)          -   0 ms -
julia(false)         -   0 ms -
battery(false)       -   0 ms -
executiontime(false) -   0 ms -
text(true)           -   0 ms - shalankwa ❯

Run duration: 3.282227ms

Cache path: /home/shalankwa

Config path: /home/shalankwa/.poshthemes/custom/purpleshell.json

Logs:

2022/06/24 23:26:24 debug: Getenv

2022/06/24 23:26:24 Getenv duration: 8.85µs, args: XDG_CACHE_HOME
2022/06/24 23:26:24 CachePath duration: 17.89µs, args:
2022/06/24 23:26:24 debug: Getenv
/home/shalankwa/.poshthemes/custom/purpleshell.json
2022/06/24 23:26:24 Getenv duration: 4.28µs, args: POSH_THEME
2022/06/24 23:26:24 resolveConfigPath duration: 6.54µs, args:
2022/06/24 23:26:24 Init duration: 79.95µs, args:
2022/06/24 23:26:24 Flags duration: 30ns, args:
2022/06/24 23:26:24 config.loadConfig duration: 531.479µs, args:
2022/06/24 23:26:24 Flags duration: 60ns, args:
2022/06/24 23:26:24 debug: Getenv

2022/06/24 23:26:24 Getenv duration: 7.83µs, args: OMP_CACHE_DISABLED
2022/06/24 23:26:24 Root duration: 460ns, args:
2022/06/24 23:26:24 Shell duration: 474.189µs, args:
2022/06/24 23:26:24 ErrorCode duration: 130ns, args:
2022/06/24 23:26:24 debug: Getenv
Ubuntu-22.04
2022/06/24 23:26:24 Getenv duration: 1.43µs, args: WSL_DISTRO_NAME
2022/06/24 23:26:24 IsWsl duration: 2.95µs, args:
2022/06/24 23:26:24 debug: Pwd
/home/shalankwa
2022/06/24 23:26:24 Pwd duration: 10.88µs, args:
2022/06/24 23:26:24 PathSeparator duration: 40ns, args:
2022/06/24 23:26:24 PathSeparator duration: 20ns, args:
2022/06/24 23:26:24 debug: User
shalankwa
2022/06/24 23:26:24 User duration: 810ns, args:
2022/06/24 23:26:24 debug: Host
Shallina
2022/06/24 23:26:24 Host duration: 1.45µs, args:
2022/06/24 23:26:24 GOOS duration: 40ns, args:
2022/06/24 23:26:24 TemplateCache duration: 524.159µs, args:
2022/06/24 23:26:24 Flags duration: 30ns, args:
2022/06/24 23:26:24 debug: Pwd
/home/shalankwa
2022/06/24 23:26:24 Pwd duration: 860ns, args:
2022/06/24 23:26:24 GOOS duration: 20ns, args:
2022/06/24 23:26:24 debug: Pwd
/home/shalankwa
2022/06/24 23:26:24 Pwd duration: 690ns, args:
2022/06/24 23:26:24 Flags duration: 30ns, args:
2022/06/24 23:26:24 debug: Pwd
/home/shalankwa
2022/06/24 23:26:24 Pwd duration: 620ns, args:
2022/06/24 23:26:24 GOOS duration: 20ns, args:
2022/06/24 23:26:24 GOOS duration: 30ns, args:
2022/06/24 23:26:24 PathSeparator duration: 20ns, args:
2022/06/24 23:26:24 PathSeparator duration: 30ns, args:
2022/06/24 23:26:24 PathSeparator duration: 30ns, args:
2022/06/24 23:26:24 PathSeparator duration: 20ns, args:
2022/06/24 23:26:24 GOOS duration: 30ns, args:
2022/06/24 23:26:24 debug: Getenv
Ubuntu-22.04
2022/06/24 23:26:24 Getenv duration: 820ns, args: WSL_DISTRO_NAME
2022/06/24 23:26:24 IsWsl duration: 2.02µs, args:
2022/06/24 23:26:24 debug: RunCommand
//wsl.localhost/Ubuntu-22.04/home/shalankwa
2022/06/24 23:26:24 RunCommand duration: 1.175102ms, args: wslpath -m /home/shalankwa
2022/06/24 23:26:24 StackCount duration: 40ns, args:
2022/06/24 23:26:24 DirIsWritable duration: 2.83µs, args:
2022/06/24 23:26:24 TemplateCache duration: 40ns, args:
2022/06/24 23:26:24 TemplateCache duration: 140ns, args:
2022/06/24 23:26:24 Shell duration: 60ns, args:
2022/06/24 23:26:24 debug: Pwd
/home/shalankwa
2022/06/24 23:26:24 Pwd duration: 1.28µs, args:
2022/06/24 23:26:24 GOOS duration: 30ns, args:
2022/06/24 23:26:24 debug: Getenv
Ubuntu-22.04
2022/06/24 23:26:24 Getenv duration: 880ns, args: WSL_DISTRO_NAME
2022/06/24 23:26:24 IsWsl duration: 2.33µs, args:
2022/06/24 23:26:24 debug: Pwd
/home/shalankwa
2022/06/24 23:26:24 Pwd duration: 620ns, args:
2022/06/24 23:26:24 GOOS duration: 30ns, args:
2022/06/24 23:26:24 HasCommand duration: 6.9µs, args: git
2022/06/24 23:26:24 debug: Pwd
/home/shalankwa
2022/06/24 23:26:24 Pwd duration: 620ns, args:
2022/06/24 23:26:24 error: HasParentFilePath
stat /.git: no such file or directory
2022/06/24 23:26:24 HasParentFilePath duration: 6.12µs, args: .git
2022/06/24 23:26:24 debug: Pwd
/home/shalankwa
2022/06/24 23:26:24 Pwd duration: 780ns, args:
2022/06/24 23:26:24 GOOS duration: 20ns, args:
2022/06/24 23:26:24 debug: Pwd
/home/shalankwa
2022/06/24 23:26:24 Pwd duration: 710ns, args:
2022/06/24 23:26:24 debug: Getenv

2022/06/24 23:26:24 Getenv duration: 860ns, args: VIRTUAL_ENV
2022/06/24 23:26:24 debug: Getenv

2022/06/24 23:26:24 Getenv duration: 770ns, args: CONDA_ENV_PATH
2022/06/24 23:26:24 debug: Getenv

2022/06/24 23:26:24 Getenv duration: 870ns, args: CONDA_DEFAULT_ENV
2022/06/24 23:26:24 debug: Pwd
/home/shalankwa
2022/06/24 23:26:24 Pwd duration: 730ns, args:
2022/06/24 23:26:24 GOOS duration: 30ns, args:
2022/06/24 23:26:24 debug: Pwd
/home/shalankwa
2022/06/24 23:26:24 Pwd duration: 640ns, args:
2022/06/24 23:26:24 debug: Pwd
/home/shalankwa
2022/06/24 23:26:24 Pwd duration: 790ns, args:
2022/06/24 23:26:24 GOOS duration: 30ns, args:
2022/06/24 23:26:24 debug: Pwd
/home/shalankwa
2022/06/24 23:26:24 Pwd duration: 640ns, args:
2022/06/24 23:26:24 debug: Pwd
/home/shalankwa
2022/06/24 23:26:24 Pwd duration: 740ns, args:
2022/06/24 23:26:24 GOOS duration: 20ns, args:
2022/06/24 23:26:24 debug: Pwd
/home/shalankwa
2022/06/24 23:26:24 Pwd duration: 650ns, args:
2022/06/24 23:26:24 debug: Getenv

2022/06/24 23:26:24 Getenv duration: 860ns, args: JAVA_HOME
2022/06/24 23:26:24 debug: Pwd
/home/shalankwa
2022/06/24 23:26:24 Pwd duration: 680ns, args:
2022/06/24 23:26:24 GOOS duration: 30ns, args:
2022/06/24 23:26:24 debug: Pwd
/home/shalankwa
2022/06/24 23:26:24 Pwd duration: 650ns, args:
2022/06/24 23:26:24 debug: Pwd
/home/shalankwa
2022/06/24 23:26:24 Pwd duration: 750ns, args:
2022/06/24 23:26:24 GOOS duration: 30ns, args:
2022/06/24 23:26:24 debug: Pwd
/home/shalankwa
2022/06/24 23:26:24 Pwd duration: 700ns, args:
2022/06/24 23:26:24 debug: Pwd
/home/shalankwa
2022/06/24 23:26:24 Pwd duration: 740ns, args:
2022/06/24 23:26:24 GOOS duration: 30ns, args:
2022/06/24 23:26:24 debug: Getenv
Ubuntu-22.04
2022/06/24 23:26:24 Getenv duration: 920ns, args: WSL_DISTRO_NAME
2022/06/24 23:26:24 IsWsl duration: 2.02µs, args:
2022/06/24 23:26:24 debug: Getenv
Ubuntu-22.04
2022/06/24 23:26:24 Getenv duration: 730ns, args: WSL_DISTRO_NAME
2022/06/24 23:26:24 IsWsl duration: 1.73µs, args:
2022/06/24 23:26:24 debug: FileContent
5.10.102.1-microsoft-standard-WSL2

2022/06/24 23:26:24 FileContent duration: 31.86µs, args: /proc/sys/kernel/osrelease
2022/06/24 23:26:24 IsWsl2 duration: 37.61µs, args:
2022/06/24 23:26:24 BatteryInfo duration: 15.54µs, args:
2022/06/24 23:26:24 Flags duration: 50ns, args:
2022/06/24 23:26:24 debug: Pwd
/home/shalankwa
2022/06/24 23:26:24 Pwd duration: 830ns, args:
2022/06/24 23:26:24 GOOS duration: 40ns, args:
2022/06/24 23:26:24 ExecutionTime duration: 50ns, args:
2022/06/24 23:26:24 debug: Pwd
/home/shalankwa
2022/06/24 23:26:24 Pwd duration: 750ns, args:
2022/06/24 23:26:24 GOOS duration: 20ns, args:
2022/06/24 23:26:24 TemplateCache duration: 50ns, args:
2022/06/24 23:26:24 TemplateCache duration: 160ns, args:
2022/06/24 23:26:24 Shell duration: 60ns, args:
2022/06/24 23:26:24 debug: Getenv

2022/06/24 23:26:24 Getenv duration: 1.1µs, args: XDG_CACHE_HOME
2022/06/24 23:26:24 CachePath duration: 6.09µs, args:
2022/06/24 23:26:24 Flags duration: 30ns, args:
Shalankwa commented 2 years ago

Strange thing I noticed was using bash terminal inside Vscode was much faster than inside windows terminal. Definitly some strange Windows->wsl behaviour...

[edit] I ran windows terminal [wsl - ubuntu 22.04 - bash] without running as administrator and the prompt load time was much faster, but still a slight delay, much more managable though.

JanDeDobbeleer commented 2 years ago

@Shalankwa this thread has some interesting information you could maybe have a look at.

Shalankwa commented 2 years ago

👍 Yes this definitly worked. Seems like the pathing for windows slows down the execution a significant amount. Thanks for hunting this down. Sorry if this was ultimately the wrong thread to post this in.

kdpuvvadi commented 2 years ago

After trying this , i just found out that if your windows username has any spaces in in it( on of my pc has username "KD Puvvadi" and all others have "kd") it also slows down things). removed spaces and uncommented appendWindowsPath=false it''s faster now. it was taking 7 seconds to load but now it around 2s, still slower but it's an improvement though . commenting out nvm in the .bashrc wasn't helpful though.

JanDeDobbeleer commented 2 years ago

@kdpuvvadi 2 seconds is still really long (unless oh-my-posh debug has some information).

aradalvand commented 2 years ago

Hi there. First of all, thank you for this phenomenal tool, the idea behind it is actually really brilliant. And it's also very well executed. So well done!

I can confirm this problem on WSL2 (Ubuntu 20.04, Bash 5.0), I also experienced this issue on Windows PowerShell but it was solved by adding the oh-my-posh.exe binary as an exclusion in Windows Defender.

On WSL however, I'm still struggling with this issue, I tried adding the Linux binary as an exclusion to Windows Defender, and it didn't work.

oh-my-posh debug shows a total execution time of 10ms or below, consistently.

I also directly put the script (output of oh-my-posh init bash --print) inside the .bashrc file as per @JanDeDobbeleer's suggestion in this comment, but it had zero effect.

The strange thing is that this even seems to slow down the execution of commands — which wasn't the case in PowerShell — a simple ls in a small directory for example, which would otherwise other be instantaneous, has a noticeable delay.

Note that as soon as I remove anything oh-my-posh-related from .bashrc, the performance goes back to normal and it's all as quick and snappy as possible.

Update: Just tried the suggestion in this comment and it actually worked, strangely enough. The prompt now appears as fast as expected. Anybody has any idea why?!

amzon-ex commented 2 years ago

If any of these two are the reason, I wonder why it didn't happen with older versions of oh-my-posh? I'm still using an older version like a breeze.

kdpuvvadi commented 2 years ago

tried omp on fresh install rhel, it's snappy as always. installed on fresh install of rocky linux on wsl it took around 7 seconds. i think it has something to do with windows file system. so, unmounted everything of windows and it's back to normal.

aaronecgberht commented 2 years ago

windows opens oh-my-posh quite slowlyy 屏幕截图 2022-06-26 212518

JanDeDobbeleer commented 2 years ago

@aaronecgberht that's PowerShell starting slow, not oh-my-posh.

amzon-ex commented 2 years ago

@Shalankwa this thread has some interesting information you could maybe have a look at.

I tried this out (I'm on zsh currently) and it works with the latest version of oh-my-posh. But now I'd have to add these paths back manually, I guess...

JanDeDobbeleer commented 2 years ago

I'm, moving this to a discussion as there's nothing much I can do on my end.