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

Lag returning to prompt (especially) in git repo #447

Closed
Keilan opened this Issue Mar 30, 2015 · 24 comments

Comments

Projects
None yet
@Keilan

Keilan commented Mar 30, 2015

When using cmder with git (where it shows the name of my currently checked out branch next to the location), I'm finding that my commands are executed quickly but there is a major delay returning to the prompt so I can enter in another command. I notice this to some extent when I'm not in a git repo, but then the delay is almost not noticeable (100-200ms I'd guess), as opposed to 1-2 seconds in a repo.

To give further details, in my repo if I type ls, the file list comes up immediately, then the current tab changes from saying "cmd.exe" to "git.exe", and only after 1-2 seconds do I get a lambda prompt again where I can enter further commands.

I'm running Windows 8.1 and cmder.exe is installed in Program Files. Let me know if any more details would be helpful.

@Jackbennett

This comment has been minimized.

Contributor

Jackbennett commented Mar 31, 2015

This is some problem with git, with that in mind could you just try to use some git command from a shell that isn't cmder/conemu. Just maybe commands like git status and checkout a couple of branches and status there.

If git runs that fast it must be something in cmders prompt function trying to write the status line before returning. I've found having the git status line in the prompt does have a performance hit in the tenth of a second order you describe. Any prompt function that is not just a cmder thing.

@Keilan

This comment has been minimized.

Keilan commented Mar 31, 2015

Hey Jack, thanks for the response. I opened Cmder and a standard windows Command Prompt and navigated to the same directory, results as follows:

Windows Cmd: ~1 second delay before git status output appears, prompt reappears immediately
Cmder: ~1 second delay before git status output appears, plus a roughly 1 second delay before prompt reappears

This is consistent with the ls output, where windows cmd is instant, and with Cmder the output is instant but there is a ~1 second delay before the prompt reappears. It seems like Cmder is running the given command as expected, but then doing something else that is causing a delay. Is there some sort of update function called when in a git repo? That would make sense given that even a non-git command such as ls results in a delay coming from git.exe.

@Jackbennett

This comment has been minimized.

Contributor

Jackbennett commented Mar 31, 2015

When the git prompt adds to the end of that line the branch / numbers e.g [master 0 +1 0] it's just formatting its own call to git status.

From what you describe I think you've got a slow git repository. You'd best find out how you could speed it up. I could just be sheer size. I'm sure there's some tweaks to make windows faster with git.

To immediately speed that up you could remove the git parts of the prompt function cmder is calling.

@Jackbennett

This comment has been minimized.

Contributor

Jackbennett commented Mar 31, 2015

Learning some new stuff myself here, This first answer seems like some solid advice. Check the git manual first though to see what these commands really do to your repo.

http://stackoverflow.com/questions/4485059/git-bash-is-extremely-slow-in-windows-7-x64

@Keilan

This comment has been minimized.

Keilan commented Mar 31, 2015

Thanks Jack, that is indeed the issue - applying the 3 settings mentioned in that SO question improved it quite a bit (I'd estimate the delay is down to 300-400ms from 1-1.5 seconds). I might look into removing the "git status" part of the prompt, as it is much more usable now, 300-400ms is still a bit much. Do you know if a setting exists for that? Or will I have to edit the source?

Anyways, marking this as closed, as the call to git status explains the issue. Thanks!

@Keilan Keilan closed this Mar 31, 2015

@vladimir-kotikov

This comment has been minimized.

Contributor

vladimir-kotikov commented Mar 31, 2015

@Keilan you can try to replace if...end block here: https://github.com/bliker/cmder/blob/master/config/git.lua#L35 with the following line
color = colors.clean
This will decrease delays twice, but you will lose colored branch name depending on repo status.

@Jackbennett

This comment has been minimized.

Contributor

Jackbennett commented Mar 31, 2015

I will try to add some kind of setting to flip this in the powershell side of the console for a future release. Probably not the next release though. At least git is faster now.

@ritave

This comment has been minimized.

ritave commented Aug 16, 2016

I'd like to have an option to disable git showing anything on the prompt. It still slow on some occasions.

@xseneque

This comment has been minimized.

xseneque commented Aug 30, 2016

I'd also like a way to disable git looking at my current repo as it gives me 30+ sec delay. It's a massive repo. I really don't care about it telling me i'm in the master branch.

How can I disable any git stuff. I just want a command prompt.

@schmich

This comment has been minimized.

schmich commented Aug 31, 2016

I'm in the same boat as @xseneque. I have a large repo where git status takes around a second, so running any commands under the repo just kills all flow.

I'd really like to disable git integration. Is there any simple workaround for now, or do we have to wait for a release?

@justaniles

This comment has been minimized.

justaniles commented Sep 1, 2016

After some searching, I've been able to remove git integration in the prompt, resulting in no lag when inputting commands in a git repo! The following modifications must be done to your cmder/vender/clink.lua file:

On line 41, remove {git}{hg} to prevent git/mercurial branch from being printed in your prompt:

local cmder_prompt = "\x1b[1;32;40m{cwd}\n\x1b[1;30;40m{lamb} \x1b[0m"

Comment out lines 266-267 to prevent git and mercurial plugins from running every time you press enter:

--clink.prompt.register_filter(hg_prompt_filter, 50)
--clink.prompt.register_filter(git_prompt_filter, 50)

As a note, you may want to back up this clink.lua file somewhere, in case it gets overridden after a cmder update.

Hope this helps!

@schmich

This comment has been minimized.

schmich commented Sep 1, 2016

@justaniles Awesome, that's exactly what I was looking for, thanks for the help!

@jankatins

This comment has been minimized.

Contributor

jankatins commented Sep 1, 2016

So what should the actual solution be here? If it should be per repo, we need to write something to the .git\ folder?

So something like this:

if not clink.get_env('CMDER_DISABLE_SCM_PROMPT') then
   -- find git dir ...
   if not git_dir_contains('cmder_disable_git_prompt') then
       -- replace {git} with the right things -> old stuff
       return
   end
end
-- replace {git} with ""
@xseneque

This comment has been minimized.

xseneque commented Sep 2, 2016

Thanks @justaniles ; works like a charm!!

@valix85

This comment has been minimized.

valix85 commented Mar 23, 2017

Hi guys, I have same problem... every git command spend a lot of seconds to end and return to input. I come back to windows cmd for now... I'm waiting for update.

@DaveInCaz

This comment has been minimized.

DaveInCaz commented Dec 21, 2017

Is this post still the most up to date advice for this? Is there a configuration option to remove the SCM details from the prompt?

@mloskot

This comment has been minimized.

mloskot commented Apr 10, 2018

In the traditional cmd with clink, there are two git look-ups run in clink.lua to refresh the prompt:

  • get_git_branch - fast, reads .git/HEAD
  • get_git_status - slow, git status which is used to decide about dirty/clean colourisation. In the whole git repo of Boost, this one takes annoyingly long time.

So, instead of disabling git information in the prompt completely, some may prefer to just get rid of the detailed/coloured status, keeping the current branch info:

λ diff -Nua c:\apps\cmder_mini\vendor\clink.lua.original c:\apps\cmder_mini\vendor\clink.lua
--- c:\apps\cmder_mini\vendor\clink.lua.original        2018-04-09 09:54:20.468732700 +0200
+++ c:\apps\cmder_mini\vendor\clink.lua 2018-04-10 08:39:57.809013700 +0200
@@ -263,11 +263,12 @@
         local color
         if branch then
             -- Has branch => therefore it is a git folder, now figure out status
-            if get_git_status() then
-                color = colors.clean
-            else
-                color = colors.dirty
-            end
+            -- XXX: Disable git status due to lag in large repo
+            -- if get_git_status() then
+                 color = colors.clean
+            -- else
+            --     color = colors.dirty
+            -- end

             clink.prompt.value = string.gsub(clink.prompt.value, "{git}", color.."("..branch..")")
             return false

Kudos to #447 (comment) for inspiration.

@DaveInCaz

This comment has been minimized.

DaveInCaz commented Apr 16, 2018

Note that this issue seems to be just as much of a problem for Mercurial as for git.

Probably the above workaround (#447 (comment)) indicates why.

@DGalt

This comment has been minimized.

DGalt commented Apr 27, 2018

Are there a different set of instructions for disabling the git status in a PowerShell prompt? Find myself using PS more than cmd.exe, but the fix provided in #447 doesn't seem to work for PS.

@mloskot

This comment has been minimized.

mloskot commented Apr 27, 2018

@DGalt Try this

  • edit vendor\profile.ps1
  • find this bit
[ScriptBlock]$CmderPrompt = {
    $Host.UI.RawUI.ForegroundColor = "White"
    Microsoft.PowerShell.Utility\Write-Host $pwd.ProviderPath -NoNewLine -ForegroundColor Green
    checkGit($pwd.ProviderPath)
}
  • remove checkGit($pwd.ProviderPath)
  • save and relaunch cmder
@DGalt

This comment has been minimized.

DGalt commented Apr 27, 2018

@mloskot perfect, thank you!

@SidShetye

This comment has been minimized.

SidShetye commented Jun 7, 2018

Can the dev re-open this issue? It's still a problem and all 'fixes' here are overwritten on an update. This belongs somewhere in settings than hardcoded in a profile.ps1 script.

@loshjawrence

This comment has been minimized.

loshjawrence commented Jul 30, 2018

Just discovered cmder today and downloaded to try it out. Ran into this issue in a large git repo (not all repo's do this). Every command is slow returning to the lambda prompt in the repo not just git commands. Tried all these fixes to no avail. Other terminal types (::bash ::mintty ::Powershell) don't have this issue. Very frustrating, feel like I'm being trolled by the terminal. Otherwise very useful program (love the fact there's no install and its portable).

@mahsanshaikh

This comment has been minimized.

mahsanshaikh commented Sep 7, 2018

@mloskot Solution works for me. Great thanks man.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment