Bug 463718 - On Wayland but not X11, system performance severely degrades as I use PC until plasma restart
Summary: On Wayland but not X11, system performance severely degrades as I use PC unti...
Status: REPORTED
Alias: None
Product: kwin
Classification: Plasma
Component: performance (show other bugs)
Version: 5.26.4
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords: wayland
Depends on:
Blocks:
 
Reported: 2023-01-02 09:01 UTC by gudvinr+kde
Modified: 2024-08-20 20:58 UTC (History)
3 users (show)

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


Attachments
nvtop (deleted)
2023-02-26 23:26 UTC, gudvinr+kde
Details
nvtop (400.95 KB, image/png)
2023-02-28 09:10 UTC, gudvinr+kde
Details

Note You need to log in before you can comment on or make changes to this bug.
Description gudvinr+kde 2023-01-02 09:01:36 UTC
SUMMARY

If I use PC with Plasma (wayland) running, performance significanly drops over time.

It is subjectively noticeable (e.g. cursor becomes laggy, windows  do not move smoothly, etc) and objectively measured (I tried to play some games while I usually have 150+ FPS and in same conditions I have less than 60 until I restart plasma).

I tried to investigate this more myself I first I thought it is caused by something in the system because it goes away after reboot. But then I tried to  e.g. play same games with every heavy app killed and it's same thing. Also tried to restart just graphical environment by Ctrl+Alt+Backspace and it helps too.

I also suspected that it could be caused by Night Color kicking in but I wasn't able to remove it out of the equation or confirm it because I use kde-inhibit when I launch steam so it isn't running while I play and observe this behaviour.

I don't use X11 session for a while now and last time I did it messed up my display layout so I don't want to switch back and forth.

Also I think it started to happen last fall, around 5.26 release. Maybe after one of the point releases of 5.26 but it'd be rather complicated to cherry pick every release and test myself because I don't even know which component might cause that. And that's very time consuming not to mention that version jumping might result in configuration corruption or some other nasty bugs.

STEPS TO REPRODUCE
1. Use PC for a while

OBSERVED RESULT
PC starts being very laggy

EXPECTED RESULT
PC not being laggy after running plasma for some time

SOFTWARE/OS VERSIONS
Operating System: Arch Linux
KDE Plasma Version: 5.26.4
KDE Frameworks Version: 5.101.0
Qt Version: 5.15.7
Kernel Version: 6.1.1-zen1-1-zen (64-bit)
Graphics Platform: Wayland
Processors: 8 × Intel® Core™ i7-8705G CPU @ 3.10GHz
Memory: 31.3 GiB of RAM
Graphics Processor: AMD Radeon RX Vega M GL Graphics
Comment 1 David Edmundson 2023-01-03 09:31:07 UTC
We need more information for this to be actionable.

Are any processes using more RAM than usual? More CPU?

>I also suspected that it could be caused by Night Color kicking in

