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

ConEmu makes console app take more time to be executed (Very slow running batch files / commands) #526

Closed
Maximus5 opened this issue Jul 31, 2015 · 25 comments

Comments

@Maximus5
Copy link
Owner

Originally reported on Google Code with ID 526

Required information!
OS version: Win7 x64
ConEmu version: 120417
Far version: 2.1.1807 bis27 x86 

*Bug description*
When starting several console applications from a .bat file, this .bat file takes more
time under FAR+ConEmu than under pure FAR to be executed.

*Steps to reproduction*
1. Create the following .bat file:

@echo off
REG /? >nul
REG QUERY /? >nul
REG ADD /? >nul
REG DELETE /? >nul
REG COPY /? >nul
REG SAVE /? >nul
REG RESTORE /? >nul
REG LOAD /? >nul
REG UNLOAD /? >nul
REG COMPARE /? >nul
REG EXPORT /? >nul
REG IMPORT /? >nul
REG FLAGS /? >nul
REG /? >nul
REG QUERY /? >nul
REG ADD /? >nul
REG DELETE /? >nul
REG COPY /? >nul
REG SAVE /? >nul
REG RESTORE /? >nul
REG LOAD /? >nul
REG UNLOAD /? >nul
REG COMPARE /? >nul
REG EXPORT /? >nul
REG IMPORT /? >nul
REG FLAGS /? >nul

2. Start this .bat file under pure FAR - it takes about a second to be executed

3. Start this .bat file under FAR+ConEmu - it takes several seconds to be executed.
This is strange because this .bat file does not output anything!
You'll have much worse results if you create a .bat file which runs WGET several times
to download several files.

Reported by dvv81gm on 2012-04-18 11:29:12

@Maximus5
Copy link
Owner Author

Several? 3-4? It means conemu makes delay of 150ms per application start/terminate.
I don't think, that it is expensive.

Reported by ConEmu.Maximus5 on 2012-04-18 13:21:26

@Maximus5
Copy link
Owner Author

I have one script which parses a text file for URLs, and calls external program for
each URL to calculate sha1 hash and then write the hash into output file.
There are about 20 URLs there. I wondered why the script took so long to be executed
(about 5 seconds under FAR+ConEmu) until I run it via Shift+Enter and ensured it takes
less than a second. And Enter under FAR without ConEmu gives almost the same time (about
a second).
When you need to run such script again and again, several additional seconds are important.

Reported by dvv81gm on 2012-04-18 14:49:28

@Maximus5
Copy link
Owner Author

Did you compare times with cmd32 or cmd64?
Are there difference between them?

Reported by ConEmu.Maximus5 on 2012-04-18 16:32:37

@Maximus5
Copy link
Owner Author

I don't know. But I've just tried the first example (a .bat file with a lot of REG ...
/? >nul) under Windows XP 32 bit and:
- under FAR+ConEmu (via Enter) it takes about 4 seconds
- via Shift+Enter it takes less than a second, almost instantly!
- under FAR without ConEmu (via Enter) it's also almost instantly.
So...

Reported by dvv81gm on 2012-04-18 17:51:12

@Maximus5
Copy link
Owner Author

Check 120418, any changes?

Reported by ConEmu.Maximus5 on 2012-04-18 18:26:25

@Maximus5
Copy link
Owner Author

Unfortunately, I don't see noticeable changes. Still 3-4 seconds under FAR+ConEmu vs.
less than a second under pure FAR. Don't you reproduce it on your PC?
But anyway, why so long? Even if ConEmu for some reason needs additional, say, 0.5
seconds to start/initiate execution of the .bat file, it would take less than (1 +
0.5) seconds in total, not 3-4 seconds. So what happens?

Reported by dvv81gm on 2012-04-18 19:02:54

@Maximus5
Copy link
Owner Author

Start/initiate - yes, .bat file - no.
This initialization is performed for _each_ console program, reg.exe in this case.

I have 7 seconds in conemu, and 5 seconds in pure cmd.

You may eliminate this initialization by removing check from "Inject ConEmuHk" option,
"Features" page.
But! This may cause unpredictable errors or problems.

ConEmu must monitor and handle all console applications, started in its tabs. ConEmuHk
takes care of this.

Reported by ConEmu.Maximus5 on 2012-04-18 19:17:35

@Maximus5
Copy link
Owner Author

Ah, that's what I was starting to think about... So, maybe, it would be good to have
an option to enable hooking just for root processes which are started from FAR, and
not for child processes of those root processes? I.e. cmd.exe (which executes the .bat
file) becomes hooked, but reg.exe does not (because it is started from cmd.exe and
not from FAR itself)?

Reported by dvv81gm on 2012-04-18 19:50:11

@Maximus5
Copy link
Owner Author

In fact, root process is infiltrated always, regardless of "Inject" checkbox state.
2-nd level processes (child of far.exe) are infiltrated when "Inject" OR "Long console
output" are checked.

Generally, I do not recommend to removing check from "Inject ConEmuHk", but you can
do so on your's head.

Reported by ConEmu.Maximus5 on 2012-04-18 22:07:43

@Maximus5
Copy link
Owner Author

Issue 585 has been merged into this issue.

