Bug 189756 - Konsole: High CPU caused by e.g. mplayer or mencoder status updates
Summary: Konsole: High CPU caused by e.g. mplayer or mencoder status updates
Status: RESOLVED UNMAINTAINED
Alias: None
Product: konsole
Classification: Applications
Component: general (show other bugs)
Version: 2.9
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-04-15 23:39 UTC by Dennis Jansen
Modified: 2022-09-04 10:23 UTC (History)
11 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dennis Jansen 2009-04-15 23:39:00 UTC
Version:            (using KDE 4.1.4)
OS:                Linux
Installed from:    Ubuntu Packages

When I play files in mplayer or encode files in mencoder I get a constant 6-10% cpu used up by konsole just to display the status updates. Even if the windows is not visible.

Currently the only workaround is to display the status via the -quiet parameter.
The problem also exists when using darkstat --verbose.
Comment 1 Dennis Jansen 2009-04-16 08:40:32 UTC
 6823      30  10 84412  49m  17m R 61.1  2.5 156:10.85 mencoder
 3952      20   0  145m  39m 7736 R 24.2  2.0  16:57.44 konsole

Here I play one file and encode another. This is a peak value, though. The average is 10-15 in that scenario.
Comment 2 Robert Knight 2009-04-16 11:16:50 UTC
> Even if the windows is not visible.

Is the window minimized or just obscured by something else?  Do you have compositing enabled?
Comment 3 Robert Knight 2009-04-16 11:18:35 UTC
>  This is a peak value, though. The average is 10-15 in that scenario.

Peak is not very useful - average over a period of time (eg. 20 seconds) would be more informative.
Comment 4 Hugo Mildenberger 2009-10-28 12:13:36 UTC
I observed a very similar behaviour using kde-4.3.2, when running for instance htop or top within "konsole": constantly 10% cpu load (sometimes, under yet unknown circumstances even about 50%, also constantly), whereas running "top" within xterm yields in max. 1% cpu load. The same holds true when running top within a native console. However, in my environment, it is not "konsole" itself, but "X" which consumes that much. The CPU-load clearly depends on whether "konsole" runs "top". It does not depend on "konsole" window being active, minimized or even moved to another desktop. The system has Compositing enabled. Looking for a difference, I noticed that xterm uses libxcb, while "konsole" does not.
Comment 5 Semo 2009-10-30 19:28:13 UTC
Same problem (with mplayer) in konsole 4.3.1. It is quite common that konsole+X consume two times more CPU than mplayer itself. With or without compositing, with or without focus, "smooth fonts" or not, doesn't make any difference. Only workaround is to minimize konsole window or switch to another tab in konsole (or option -quiet for mplayer). Konsole 3.5.10 is not affect as well as xterm.

Test case 1 (Athlon64 3200 = 2.0GHz): top with 1s delay running in konsole (LINES==54, COLUMNS==157) measured with top with 20s delay running in xterm.

 9869 semo      20   0  106m  39m  10m S  4.6  1.3  62:49.74 konsole            
 9765 root      20   0  158m  45m 3104 S  3.7  1.5 125:32.50 X                  
 9846 semo      20   0  309m  30m  15m R  2.1  1.0  56:39.29 kwin               
15536 semo      20   0  187m 132m  19m S  1.7  4.4  14:49.91 opera              
31500 semo      20   0  2696 1180  884 S  1.2  0.0   0:01.04 top

and xterm (with 1s top) measured by xterm (with 20s top)
 9846 semo      20   0  312m  30m  15m S  2.0  1.0  56:43.80 kwin               
 9765 root      20   0  165m  45m 3104 S  2.0  1.5 125:41.21 X                  
15536 semo      20   0  187m 132m  19m R  1.9  4.4  14:53.34 opera              
31532 semo      20   0  2696 1180  884 S  1.2  0.0   0:00.36 top                
 9850 semo      20   0  308m  38m  10m S  0.7  1.3  28:39.43 plasma-desktop     
 9855 semo      20   0  4340  884  348 S  0.6  0.0  20:11.51 ksysguardd         
31502 semo      20   0  9188 3872 2372 S  0.3  0.1   0:00.30 xterm

Test case 2: print string similar to mplayer 25 times per second (just like mplayer) a see difference in CPU consuming when running in konsole and in xterm.
=========================
#include <unistd.h>
void main(void) {
    for (;;) {
        usleep(40000);
        puts("A:   1.5 V:   1.5 A-V: -0.000 ct: -0.018  38/ 38 30%  7%  0.4% 4 0");
    }
}
=========================
Comment 6 Semo 2009-10-30 19:28:47 UTC
*** This bug has been confirmed by popular vote. ***
Comment 7 Hugo Mildenberger 2009-10-31 21:04:51 UTC
Using a much shorter test program (while sleep 1; do echo hello; done), I observed that CPU load jumps from about 10% to 35% the very moment the console screen starts scrolling. Resetting the terminal via reset and repeating the experiment lowers CPU load again to 10% -- until scrolling starts.  Disabling konsole history brings the CPU load down to constantly 2%. I used a buffer of 1000 lines. The test program "while sleep 1; do true; done" does not increase CPU load.
Comment 8 Benni Hill 2011-02-09 00:50:45 UTC
I can confirm this on KDE 4.6. Playing an mp3 stream with mplayer produces a constant cpu consumption of ~12% for konsole. Starting mplayer with -quiet prevents this.
Comment 9 Matt Whitlock 2011-02-09 00:59:04 UTC
(In reply to comment #8)
> I can confirm this on KDE 4.6. Playing an mp3 stream with mplayer produces a
> constant cpu consumption of ~12% for konsole. Starting mplayer with -quiet
> prevents this.

I am also on KDE 4.6, but I do not see this behavior. When I play an MP3 with mplayer, Konsole uses a constant 1% CPU, and KWin uses a constant 1% CPU as well. The X server uses essentially no CPU time.

I have compositing and LCD font anti-aliasing enabled, and I even have Konsole using a translucent background. I can provide any additional info about my system if it would be helpful.
Comment 10 Benni Hill 2011-02-09 01:01:59 UTC
I forgot to mention: I ran konsole in valgrind and the problem seems to be in
Konsole::TerminalDisplay::updateImage() and/or Konsole::Screen::copyFromScreen.
Comment 11 Benni Hill 2011-02-09 01:25:52 UTC
(In reply to comment #9)
I played with anti-aliasing (in konsole and in systemsettings) and compositing and neither had a significant effect.

Using mplayer in xterm isn't causing any problems.
Comment 12 Benni Hill 2011-02-09 18:15:51 UTC
I can reproduce this on another PC (i5 QuadCore) with KDE 4.5.3. Konsole there has ~8% CPU usage (on one core I guess).
Comment 13 Jekyll Wu 2011-07-25 06:14:01 UTC
There might be some efficiency problem in how konsole updates the display, especially when the content is changed in high frequency.

When I run cmatrix within konsole, the average cpu usage of konsole is 70%. gnome-terminal and xfce4-terminal have around 15%, and xterm has around 3%.
Comment 14 e-kde 2013-06-26 15:05:19 UTC
This problem just recently (with some version around 4.10.4) got muc worse for me.
Playing an mp3 in mplayer is not causing constant 100% cpu load on konsole.
Comment 15 Jerrod Frost 2016-01-05 06:15:23 UTC
I don't think this issue is strictly related to playing audio files. I've always been a big yakuake fan so I didn't notice these issues before. Konsole is unruly for a terminal application. doing top (and nothing but top) Konsole bounces up to 17% CPU usage some times! xterm doesn't even appear in the top 10 like konsole does. 

 PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                                       
 6288 darksurf  20   0  643336  74276  62348 S  16.6  1.1   0:06.84 konsole                                                                                                       
 2248 darksurf  20   0 3285624 140236  99364 S   5.3  2.0   2:52.69 kwin_x11                                                                                                      
 2059 root      20   0  450428 219756 129640 S   5.0  3.1   1:45.44 X                                                                                                             
 2263 darksurf  20   0 5797936 458768 174832 S   2.3  6.5   1:07.61 plasmashell                                                                                                   
 2258 darksurf  20   0  843720  96092  69656 S   1.3  1.4   0:43.02 krunner                                                                                                       
 4683 darksurf  20   0  613276 144152  90760 S   1.3  2.0   1:18.94 chrome                                                                                                        
 2289 darksurf  20   0 1181444  72788  43124 S   0.7  1.0   0:27.22 ktorrent                                                                                                      
 1635 root      20   0  148416  72356  72020 S   0.3  1.0   0:00.70 systemd-journal                                                                                               
 1965 root      20   0  620128  14936  12216 S   0.3  0.2   0:00.70 NetworkManager                                                                                                
 2115 darksurf  20   0   32824   3168   1908 S   0.3  0.0   0:01.16 dbus-daemon                                                                                                   


Sabayon Linux fully updated as of 05.01.2016
Linux CtrlZ 4.3.0-sabayon #1 SMP Wed Dec 16 22:02:39 UTC 2015 x86_64 AMD A10-7850K Radeon R7, 12 Compute Cores 4C+8G AuthenticAMD GNU/Linux
KDE PLASMA 5.5.2
konsole-15.08.3

darksurf@CtrlZ ~ $ sudo lspci
00:00.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 15h (Models 30h-3fh) Processor Root Complex
00:00.2 IOMMU: Advanced Micro Devices, Inc. [AMD] Family 15h (Models 30h-3fh) I/O Memory Management Unit
00:01.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Kaveri [Radeon R7 Graphics]
00:01.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Kaveri HDMI/DP Audio Controller
00:02.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Device 1424
00:02.1 PCI bridge: Advanced Micro Devices, Inc. [AMD] Device 1425
00:03.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Device 1424
00:03.1 PCI bridge: Advanced Micro Devices, Inc. [AMD] Family 15h (Models 30h-3fh) Processor Root Port
00:04.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Device 1424
00:10.0 USB controller: Advanced Micro Devices, Inc. [AMD] FCH USB XHCI Controller (rev 09)
00:10.1 USB controller: Advanced Micro Devices, Inc. [AMD] FCH USB XHCI Controller (rev 09)
00:11.0 SATA controller: Advanced Micro Devices, Inc. [AMD] FCH SATA Controller [AHCI mode] (rev 40)
00:12.0 USB controller: Advanced Micro Devices, Inc. [AMD] FCH USB OHCI Controller (rev 11)
00:12.2 USB controller: Advanced Micro Devices, Inc. [AMD] FCH USB EHCI Controller (rev 11)
00:13.0 USB controller: Advanced Micro Devices, Inc. [AMD] FCH USB OHCI Controller (rev 11)
00:13.2 USB controller: Advanced Micro Devices, Inc. [AMD] FCH USB EHCI Controller (rev 11)
00:14.0 SMBus: Advanced Micro Devices, Inc. [AMD] FCH SMBus Controller (rev 16)
00:14.1 IDE interface: Advanced Micro Devices, Inc. [AMD] FCH IDE Controller
00:14.2 Audio device: Advanced Micro Devices, Inc. [AMD] FCH Azalia Controller (rev 01)
00:14.3 ISA bridge: Advanced Micro Devices, Inc. [AMD] FCH LPC Bridge (rev 11)
00:14.4 PCI bridge: Advanced Micro Devices, Inc. [AMD] FCH PCI Bridge (rev 40)
00:14.5 USB controller: Advanced Micro Devices, Inc. [AMD] FCH USB OHCI Controller (rev 11)
00:15.0 PCI bridge: Advanced Micro Devices, Inc. [AMD] Hudson PCI to PCI bridge (PCIE port 0)
00:18.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 15h (Models 30h-3fh) Processor Function 0
00:18.1 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 15h (Models 30h-3fh) Processor Function 1
00:18.2 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 15h (Models 30h-3fh) Processor Function 2
00:18.3 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 15h (Models 30h-3fh) Processor Function 3
00:18.4 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 15h (Models 30h-3fh) Processor Function 4
00:18.5 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 15h (Models 30h-3fh) Processor Function 5
01:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Fiji XT [Radeon R9 FURY X] (rev ca)
01:00.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Device aae8                                                                                                          
02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 06)                                                   
04:00.0 Network controller: Intel Corporation Wireless 7260 (rev 73)