Bug 366742 - Qbitorrent Xorg/kwin_x11 high cpu usage while adding more than 1 torrent at the same time.
Summary: Qbitorrent Xorg/kwin_x11 high cpu usage while adding more than 1 torrent at t...
Status: RESOLVED NOT A BUG
Alias: None
Product: kwin
Classification: Plasma
Component: core (show other bugs)
Version: 5.7.3
Platform: Neon Linux
: NOR crash
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-14 00:12 UTC by Tony
Modified: 2018-06-11 19:04 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tony 2016-08-14 00:12:20 UTC
Today i wanted to download a few distros , got a few torrents from linuxtracker.org and proceed to download.  Now Neon does not ship with a torrent downloader so i got Qbittorent (i found ktorrent too heavy on resources imo) .
I got it from the official ppa:
https://launchpad.net/~qbittorrent-team/+archive/ubuntu/qbittorrent-stable

If i try to add more than one torrent at the same time Xorg and kwin_x11 cpu usage will skyrocket freezing the desktop, in my case adding 4 torrents at the same time will do it.  Adding 2 or 3 will make the desktop unresponsive due to the CPU being hit in the face.

I hit ctrl+alt+F12, tried again, same issue. 

Qbittorrent default behavior when adding torrents is to open a window showing the torrent contents and options related to it. If you add 4 torrents at the same time like me, 4 of this windows will open.
This can be turn off so the torrents go straight away to the download list, avoiding this issue.

Now i am not entirely sure if this is a KDE related issue, i posted here since i don't have this problem on Windows or MacOS while using qbittorrent.

Reproducible: Always

Steps to Reproduce:
1.Install qbitorrent
2.Get some torrents
3.Open 4 or more at the same time
Comment 1 Martin Flöser 2016-08-15 05:43:44 UTC
could you please install debug symbols for KWin and gdb into the kwin process with the high cpu usage and then provide us a backtrace of it?

That should be something like:
1. ps -AF | grep kwin_x11
2. gdb --pid=<pid determined by 1>
3. t a a bt
Comment 2 Thomas Lübking 2016-08-15 10:40:09 UTC
> Xorg and kwin_x11
Smells like something (qbittorrent? plasmashell?) will cause massive repaints.

Suspend the compositor (SHIFT+Alt+F12) and check the remaining load on Xorg plus whatever process else boils up in top.

And use transmission ;-)
Comment 3 Tony 2016-08-15 18:53:13 UTC
Sadly can't provide a proper backtrace....

When i try to do it as non-root i get "ptrace: Operation not permitted."
Using sudo + having the compositor on, gdb won't even open on the terminal and the desktop locks.
Tried to cancel the command ctrl+c, no go, i killed x to regain control

I tried again with compositor off, .It works but  while gdb is running i can't click on anything, i mean i can, but there is no response, can't drag windows, right click menus etc.  so cannot switch to it.

Tried to open it from the terminal and i got this error:
"Could not resolve property : linearGradient4566"

I ran "bt" before closing gdb, this is what i got:

Attaching to process 3820
[New LWP 3825]
[New LWP 3827]
[New LWP 3854]
[New LWP 3915]
[New LWP 6011]
[New LWP 6012]
[New LWP 6013]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
0x00007f5378455e8d in poll () at ../sysdeps/unix/syscall-template.S:84
84      ../sysdeps/unix/syscall-template.S: No such file or directory.
(gdb) bt
#0  0x00007f5378455e8d in poll () at ../sysdeps/unix/syscall-template.S:84
#1  0x00007f5376328614 in poll (__timeout=<optimized out>, __nfds=5, __fds=0x1906118)
    at /usr/include/x86_64-linux-gnu/bits/poll2.h:46
#2  qt_ppoll (timeout_ts=<synthetic pointer>, nfds=5, fds=0x1906118) at kernel/qcore_unix.cpp:93
#3  qt_safe_poll (fds=0x1906118, nfds=nfds@entry=5, timeout_ts=timeout_ts@entry=0x7ffee2132320)
    at kernel/qcore_unix.cpp:121
