Closed amzon-ex closed 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.
Precisely. I don't see it in the log. I'm using bash.
@amzon-ex are you using the Windows executable or the Linux one?
Linux one. I followed the linux installation instructions. which oh-my-posh
points to /usr/local/bin/oh-my-posh
.
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.
@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?
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 :/
I'll have a look at the diff between those.
@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?
This might be a very naive question, but how do you update bash in WSL?
how do you update bash in WSL?
Taking Ubuntu as an example, a general way is sudo apt upgrade bash
, just as in Linux.
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)).
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
It's weird as I'm using bash on macOS and this isn't happening. I'll try to check on WSL2.
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
@Shalankwa can you try to exclude the unix binary as well?
@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.
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.
@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 --print
and then removing things until it's speedy again (reload the shell when you do at each step). Curious to understand the result.
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:
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.
@Shalankwa this thread has some interesting information you could maybe have a look at.
👍 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.
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.
@kdpuvvadi 2 seconds is still really long (unless oh-my-posh debug has some information).
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?!
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.
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.
windows opens oh-my-posh quite slowlyy
@aaronecgberht that's PowerShell starting slow, not oh-my-posh.
@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...
I'm, moving this to a discussion as there's nothing much I can do on my end.
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
What OS are you seeing the problem on?
Linux
Which shell are you using?
bash
Log output