Can you expand on this. Play with the settings so it comes on and off explicitly.
Comment 2 gudvinr+kde 2023-01-03 09:45:03 UTC
(In reply to David Edmundson from comment #1)
> Are any processes using more RAM than usual? More CPU?

In the moment? No, I don't think that processes start to consume abnormally huge amount of resources. Like half of CPU or GBs or RAM.
And I try to stop all user processes that potentially can cause issue. Like browser, discord, media player. 
I'll try to track if something uses more ram over time, though. But it will take some time to gather statistics.

> Can you expand on this. Play with the settings so it comes on and off explicitly.

I can say for sure that while transition happens, everything on screen that moves is jittery but that by itself is probably another issue.
I set NC to always night, then toggle it off and then on, and while it gradually changes temperature, I move window.
Comment 3 gudvinr+kde 2023-01-03 09:50:48 UTC
I have a hunch that it could be related to xwayland but to prove that (or exclude xwayland from list of suspects) I need to be able to restart xwayland without restarting whole session. Is it possible to do with KDE?
Comment 4 Bug Janitor Service 2023-01-18 05:11:33 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 5 gudvinr+kde 2023-01-30 03:51:34 UTC
Through nvtop I found out that plasma takes about 25% of my VRAM (which is about 1Gb) after 10-ish hours of uptime. It also uses around 600Mb of RAM.

If I do plasmashell --replace or restart session with ctrl+alt+backspace, VRAM at the beginning is ~600Mb and RAM is ~200Mb.
Comment 6 gudvinr+kde 2023-01-30 04:08:39 UTC
I also noticed that when I quickly move mouse over task manager icons, CPU usage spikes to 15% (on 8 thread CPU, if plasma does perfect threading it could be ~2% per CPU thread) and GPU to 4%.

When I change qt quick rendering to software through `kcmshell5 qtquicksettings`, I get 4Mb of VRAM usage but what's expected, RAM usage increases to around 1Gb after plasmashell --replace.

After this, if I try to move over tasks quickly, CPU spikes to 11%, and no GPU usage.

So, I am not sure if all of this points to plasma as the culprit or if plasma causes issues that I have but surely using 1Gb of GPU doesn't seem to be a responsible handling of system resources. I don't mind RAM usage too much though, but 900Mb or 500Mb of RAM on cold boot also feels rather wasteful.

I don't think that this is still enough information to work with but what can I do to gather something more to be more useful?
Comment 7 gudvinr+kde 2023-02-26 23:24:25 UTC
I think I kinda reproduced this behaviour and I believe that's why I also have bug 462002.

I first noticed that my cursor behaves funny again and fired up nvtop and kwin debug console to see if that could be caused e.g. by mouse not sending events.

But I noticed that when I use scrollwheel and move mouse around in firefox, kwin CPU usage goes to 95%.
Then I took screenshot and when I just move mouse around in gwenview, kwin CPU usage goes up again, as well as gwenview usage.
Then I restarted firefox and it's back to normal again.

I maybe will try to run perf on kwin process if that happens again but as for now I can't think of something else I can do.
Comment 8 gudvinr+kde 2023-02-26 23:26:43 UTC
Created attachment 156771 [details]
nvtop

Here's the graph of GPU usage and current stats for processes as I move mouse around.
Comment 9 gudvinr+kde 2023-02-28 09:10:39 UTC
Created attachment 156823 [details]
nvtop

So, I again have issues with cursor stutter and overall noticeable performance issues.

I opened nvtop and now I see that kwin consumes almost half of my VRAM (1.5 out of 4 GiB) and GPU load up to 40%.
Load is caused by me playing youtube video though, once I stopped playback it goes back to normal (not performance issues though). Although it still doesn't seem right that despite of hardware decoding in firefox, kwin consumes 30 to 40% of GPU time.
Comment 10 Ben Cooksley 2023-08-21 09:35:54 UTC
The content of attachment 156771 [details] has been deleted for the following reason:

Requested by original submitter
Comment 11 Nate Graham 2024-08-20 16:41:00 UTC
Many things have changed under the hood in the past year and a half. Can I ask you to report whether this is still reproducible in any capacity in Plasma 6.1.4 or later?
Comment 12 gudvinr+kde 2024-08-20 18:02:14 UTC
This requires fully switching to Wayland for quite some time.
I decided not to until at least bugs that impact my workflow are fixed or somehow mitigated.

E.g. I filed BUG 460398 because I used window rules as poor man's tiling. When you change scale settings or switch between X11 and Wayland, changing these back and forth SUCKS.
However, if built-in tiling improves so you can save/load custom layouts, set layouts per activity and save per-app settings, etc I might not need these rules anymore. It'll still suck, but will not be that relevant.

Same with BUG 458748, when window opens up somewhere you don't expect it to, this annoys a lot when you do that every day multiple times a day.
BUG 453560, BUG 466603 and BUG 465124 all related to snapping and also are major annoyance.

BUG 451232 and BUG 466158 also not fixed apparently. Although some bugs related to bad scaling are indeed fixed, which is a plus.

All in all, I don't mind if this issue is getting closed as not reproducible if it isn't.
Comment 13 Nate Graham 2024-08-20 20:58:03 UTC
No unfortunately this doesn't seem to be widely reproducible. I'll keep it open for now and move it to KWin, since that's where the issues will be coming from on Wayland.