Reported by ConEmu.Maximus5 on 2012-10-28 13:30:35

@Maximus5
Copy link
Owner Author

Reported by ConEmu.Maximus5 on 2012-10-28 13:31:03

  • Status changed: Started

@Maximus5
Copy link
Owner Author

Check 121028

Reported by ConEmu.Maximus5 on 2012-10-29 00:34:03

@Maximus5
Copy link
Owner Author

Not as fast as Shift+Enter yet, but faster than before indeed. About two times faster
now.

Reported by dvv81@ukr.net on 2012-10-30 14:05:44

@Maximus5
Copy link
Owner Author

Прошу прощения, что врываюсь, но очень хотелось задать вопрос по коду. В ConEmuHk есть
существует глобальный объект CEStartupEnv, на который указывает глобальная переменная
gpStartEnv. Насколько я понял, в рамках всех библиотеки данный объект инициализируется
в DllMain и используется только функцией DuplicateRoot, которая в свою очередь вызывается
из HookServerCommand. Верно ли мое понимание ситуации и каково назначение DuplicateRoot
и HookServerCommand? Спасибо.

Reported by babavalya903 on 2013-01-03 15:49:50

@Maximus5
Copy link
Owner Author

@babavalya903,
В первую очередь объект создавался для багрепортов и отладки.
DuplicateRoot появился потом (инициируется из окна ConEmu меню таба).

Reported by ConEmu.Maximus5 on 2013-01-03 17:55:58

@Maximus5
Copy link
Owner Author

Running ConEmu 130314 x64 on Windows 7 pro 64bit, Far version 3.0 (build 3247)..
If I run Far, exiting Far with F10 can sometimes take up to 30 seconds to return to
a prompt, if I remove the check from "Inject ConEmuHk", then it doesn't seem to happen,
but then doskey.exe crashes  randomly, if I enable ConEmuHk doskey no longer crashes..

Reported by chalktrauma on 2013-03-19 01:09:12

@Maximus5
Copy link
Owner Author

Looks like the doskey issue might be a conflict with EasyHK64 in MacType and ConEmu,
still see Far slow to exit issue

Reported by chalktrauma on 2013-03-19 03:06:26

@Maximus5
Copy link
Owner Author

2chalktrauma,

30 sec delay is another issue, no need to mix them. However:
1. 130314 is not latest build
2. I need memory dumps a the moment of hung (30s delay)

Reported by ConEmu.Maximus5 on 2013-03-19 05:13:05

@Maximus5
Copy link
Owner Author

It seems I have similar issues using 130530 x64 on Win7 x64 and cmd.exe.
I got a Startup Task that opens 3 Tabs (4 actually) with my current git projects.
It's 3 projects, but for some reason the first tab is always lagging behind in input,
so I added a dummy-tab just catch this. Doesn't really help; out of the 4 tabs mostly
2 or 3 lag in input (I start typing, and letters slowly appear like an old typewriter
instead of instantly). 
Restarting ConEmu does not work; opening new tabs does (sometimes). Detaching and attaching
the Console also works.

My task looks like this (in case it matters):
 C:\Windows\System32\cmd.exe  -cur_console:a -cur_console:d:D:\_git\
 C:\Windows\System32\cmd.exe  -cur_console:a -cur_console:t:Repo1 "-cur_console:d:D:\_git\Repository
1"
 C:\Windows\System32\cmd.exe  -cur_console:a -cur_console:t:Repo2 "-cur_console:d:D:\_git\Repository
2"
 C:\Windows\System32\cmd.exe  -cur_console:a -cur_console:t:Repo3 "-cur_console:d:D:\_git\Repository
3"

Reported by bhaalsen on 2013-06-11 06:08:09

@Maximus5
Copy link
Owner Author

@bhaalsen,
Don't mix issues. Slow typing is NOT match to Issue 526.
May be you need go to the Issue 1078.

Reported by ConEmu.Maximus5 on 2013-06-11 07:54:05

@Maximus5
Copy link
Owner Author

I don't speak russian, so this issue seemed to be the closest match to my problem.

Reported by bhaalsen on 2013-06-11 09:16:01

@Maximus5
Copy link
Owner Author

You may open new one, but this issue is wrong place for discussion about your problem.
Please do that and attach screenshot of "Info" tab while you typing

Reported by ConEmu.Maximus5 on 2013-06-11 09:50:07

@Maximus5
Copy link
Owner Author

 If anyone notice large lags during execution - they may leave comments here. But I
believe ConEmu injects speed was greatly improved and can't be improved more ATM.
Current lag per process on my test PC is less than 10 ms.

Reported by ConEmu.Maximus5 on 2014-03-12 17:13:15

  • Status changed: Fixed

@bryanroscoe
Copy link

ConEmu takes about double the time to run our out MigrationScripts (which fork a bunch of sqlcmds) if I leave Inject ConEmuHK enabled.

@Maximus5
Copy link
Owner Author

Maximus5 commented Oct 1, 2015

This issue tracker was created for historical purposes only.

Small lags are expected. The only possible workaround is described in docs
https://conemu.github.io/en/ConEmuHk.html#Slowdown
Use carefully to avoid crashes.

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

No branches or pull requests

2 participants