Nessesarius / mintty

Automatically exported from code.google.com/p/mintty
GNU General Public License v3.0
0 stars 0 forks source link

CPU Usage When Idle #265

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Start mintty and leave it idle.
2. Open Process Explorer. (This is the easiest way. Performance Monitor or 
typeperf could also be used but I won't be explaining how.)
3. Observe "Cycles Delta" and "CSwitch Delta". (I see > 200 CSwitches per 
second.)
4. Open Properties of mintty.exe in Process Explorer, view Threads tab and 
notice the activity.

What is the expected output? What do you see instead?
Frankly, this is not a serious issue. More of a nagging curiosity. My 
expectation from mintty is that it use few/no CPU cycles and makes few/no 
context switches when idle. What I instead see is a very noticeable activity, 
and most CPU cycles are being consumed by a TID starting at 
cygwin1.dll!setprogname+0x2620. Why? Could this be something that should not or 
need not be done? (Running cygwin.bat directly to use Cygwin doesn't show such 
activity.)

What versions of mintty, Cygwin/MSYS, and Windows are you using?
Mintty v0.97, Cygwin v1.7.9-1, Windows 7 Ultimate SP1 (x64, Build Version: 
6.1.7601 Service Pack 1 Build 7601). I've noticed this in a few older versions 
of Mintty, Cygwin as well, even on Windows XP.

Please provide any additional information below.
I can't think of any. If there's anything else needed, please write to me.

Original issue reported on code.google.com by bsravanin on 18 May 2011 at 5:47

GoogleCodeExporter commented 8 years ago
Mintty is a single-threaded application that spends most of its time in a 
select() call waiting for Windows events (via /dev/windows) or terminal output 
(via a pty device). Hence I don't think this is something that mintty itself 
does, but something in the Cygwin DLL, as suggested by your investigation. 
Something called setprogname() is unlikely to be 10K in size, so it's probably 
something else that just doesn't have a public symbol.

There was a thread about a seemingly closely related topic on the mintty 
discussion group recently: 
http://groups.google.com/group/mintty-discuss/browse_thread/thread/a6ad7e2d22a89
b7f.

There, the concern was about background I/O operations at a rate of about 
1Kbyte a second, and this turned out to be common to all terminals based on pty 
devices, which doesn't include the default console.

Therefore, could you check whether you see the same thing with the likes of 
rxvt or PuTTYcyg's cthelper? If so, the Cygwin mailing list is the best place 
for trying to get an explanation.

Original comment by andy.koppe on 18 May 2011 at 7:57

GoogleCodeExporter commented 8 years ago
You seem to be right, Andy. I'm seeing similar behavior in rxvt as well, 
apparently caused by setprogname(). I never noticed it before probably because 
mintty is the only terminal I use.

I will take this to the Cygwin mailing list next.

Thank you.

Original comment by bsravanin on 19 May 2011 at 4:22

GoogleCodeExporter commented 8 years ago
The resulting Cygwin mailing list thread indicates that this is due to select() 
periodically polling the Windows pipes underlying Cygwin's pseudo terminal 
(pty) implementation. I'm afraid there's nothing I can do about this in mintty.

http://www.cygwin.com/ml/cygwin/2011-05/msg00294.html

Original comment by andy.koppe on 25 May 2011 at 4:38