#4  0x00007f5376329fb8 in QEventDispatcherUNIX::processEvents (this=<optimized out>, flags=..., 
    flags@entry=...) at kernel/qeventdispatcher_unix.cpp:495
#5  0x00007f536255e87d in QUnixEventDispatcherQPA::processEvents (this=<optimized out>, flags=...)
    at eventdispatchers/qunixeventdispatcher.cpp:68
#6  0x00007f53762d7d9a in QEventLoop::exec (this=this@entry=0x7ffee2132460, flags=..., 
    flags@entry=...) at kernel/qeventloop.cpp:210
#7  0x00007f53762e03ac in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1261
#8  0x00007f5376622dbc in QGuiApplication::exec () at kernel/qguiapplication.cpp:1639
#9  0x00007f5376bc57f5 in QApplication::exec () at kernel/qapplication.cpp:2975
#10 0x00007f5378734206 in kdemain (argc=1, argv=0x7ffee21326f8) at /workspace/build/main_x11.cpp:466
#11 0x00007f537837b830 in __libc_start_main (main=0x400710 <main(int, char**)>, argc=1, 
    argv=0x7ffee21326f8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, 
    stack_end=0x7ffee21326e8) at ../csu/libc-start.c:291
#12 0x0000000000400749 in _start ()
(gdb) quit
A debugging session is active.

        Inferior 1 [process 3820] will be detached.

Quit anyway? (y or n) y
Detaching from program: /usr/bin/kwin_x11, process 3820


At this point i gave up installed ktorrent, not a single issue, so this is on qbitorrent if you ask me.
Comment 4 Martin Flöser 2016-08-16 12:24:55 UTC
for gdb you need to go to another VT. Never gdb from the running session. Sorry, forgot to mention that.
Comment 5 Tony 2016-08-16 14:19:42 UTC
Ok, i gave it another try. Had to read about gdb a bit.... The desktop still locks while using gdb though so here is what i did:

First i delete .config and .cache from "home" and start the desktop clean.
I login to  VT3 and VT4. In VT4 have top running, VT3 i used it to run gdb.

So i opened 4 torrents with qbitorrent switch to VT4 check that X and kwin are using a lot cpu power.
Switch to VT3 and ran gdb, set logging on, and ran bt. I got this on from "gdb.txt" on my home folder:

#0  QVector<bool (*)(QXcbConnection*, xcb_generic_event_t*)>::detach (this=0x1470800) at ../../../../include/QtCore/../../src/corelib/tools/qvector.h:384
#1  QVector<bool (*)(QXcbConnection*, xcb_generic_event_t*)>::end (this=0x1470800) at ../../../../include/QtCore/../../src/corelib/tools/qvector.h:208
#2  QXcbConnection::processXcbEvents (this=0x14704f0) at qxcbconnection.cpp:1731
#3  0x00007f54ce159ad9 in QObject::event (this=0x14704f0, e=<optimized out>) at kernel/qobject.cpp:1263
#4  0x00007f54cea1989c in QApplicationPrivate::notify_helper (this=<optimized out>, receiver=0x14704f0, e=0x7f54b4a5aef0) at kernel/qapplication.cpp:3799
#5  0x00007f54cea21296 in QApplication::notify (this=0x7ffc2242e190, receiver=0x14704f0, e=0x7f54b4a5aef0) at kernel/qapplication.cpp:3556
#6  0x00007f54ce12dda8 in QCoreApplication::notifyInternal2 (receiver=0x14704f0, event=event@entry=0x7f54b4a5aef0) at kernel/qcoreapplication.cpp:988
#7  0x00007f54ce13046b in QCoreApplication::sendEvent (event=0x7f54b4a5aef0, receiver=<optimized out>)
    at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:231
