Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

posh-git is still too slow... #78

Closed
tgoeke opened this issue Feb 9, 2013 · 23 comments
Closed

posh-git is still too slow... #78

tgoeke opened this issue Feb 9, 2013 · 23 comments

Comments

@tgoeke
Copy link

tgoeke commented Feb 9, 2013

I'm trying out posh-git, but it's still too slow. How do I uninstall it?

@JayBazuzi
Copy link
Collaborator

If you're in a large repo, you probably want to set:

PS> $GitPromptSettings.EnableFileStatus = $false

@dahlbyk
Copy link
Owner

dahlbyk commented Feb 9, 2013

Or to disable it completely, just remove the posh-git line from your $PROFILE with a text editor.

@dahlbyk
Copy link
Owner

dahlbyk commented Feb 9, 2013

You can also selectively disable file status only for your slow repositories:

$GitPromptSettings.RepositoriesInWhichToDisableFileStatus += 'C:\Path\To\Project'

@atbussma
Copy link

atbussma commented Dec 5, 2014

Reviving this thread as I'm getting bitten by this now. I'd like to keep using file status and I'm wondering whether a simpler solution than async is to use filesystem notifications or just limiting the number of file status requests within a specific period of time (caching)? I'm curious to know whether anyone has thought more about this and potential solutions? Would there be any potential benefit to testing out a couple of these options, or has the community moved on from this tool?

@dahlbyk
Copy link
Owner

dahlbyk commented Dec 8, 2014

There have been a few attempts at this... #52 (cache), #104 (async write to console buffer), #145 (https://github.com/fieryorc/gitprompt, a daemon to do the status monitoring). Of the three, I think the last will yield the best user experience - try @fieryorc's fork: https://github.com/fieryorc/posh-git? I regret that I haven't had time to try it myself.

@ghostsquad
Copy link

I'm guessing that this still has not been implemented?

@dahlbyk
Copy link
Owner

dahlbyk commented Aug 25, 2015

I'm guessing that this still has not been implemented?

You guess correctly. However, #208 just dropped and it's looking very promising!

@edclement
Copy link

removing this line:
$stashCount = $null | git stash list 2>$null | measure-object | select -expand Count
from GitUtils.ps1 solved the issue for me. It cut 3 seconds off the prompt return time. Considering that git stash status is disabled by default with posh git, I don't understand why this command is always run anyway....

@ghostsquad
Copy link

the pipeline is slow. Any areas that can be converted to use standard loops and .NET classes would significantly improve performance.

@Mellbourn
Copy link

@edclement excellent workaround! That increased the performance for me from unacceptable to no problem at all.

@DoCode
Copy link

DoCode commented Oct 6, 2015

posh-git is still slow on tab completion!
Guys, we must investing in libgit2sharp integration!

@Tavriets
Copy link

Tavriets commented Oct 8, 2015

Adding --untracked-files=no (or just -uno) to the git -c color.status=false status --short --branch in GitUtils.ps1 mentioned by @edclement, makes it much faster for me.

@ghostsquad
Copy link

@edclement - not sure if your workaround is even valid. if StashStatus is disabled, that line won't execute.

@edclement
Copy link

@ghostsquad - removing that line from the 0.4.0 release (the latest tagged version) definitely fixed the issue for me. That was the only thing I changed.
looking at the code in that tagged version:

if($settings.EnableFileStatus -and !$(InDisabledRepository)) {
    dbg 'Getting status' $sw
    $status = git -c color.status=false status --short --branch 2>$null
    #$stashCount = $null | git stash list 2>$null | measure-object | select -expand Count
} else {
    $status = @()
}

I don't see why that command wouldn't execute...

@ghostsquad
Copy link

oh oh, sorry, we were looking at different versions. I'm running straight from the master branch.

@serbrech
Copy link

@edclement 👍 worked for me, this makes it good enough to work with for me too

@dahlbyk
Copy link
Owner

dahlbyk commented Dec 31, 2016

Between #319 and #208 we should be in a better spot performance-wise. I'm going to go ahead an close this, but do keep an eye out for an upcoming release with those improvements and leave a note if you're still having issues.

@cawoodm
Copy link

cawoodm commented Oct 23, 2021

What IS slow is having Posh in your profile - it adds about 2s to the already 2s startup of PowerShell 7 so it's really noticeable.

Loading personal and system profiles took 1907ms.

Is there something we can do? And how can we update?

@dahlbyk
Copy link
Owner

dahlbyk commented Oct 23, 2021

What IS slow is having Posh in your profile - it adds about 2s to the already 2s startup of PowerShell 7 so it's really noticeable.

Loading personal and system profiles took 1907ms.

Is there something we can do? And how can we update?

This issue was specifically about performance of the actual prompt status every time you hit enter, but I agree the module should be able to load faster. If you wanted to take a stab at optimizing it, I'd mimic how we figured out where the prompt was slow:

posh-git/src/GitUtils.ps1

Lines 245 to 247 in 5a87e8a

if ($settings.Debug) {
$sw = [Diagnostics.Stopwatch]::StartNew(); Write-Host ''
}

image

@ZhangTianrong
Copy link

ZhangTianrong commented Nov 23, 2023

I was optimizing the load time of my profile and surprisingly Import-Module posh-git is taking close to 0.5 second while my entire profile is taking 0.9 second. That is more than the 0.2 second taken by the already slow oh-my-posh or conda activate base. If you only need tab completion, I would suggest you look at carapace which loads much faster.

@Ramin2c
Copy link

Ramin2c commented Apr 26, 2024

$GitPromptSettings.EnableFileStatus = $false

Mine was initially true, but setting it once to false and back to true again just fixed my slowness problem.

@ilpssun
Copy link

ilpssun commented Jan 15, 2025

@Ramin2c Thanks so much for this advice. Loading posh-git from my profile took almost 6 seconds. Changing the FileStatus parameter to false and back to true reduced the loading time to under 1 second. No idea why, but so much better 😃

@Ramin2c
Copy link

Ramin2c commented Jan 15, 2025

@Ramin2c Thanks so much for this advice. Loading posh-git from my profile took almost 6 seconds. Changing the FileStatus parameter to false and back to true reduced the loading time to under 1 second. No idea why, but so much better 😃

Don't worry, no one knows why such so-called fix works, but glad I could help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests