Bug 438297

Summary: kwin_x11
Product: [Plasma] kwin Reporter: Mike Rophone <sonok82308>
Component: generalAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED NOT A BUG    
Severity: normal CC: kde
Priority: NOR    
Version First Reported In: 5.21.5   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: heaptrack if high cpu usage kwin_x11

Description Mike Rophone 2021-06-08 22:32:30 UTC
SUMMARY
The kwin_x11 process takes up abnormally high amount of cpu ressources (up to 60% as reported by htop when watching a 720p video on a good system) but the problem seems to fade away when logging out and logging back in. This happens when disabling all the scripts, effects and addons I could find

STEPS TO REPRODUCE
1. Boot up the computer

OBSERVED RESULT
System is sluggish, kwin_x11 uses crazy high amount of cpu

EXPECTED RESULT
Low (sub 10%) cpu usage. Is achieved after logging out and back in

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 5.21.5
KDE Frameworks Version: Not sure? Latest from GNU/Arch Linux
Qt Version: 5.15.2

ADDITIONAL INFORMATION
Please find the output of `qdbus org.kde.KWin /KWin supportInformation` below

```
KWin Support Information:
The following information should be used when requesting support on e.g. https://forum.kde.org.
It provides information about the currently running instance, which options are used,
what OpenGL driver and which effects are running.
Please post the information provided underneath this introductory text to a paste bin service
like https://paste.kde.org instead of pasting into support threads.

==========================

Version
=======
KWin version: 5.21.5
Qt Version: 5.15.2
Qt compile version: 5.15.2
XCB compile version: 1.14

Operation Mode: X11 only

Build Options
=============
KWIN_BUILD_DECORATIONS: yes
KWIN_BUILD_TABBOX: yes
KWIN_BUILD_ACTIVITIES: yes
HAVE_DRM: yes
HAVE_GBM: yes
HAVE_EGL_STREAMS: yes
HAVE_X11_XCB: yes
HAVE_EPOXY_GLX: yes
HAVE_WAYLAND_EGL: yes

X11
===
Vendor: The X.Org Foundation
Vendor Release: 12011000
Protocol Version/Revision: 11/0
SHAPE: yes; Version: 0x11
RANDR: yes; Version: 0x14
DAMAGE: yes; Version: 0x11
Composite: yes; Version: 0x4
RENDER: yes; Version: 0xb
XFIXES: yes; Version: 0x50
SYNC: yes; Version: 0x31
GLX: yes; Version: 0x0

Decoration
==========
Plugin: org.kde.breeze
Theme: 
Plugin recommends border size: None
Blur: 0
onAllDesktopsAvailable: true
alphaChannelSupported: true
closeOnDoubleClickOnMenu: false
decorationButtonsLeft: 5, 3, 4, 7
decorationButtonsRight: 0
borderSize: 0
gridUnit: 10
font: IBM Plex Sans,10,-1,5,50,0,0,0,0,0,Regular
smallSpacing: 2
largeSpacing: 10

Platform
==========
Name: KWin::X11StandalonePlatform

Cursor
======
themeName: OpenZone_Black_Slim
themeSize: 24

Options
=======
focusPolicy: 0
xwaylandCrashPolicy: 
xwaylandMaxCrashCount: 3
nextFocusPrefersMouse: false
clickRaise: true
autoRaise: false
autoRaiseInterval: 0
delayFocusInterval: 0
shadeHover: false
shadeHoverInterval: 250
separateScreenFocus: true
placement: 8
focusPolicyIsReasonable: true
borderSnapZone: 10
windowSnapZone: 10
centerSnapZone: 0
snapOnlyWhenOverlapping: false
rollOverDesktops: true
focusStealingPreventionLevel: 1
operationTitlebarDblClick: 5000
operationMaxButtonLeftClick: 5000
operationMaxButtonMiddleClick: 5015
operationMaxButtonRightClick: 5014
commandActiveTitlebar1: 0
commandActiveTitlebar2: 28
commandActiveTitlebar3: 2
commandInactiveTitlebar1: 4
commandInactiveTitlebar2: 28
commandInactiveTitlebar3: 2
commandWindow1: 7
commandWindow2: 8
commandWindow3: 8
commandWindowWheel: 28
commandAll1: 10
commandAll2: 3
commandAll3: 14
keyCmdAllModKey: 16777251
showGeometryTip: false
condensedTitle: false
electricBorderMaximize: true
electricBorderTiling: true
electricBorderCornerRatio: 0.25
borderlessMaximizedWindows: false
killPingTimeout: 5000
hideUtilityWindowsForInactive: true
compositingMode: 1
useCompositing: true
hiddenPreviews: 1
glSmoothScale: 1
xrenderSmoothScale: false
glStrictBinding: true
glStrictBindingFollowsDriver: true
glCoreProfile: false
glPreferBufferSwap: 101
glPlatformInterface: 1
windowsBlockCompositing: true
latencyPolicy: 
renderTimeEstimator: 

Screen Edges
============
desktopSwitching: false
desktopSwitchingMovingClients: false
cursorPushBackDistance: 1x1
timeThreshold: 150
reActivateThreshold: 350
actionTopLeft: 0
actionTop: 0
actionTopRight: 0
actionRight: 0
actionBottomRight: 0
actionBottom: 0
actionBottomLeft: 0
actionLeft: 0

Screens
=======
Multi-Head: no
Active screen follows mouse:  no
Number of Screens: 2

Screen 0:
---------
Name: DVI-D-0
Geometry: 1920,0,1920x1080
Scale: 1
Refresh Rate: 59.933

Screen 1:
---------
Name: HDMI-0
Geometry: 0,0,1920x1080
Scale: 1
Refresh Rate: 60


Compositing
===========
Compositing is active
Compositing Type: OpenGL
OpenGL vendor string: Mesa/X.org
OpenGL renderer string: llvmpipe (LLVM 12.0.0, 256 bits)
OpenGL version string: 3.1 Mesa 21.1.2
OpenGL platform interface: GLX
OpenGL shading language version string: 1.40
Driver: LLVMpipe
GPU class: Unknown
OpenGL version: 3.1
GLSL version: 1.40
Mesa version: 21.1.2
X server version: 1.20.11
Linux kernel version: 5.12.9
Direct rendering: Requires strict binding: yes
GLSL shaders:  yes
Texture NPOT support:  yes
Virtual Machine:  no
OpenGL 2 Shaders are used

Loaded Effects:
---------------
screenshot
colorpicker
highlightwindow
startupfeedback
kscreen

Currently Active Effects:
-------------------------

Effect Settings:
----------------
screenshot:

colorpicker:

highlightwindow:

startupfeedback:
type: 1

kscreen:


Loaded Plugins:
---------------
kwin5_plugin_krunner
kwin5_plugin_nightcolor

Available Plugins:
------------------
kwin5_plugin_colord
kwin5_plugin_krunner
kwin5_plugin_nightcolor

```
Comment 1 David Edmundson 2021-06-12 12:43:58 UTC
>The kwin_x11 process takes up abnormally high amount of cpu ressources

Please include a trace with heaptrack.
Comment 2 Mike Rophone 2021-06-12 17:33:36 UTC
Created attachment 139262 [details]
heaptrack if high cpu usage kwin_x11

heaptrack of kwin_x11 directly after a reboot, while watching a youtube video (in order to exacerbate the CPU consumption issue)
Comment 3 Mike Rophone 2021-06-12 17:34:22 UTC
(In reply to David Edmundson from comment #1)
> >The kwin_x11 process takes up abnormally high amount of cpu ressources
> 
> Please include a trace with heaptrack.

Thank you for your answer, please find attached the trace in the previous comment
Comment 4 Vlad Zahorodnii 2021-06-15 06:39:31 UTC
> OpenGL renderer string: llvmpipe (LLVM 12.0.0, 256 bits)

You use software rasterizer. This results in much higher CPU usage. Please make sure that you have all necessary drivers installed.
Comment 5 Mike Rophone 2021-06-16 12:41:14 UTC
(In reply to Vlad Zahorodnii from comment #4)
> > OpenGL renderer string: llvmpipe (LLVM 12.0.0, 256 bits)
> 
> You use software rasterizer. This results in much higher CPU usage. Please
> make sure that you have all necessary drivers installed.

Oh you're right, (In reply to Vlad Zahorodnii from comment #4)
> > OpenGL renderer string: llvmpipe (LLVM 12.0.0, 256 bits)
> 
> You use software rasterizer. This results in much higher CPU usage. Please
> make sure that you have all necessary drivers installed.

You are right, the renderer is Software Rasterizer after a reboot, and switches back to my graphic card after loging out and back in. I'll try to figure out why this is happening, but if you have some idea please let me know. Thank you for your help though, this narrows the troubleshooting a great deal
Comment 6 Mike Rophone 2021-06-16 13:40:10 UTC
Seems like I fixed my issue thanks to this https://bbs.archlinux.org/viewtopic.php?id=249344

I added 
```
Section "Files"
    ModulePath      "/usr/lib/nvidia/xorg"
    ModulePath      "/usr/lib/xorg/modules"
EndSection
```
to my /etc/X11/xorg.conf and now it works. So it's a nvidia problem and I apologize for reporting it here