Is kwin_wayland unnecessarily burning CPU cycles?

Hey hey,

I think I found a bug in the sense that KDE unnecessarily burns CPU cycles. Could you verify this:

Open the System Monitor with the ‘Processes’ tab ordered by CPU, open Kate or Konsole next to it, enter a bit of text (‘asdf’, it’s not important what), and check whether the kwin_wayland process uses about 75% of one core of the CPU without anything else happening (on my 5600X that’s about 7-8% of the CPU). Important: as soon as the mouse is moved the CPU usage goes down again, otherwise it keeps using one core of the CPU.

This happens on my PC with Kate, Konsole, Firefox (even with the textarea I’m writing this in), Thunderbird and probably more applications, but not in Chromium, VSCode, Sublimetext.

Does this happen on your systems, too? This is with Plasma 6.6.0 on Opensuse Tumbleweed, 5600X, AMD 9060XT.

8700k @ 4.8GHz here, kwin_wayland is using 1.5% of my CPU at most when wiggling the mouse at the desktop. Running KDE Neon 6.6.0.

I’ve got Firefox, Thunderbird, Discord, Steam and a number of other applications running in the background.

Thanks for the reply! My CPU usage is fine when wiggling the mouse at the desktop, too, but what happens when you do what I described, type text in Kate or Konsole?

The highest I see is typing under Kate, CPU usage goes up to 1.1%.

1 Like

Ok, thanks for testing this! :slightly_smiling_face:

Happy to provide feedback, no problem.

1 Like

I have this problem. Typing random keystrokes into a Konsole window:

I stop typing and it settles back to [nearly] zero.

kwin.x86_64 6.6.0-1.fc43

1 Like

Thanks for checking! So I’m not alone with this! :slightly_smiling_face:

I’ll wait for maybe a few other responses, and then I’ll open a bug for this. If this turn out to be a more common problem, it probably should be adressed. Otherwise we’d all be wasting a bit of energy for nothing.

What kwin scripts do you have enabled?

In my case, none.

> What kwin scripts do you have enabled?

None. (I had to look up what that is. )

I do use two widgets in the taskbar, “Individual Core Usage” and “Thermal Monitor”, but removing them doesn’t change anything regarding the CPU usage.

I just checked on my CachyOS system running Plasma 6.6.0 and an i5-11400. Typing in Konsole or under Kate, again kwin_wayland never goes over ~1.1%

Any errors or warnings in your system log regarding video drivers or kwin or wayland?

journalctl -b -p 0..4

1 Like

Good call, I checked before, but haven’t found anything obvious.

I looked again: No errors for video drivers, the only warnings regarding kwin_wayland for today:

Feb 25 08:01:48 tw kwin_wayland[4642]: QDBusConnection: couldn’t handle call to Teardown, no slot matched
Feb 25 08:01:48 tw kwin_wayland[4642]: QDBusConnection: couldn’t handle call to Teardown, no slot matched
Feb 25 08:01:48 tw kwin_wayland[4642]: Could not find slot Krunner1Adaptor::Teardown
[…]
Feb 25 13:07:45 tw kwin_wayland[4642]: Failed to register with host portal QDBusError(“org.freedesktop.portal.Error.Failed”, “Could not register app ID: Unable to open /proc/4642/root”)

But these don’t seem to be connected. There are no entries at the times when I test the CPU usage spinning up.

I just noticed: when I play a youtube video in Firefox, and test typing a bit of text in Konsole, the bug doesn’t happen anymore, the CPU stays at ~1%. But when I stop the video, bring Konsole to the front, type a letter, then bam, one CPU core is at 75% load, 8% CPU usage until I move the mouse.

Same with Firefox, right now while I type this I can see the CPU between 5-8%.

Perhaps the higher CPU usage from playing a video is masking the other CPU usage?

Do you have some kind of autocomplete or other as you type program setup for terminal commands?

1 Like

I don’t think so. A youtube video only takes about 1-2% usage distributed over all CPU cores, but what I see with this ‘bug’ is one CPU core at about 75% usage.

I use a widget called “Individual Core Usage” that shows the usage of each CPU core of my 5600X as twelve bars (six core CPU + hyperthreading). When this bug happens this is what it looks like:

individual_core_usage

One thread, one process in some kind of ‘busy loop’. With youtube running or other typical desktop usage it looks more like many small bars, with just a few pixel height. (I tried to add a second image for comparison, but the forum won’t let me since I’m a new user. :melting_face: )

No, nothing of the kind. I do use zsh as shell, and it has an autocomplete built-in, but it works ‘on demand’ and doesn’t take much CPU, and besides I see this also happening while typing this message here in the forum in Firefox or composing an e-mail in Thunderbird or in Kate.

The fact that this happens in so many different applications makes me think that there’s really some busy loop in the desktop environment or compositor itself. And for some reason it doesn’t spin up when a window has to be redrawn every frame like it happens with a youtube video? I don’t know, I only know I can reproduce this. With a YT video running = no weird CPU usage, when I stop the video = same pattern as before.

But thanks for your reply! I’d love to find out why this happens, so it’s great that you check back. :slightly_smiling_face:

icu_youtube

This is the typical usage pattern, e.g. while watching a YT video. Low CPU usage distributed over all cores.

I think we’re stuck ruling stuff out until we find something.

Have you tried creating a new user and seeing if it happens under that “fresh” profile? That should narrow it down to system config vs user config.

1 Like

Just stumbled across this GitHub - KDAB/hotspot: The Linux perf GUI for performance analysis.

Apparently you can attach it to the pid of the kwin_wayland process (or any process) to pinpoint what is causing the high cpu use more directly.

I haven’t tried it but it sounds useful for your case.

1 Like