#8  QCoreApplicationPrivate::sendPostedEvents (receiver=receiver@entry=0x0, event_type=event_type@entry=0, data=0x1456d30) at kernel/qcoreapplication.cpp:1649
#9  0x00007f54ce17ddea in QEventDispatcherUNIX::processEvents (this=0x14abdf0, flags=flags@entry=...) at kernel/qeventdispatcher_unix.cpp:461
#10 0x00007f54ba3b287d in QUnixEventDispatcherQPA::processEvents (this=<optimized out>, flags=...) at eventdispatchers/qunixeventdispatcher.cpp:68
#11 0x00007f54ce12bd9a in QEventLoop::exec (this=this@entry=0x7ffc2242e080, flags=..., flags@entry=...) at kernel/qeventloop.cpp:210
#12 0x00007f54ce1343ac in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1261
#13 0x00007f54ce476dbc in QGuiApplication::exec () at kernel/qguiapplication.cpp:1639
#14 0x00007f54cea197f5 in QApplication::exec () at kernel/qapplication.cpp:2975
#15 0x00007f54d0588206 in kdemain (argc=1, argv=0x7ffc2242e318) at /workspace/build/main_x11.cpp:466
#16 0x00007f54d01cf830 in __libc_start_main (main=0x400710 <main(int, char**)>, argc=3, argv=0x7ffc2242e318, init=<optimized out>, fini=<optimized out>, 
    rtld_fini=<optimized out>, stack_end=0x7ffc2242e308) at ../csu/libc-start.c:291
#17 0x0000000000400749 in _start ()
Detaching from program: /usr/bin/kwin_x11, process 10843

Hopefully it helps.

But now i noticed something else, when i ran gdb attached to kwin process the cpu usage from both X and kwin goes down right away, but as soon as i quit it it goes up again. Both spike well above  50% cpu usage on a FX832 up to 90% for X and stay there until i killed qbittorrent.
Comment 6 Martin Flöser 2016-08-16 14:26:13 UTC
thanks. The backtrace is directly from the event loop when processing X11 events. That could confirm the hypothesis Thomas had in comment #2.

Did you try with just turning compositing off?
Comment 7 Tony 2016-08-16 15:10:12 UTC
For that bactrace no i did not. But it happens in any case compositing on/off, the only difference is that when off i does not happen right away i need to move the windows around, click on them or wait a little with them open.

This is a backtrace i get with compositing off:

#0  0x00007f8669d60c74 in QXcbConnection::checkEvent<(anonymous namespace)::PropertyNotifyEvent> (this=0x23a64c0, checker=<synthetic pointer>)
    at qxcbconnection.h:695
#1  QXcbConnection::getTimestamp (this=0x23a64c0) at qxcbconnection.cpp:1467
#2  0x00007f8669d812b2 in QXcbNativeInterface::getTimestamp (this=this@entry=0x239ee10, screen=screen@entry=0x23b8c80) at qxcbnativeinterface.cpp:413
#3  0x00007f8669d82242 in QXcbNativeInterface::nativeResourceForScreen (this=0x239ee10, resourceString=..., screen=0x23b8420) at qxcbnativeinterface.cpp:243
#4  0x00007f86803a6c90 in QX11Info::getTimestamp() () from /usr/lib/x86_64-linux-gnu/libQt5X11Extras.so.5
#5  0x00007f867f7f7dd9 in KWin::updateXTime () at /workspace/build/utils.cpp:87
#6  0x00007f867f827355 in KWin::Client::updateUserTime (this=0x2753740, time=time@entry=0) at /workspace/build/activation.cpp:706
#7  0x00007f867f828472 in KWin::Workspace::activateClient (this=0x24812b0, c=0x2753740, force=<optimized out>) at /workspace/build/activation.cpp:330
#8  0x00007f867e97a0dc in NETRootInfo::event(xcb_generic_event_t*, QFlags<NET::Property>*, QFlags<NET::Property2>*) ()
   from /usr/lib/x86_64-linux-gnu/libKF5WindowSystem.so.5
#9  0x00007f867f80d946 in KWin::Workspace::workspaceEvent (this=0x24812b0, e=0x7f86653a00f0) at /workspace/build/events.cpp:265
#10 0x00007f867db50f0f in QAbstractEventDispatcher::filterNativeEvent (this=<optimized out>, eventType=..., message=message@entry=0x7f86653a00f0, 
    result=result@entry=0x7fff9943a698) at kernel/qabstracteventdispatcher.cpp:466
