Bug 407917

Summary: Poor performance when open a more than N argb windows
Product: [Plasma] kwin Reporter: zvova7890
Component: performanceAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: kishore96, nate, tromzy, xaver.hugl
Priority: NOR Flags: mgraesslin: Wayland+
mgraesslin: X11+
Version First Reported In: 5.15.90   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: 6.1
Sentry Crash Report:

Description zvova7890 2019-05-24 19:16:19 UTC
Is this normal, when I'm open 10 windows of some app(for example konsole) - compositing performance is slowdown and moving, resizing, etc operation with windows like slideshow, including cursor. If open 50 instances of some app - 0.5fps we had. In this case, is this normal behavior? This is not because no more ram, swapping or something, this is realy kwin_wayland process eat a lot processor time. I tried to sysprof - all processor time mostly in kernel DRM of intel GPU driver.


STEPS TO REPRODUCE
1. Open 10+ windows of some app
2. Try to use system

OBSERVED RESULT
Poor performance

EXPECTED RESULT
All continue working smoothly

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 5.15.90
KDE Frameworks Version: 5.58.0
Qt Version: 5.13.0
Kernel Version: 5.1.4-arch1-1-ARCH
OS Type: 64-bit
Processors: 8 × Intel® Core™ i7-3630QM CPU @ 2.40GHz
Memory: 11.6 ГиБ
Comment 1 tromzy 2019-06-05 11:27:17 UTC
I also noticed that while kwin_wayland is snappier and smoother than kwin_x11 on an empty session (or with few windows), performance degrades fast when multiple windows are open.
Comment 2 zvova7890 2019-07-01 23:01:49 UTC
Interest thing. I had received updates for my archlinux, with released kwin(5.16) and Qt 5.13(before I'm used beta releases), and have tested this again. 

In x11 if open 50 konsole instances - performance regress to, but if disable composition all becomes fine. Second my test continue in weston compositor. I'm run 150 instances weston-terminal and all continue work smooth, but if in wayland mode run some konsole in 150 instances - performance is regress. Then I'm install gnome-terminal and also run with 150 instance - same result as with konsole. What is this and why weston "native" applications work better with more instances - I don't know. Maybe weston applications used more proper way for rendering invisible areas of application, I don't know. These are my observations, if it could somehow help
Comment 3 Martin Flöser 2019-07-02 04:51:30 UTC
Maybe it's a problem with translucent windows? Especially if window background is blurred a performance degrading is to be expected with more open windows.
Comment 4 zvova7890 2019-07-02 17:11:02 UTC
It is default kde theme, transparent and blured only plasma(taskbar what visible). Window is not transparent, only when moved. But I had disabled transparency and blur in effect settings - and window run more smoother. Wait... it's could be window shadows, that are transparent and blured. But in case X11 when I disabled transparent and blur effects window run smoother in a lot instances, in wayland session it's not affected and performance continues in low level.
Comment 5 zvova7890 2019-07-02 21:03:30 UTC
Another interest thing - if open ksysguard in 100+ instances, all fine. But with konsole slideshow O_o. This is on x11, on wayland stable performance problem with any windows. I tried to switch to wayland by default, but when I make some my work and open 10+ windows lags can't make me productive. I had switched back to x11
Comment 6 Martin Flöser 2019-07-03 04:36:30 UTC
Shadows are translucent and Konsole is translucent. That sounds a lot like an issue in our translucent windows rendering path.
Comment 7 zvova7890 2019-07-03 12:36:02 UTC
Looks like. ksysguard in many instances work fine with shadows(normal size in shadow settings) in x11, in wayland much slower. So there is 2 problems:

1. konsole in anywhere slow with many instances because translucent is flagged in all cases and also in case when translucent and blur is disabled in konsole profile.

2. Wayland kwin backend has some problems with rendering translucent windows. But not sure, because with disabled shadows with many instances of ksysguard is also faced slow rendering
Comment 8 Martin Flöser 2019-07-03 16:59:04 UTC
Iirc Qt on Wayland uses an alpha channel by default, so we are always in the "Konsole" Case.
Comment 9 Christoph Feck 2019-07-03 17:37:26 UTC
If Qt doesn't inform Wayland of opaque surfaces, that sure would be worth a bug report.
Comment 10 Martin Flöser 2019-07-04 04:33:22 UTC
(In reply to Christoph Feck from comment #9)
> If Qt doesn't inform Wayland of opaque surfaces, that sure would be worth a
> bug report.

Yes and no. I would say it was a bug on X11 that argb was not supported out of the box. And anyway any gtk application is argb due to csd. We need to become better in rendering argb windows.
Comment 11 Christoph Feck 2019-07-25 14:31:06 UTC
> any gtk application is argb due to csd

I am pretty sure GTK informs wayland about the opaque region _inside_ the window. Otherwise a stack of windows always needs to be composited completely from back to front.
Comment 12 zvova7890 2019-07-27 00:39:05 UTC
I had installed gnome, run under wayland, and create 50 windows od gedit(and then gnome-terminal) - performance is ok. Then i make 50 windows of ksysguard(uses wayland mode) - faced slow rendering, with konsole same situation.

So: 
1. GTK applications correct informs gnome compositor about opaque surfaces.
2. KDE/Qt applications always in transclucent mode. 
3. GTK applications is always in transclucent mode under kwin compisition.


Maybe kwin-wayland doesn't uses opaque flag and always goes to the transclucent composition for all window? And second problem - that the Qt applications nothing inform about opaque surfaces, and compositors take default value as opaque = true.
Comment 13 zvova7890 2020-04-14 01:07:59 UTC
Any ideas/progress with this? Still having this issue(
I’m really want to switch my session on wayland and continue deep testing, but I cannot, because I’m using more than 5 window, xorg session still more smooth
Comment 14 zvova7890 2021-08-20 01:14:06 UTC
I had built latest for now kwin from git and related kwayland* packages, seems situation for now is match better! Also firefox now not laggy when hide/show action is performed. Maybe that related to https://invent.kde.org/plasma/kwin/-/commit/11c7e7a64da3b39c89a1392f1f1112bc8c8ea8b7 commit. 

I'm waiting for release for full true test
Comment 15 zvova7890 2022-08-08 00:24:40 UTC
Bug is still here :( konsole windows count in direct ratio affect performance. Over 20 windows of konsole become desktop to slideshow. Also, when desktop has not windows showed, all slideup plasma menus shows smoothly, but if open at least one window - smooth is disapearing. When you are working and open many windows - interface reaction is slowing down. X11 session doesn't have this effect. You can open as much as you want windows and this doesn't affect to the interface FPS. Feels like some compositor problems.
Comment 16 Zamundaaa 2024-06-07 15:50:20 UTC
Can you still reproduce this issue in Plasma 6?
Comment 17 zvova7890 2024-06-08 14:13:08 UTC
Yes, I do. But I want to test it on 6.1 with the triple buffering feature. Will test this weekend
Comment 18 zvova7890 2024-06-08 19:26:54 UTC
With triple buffering and https://invent.kde.org/plasma/kwin/-/merge_requests/5779 the issue seems to be resolved. At least it is now have performance parity between Wayland and X11 session. So, this bug can be considered resolved.

Thanks!
Comment 19 Nate Graham 2024-06-08 19:28:16 UTC
Great news!