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

Slow on startup #1122

Closed
lamarqua opened this issue Oct 9, 2016 · 7 comments
Closed

Slow on startup #1122

lamarqua opened this issue Oct 9, 2016 · 7 comments

Comments

@lamarqua
Copy link
Contributor

lamarqua commented Oct 9, 2016

On my machine, a vanilla installation of Cmder takes >5s to startup compared to the instantaneous ConEmu.
I tried disabling everything in the init.bat script but it didn't really make a difference.

@daxgames
Copy link
Member

daxgames commented Oct 9, 2016

If you disable everything in init.bat why use cmder then? Cmder is a set of tools including ConEmu that together is an enhanced version of the windows cmd shell and the init.bat is what handles loading those enhancements.

First time launch is slower because some cfg files are initialized. Launch will always be SLIGHTLY slower because it is not vanilla cmd.exe but should not be impactful. Second launch on my system takes under a second.

@lamarqua
Copy link
Contributor Author

lamarqua commented Oct 9, 2016

If you disable everything in init.bat why use cmder then? Cmder is a set of tools including ConEmu that together is an enhanced version of the windows cmd shell and the init.bat is what handles loading those enhancements.

I already know that, I am not stupid. I disabled it temporarily to see if that would make a difference on startup.

First time launch is slower because some cfg files are initialized. Launch will always be SLIGHTLY slower because it is not vanilla cmd.exe but should not be impactful. Second launch on my system takes under a second.

Not the case for me: it consistently takes ~5 seconds to launch. Once it is launched, creating a new cmd.exe shell (for example) in a tab or a window is quick.

Note that I am not talking about the first launch after installation, but every launch of a new instance of cmder.exe.

It strikes me as a serious performance problem, since the launcher doesn't need that long to do its job and defers to ConEmu for the rest, and ConEmu launches quickly on its own. I'm willing to help investigate it however I can.

@lamarqua
Copy link
Contributor Author

lamarqua commented Oct 9, 2016

Precisions: my machine is an Core 2 Duo E8400 running Win7 Family SP1. Cmder is installed on an SSD.

I'm gonna go ahead and see what I can understand on my own, but I'd appreciate any ideas about why this is so slow.

@kn0rki
Copy link

kn0rki commented Oct 9, 2016

Hi,

maybe a virus scanner problem?
Try to look with procmon, whats going on when cmder.exe starts

Procmon

@lamarqua
Copy link
Contributor Author

lamarqua commented Oct 11, 2016

Found the problem:
https://github.com/cmderdev/cmder/blob/master/launcher/src/CmderLauncher.cpp#L172
The culprit "non-answering" process is akamai's netsession_win.exe. They don't offer it as stand-alone download - it's usually bundled with something else and I can't exactly remember what on my machine.
Unfortunately there's little we can do against netsession_win.exe being slow to process its messages (AFAIK the process does process the message, but very slowly - around 2.2 seconds per SendMessageTimeout. I don't know why). But there are different approaches to solving that problem:

  1. Create the child ConEmu process before the SendMessageTimeouts. The child process inherits the parent's Environment block (as per MSDN) so this works.
  2. I'm not sure exactly why we need to broadcast an update everytime, even when no ConEmu window is open. So conditioning the SendMessageTimeout to the presence of a ConEmu top-level window could be one partial solution. (Using EnumWindow to list all top level windows.) Alas, the WM_SETTINGCHANGE message has to be broadcasted in case of update per MSDN's documentation.
    2bis. Another solution would be to use SendMessageCallback which is asynchronous.
  3. Lowering the timeout value. 5 seconds seems arbitrarily high, setting to a lower value could help cut away some of the wait.

I already implemented solution 1 (just rearranging the call to CreateProcess before the SendMessageTimeout) and it's much better for me. Please let me know if you want the pull request. I can also implement any other solution if necessary.

@luastoned
Copy link

luastoned commented Oct 14, 2016

Just updated Cmder today and I'm seeing the same issue. 5+ seconds on startup.

@Stanzilla
Copy link
Member

@lamarqua yes, a PR would be great

lamarqua added a commit to lamarqua/cmder that referenced this issue Oct 14, 2016
Fixes cmderdev#1122 by simply calling CreateProcess before the SendMessageTimeout
calls that are used to propagate environment variable changes.
Stanzilla added a commit that referenced this issue Oct 17, 2016
Fix for slow startup under certain conditions (#1122)
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

5 participants