#11 0x00007f8669d64684 in QXcbConnection::handleXcbEvent (this=this@entry=0x23a64c0, event=event@entry=0x7f86653a00f0) at qxcbconnection.cpp:1103
#12 0x00007f8669d65300 in QXcbConnection::processXcbEvents (this=0x23a64c0) at qxcbconnection.cpp:1735
#13 0x00007f867db7fad9 in QObject::event (this=0x23a64c0, e=<optimized out>) at kernel/qobject.cpp:1263
#14 0x00007f867e43f89c in QApplicationPrivate::notify_helper (this=<optimized out>, receiver=0x23a64c0, e=0x7f8665022110) at kernel/qapplication.cpp:3799
#15 0x00007f867e447296 in QApplication::notify (this=0x7fff9943ad50, receiver=0x23a64c0, e=0x7f8665022110) at kernel/qapplication.cpp:3556
#16 0x00007f867db53da8 in QCoreApplication::notifyInternal2 (receiver=0x23a64c0, event=event@entry=0x7f8665022110) at kernel/qcoreapplication.cpp:988
#17 0x00007f867db5646b in QCoreApplication::sendEvent (event=0x7f8665022110, receiver=<optimized out>)
    at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:231
#18 QCoreApplicationPrivate::sendPostedEvents (receiver=receiver@entry=0x0, event_type=event_type@entry=0, data=0x238cd30) at kernel/qcoreapplication.cpp:1649
#19 0x00007f867dba3dea in QEventDispatcherUNIX::processEvents (this=0x23e5f20, flags=flags@entry=...) at kernel/qeventdispatcher_unix.cpp:461
#20 0x00007f8669dd887d in QUnixEventDispatcherQPA::processEvents (this=<optimized out>, flags=...) at eventdispatchers/qunixeventdispatcher.cpp:68
#21 0x00007f867db51d9a in QEventLoop::exec (this=this@entry=0x7fff9943ac40, flags=..., flags@entry=...) at kernel/qeventloop.cpp:210
#22 0x00007f867db5a3ac in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1261
#23 0x00007f867de9cdbc in QGuiApplication::exec () at kernel/qguiapplication.cpp:1639
#24 0x00007f867e43f7f5 in QApplication::exec () at kernel/qapplication.cpp:2975
#25 0x00007f867ffae206 in kdemain (argc=1, argv=0x7fff9943aed8) at /workspace/build/main_x11.cpp:466
#26 0x00007f867fbf5830 in __libc_start_main (main=0x400710 <main(int, char**)>, argc=1, argv=0x7fff9943aed8, init=<optimized out>, fini=<optimized out>, 
    rtld_fini=<optimized out>, stack_end=0x7fff9943aec8) at ../csu/libc-start.c:291
#27 0x0000000000400749 in _start ()
Detaching from program: /usr/bin/kwin_x11, process 3126
Comment 8 Thomas Lübking 2016-08-21 08:17:23 UTC
Some static backtrace won't get you anywhere reg. CPU load - this would only work if kwin would be trapped in an infinite loop.

Suspend the compositor (SHIFT+Alt+F12), run qbittorrent and watch remaining CPU loads.
A high cpu load in qbittorrent and Xorg, but no load in kwin likely means that the client repaints like hell - this will directly impact the compositor (rasing kwin in that regard)

If kwin has high cpu load despite a suspended compositor (no shadows, translucency etc!) that would suggest the client causes map/unmap notifications (some window shows/hides) or configure requests.

In the latter case I would check on its systray icon (it certainly has one, yesno?)
Try to disable such feature in qbittorrent and see what happens.
Comment 9 Tony 2016-08-21 15:33:28 UTC
I did as you said, suspended the compositor, removed qbitorrent icon from notification area. 

Like this, it does not happen right away as i said before, it only  takes longer to pop up, have to force it (opening many torrents).
Kwin and qbitorrent cpu usage only go up when Xorg usage goes up by a lot in this case. 
So is more like your 1st case.
Comment 10 Tony 2018-06-11 19:04:11 UTC
Recently checking to see if this was fixed or better, with help from someone that works in "Linux" for a living it was concluded this is not a Kwin nor Qbitorrent problem but X's.  

The issue is present on different systems and OSs Neon, Fedora Opensuse and Debian.

This do not happen under Wayland.