https://bugs.kde.org/show_bug.cgi?id=529178
--- Comment #2 from Wodoro <[email protected]> --- Sorry, the first comment was incorrect draft meant for libdrm. ## Summary While any JavaFX application rendering with its default OpenGL (ES2/GLX) pipeline animates under Xwayland, kwin_wayland's main thread goes to ~100% of one core. Because the cursor is also driven from that thread, the whole desktop and the mouse cursor stutter. Profiling shows almost all of that time inside libdrm_amdgpu's virtual address manager, reached from kwin's linux-dmabuf `create_immed` handler (`EglBackend::testImportBuffer`) and from the buffer destruction path right after it. Other Xwayland GL/Vulkan clients (glxgears, vkcube) at the same window size do not trigger it. ## Environment - Fedora 45 KDE Plasma, Wayland session - kwin 6.8.3, Qt 6.11.2 - Xwayland 24.1.15 (xorg-x11-server-Xwayland-24.1.15-1.fc45) - Mesa 26.2.7 (RPM Fusion mesa-va-drivers-freeworld / dri-freeworld libgallium), libdrm 2.4.134 - Kernel 7.3.4-300.fc45.x86_64 - GPU: AMD Radeon RX 7900 XTX (radeonsi, navi31), kwin compositing via OpenGL ES 3.2 / EGL - Outputs: DP-1 2560x1440 @144 Hz, DP-2 1440x2560 (portrait) @120 Hz, scale 1 - JavaFX 21.0.13 (prism es2 pipeline via GLX), JDK 21 - kwin_wayland had been running ~35 hours when measured ## Steps to reproduce 1. Compile and run the mentioned `Anim.java` (a single circle with a TranslateTransition in a 1600x1000 window): ``` javac --release 21 --module-path <javafx-base.jar>:<javafx-graphics.jar> --add-modules javafx.graphics Anim.java java --module-path <javafx-base.jar>:<javafx-graphics.jar> --add-modules javafx.graphics -cp . Anim ``` 2. Watch CPU of kwin_wayland's main thread (e.g. `top -H -p $(pgrep -x kwin_wayland)`), move the mouse. ## Measurements CPU of the kwin_wayland main thread (TID == PID), averaged over 15 s, same window size: | Client | kwin main thread CPU | |---|---| | idle | 4% | | JavaFX Anim, default es2 pipeline | 99% | | JavaFX Anim, `-Dprism.vsync=false` | 55% | | JavaFX Anim, `-Dprism.order=sw` (software) | 5-6% | | `glxgears -geometry 1600x1000` | 11% | | `vkcube --width 1600 --height 1000` | 9% | Changing Adaptive Sync from "always" to "automatic", unloading the third-party kzones script and quitting xwaylandvideobridge made no difference. ## Profile `perf record -g -t <kwin main tid>` for 30 s while the JavaFX test animated (full call graph attached): ``` 77.84% libdrm_amdgpu.so.1.134.0 amdgpu_vamgr_find_va KWin::LinuxDmaBufParamsV1::zwp_linux_buffer_params_v1_create_immed KWin::EglBackend::testImportBuffer KWin::EglDisplay::importBufferAsImage KWin::EglDisplay::importDmaBufAsImage _eglCreateImageCommon > dri2_create_image_dma_buf > dri2_from_dma_bufs si_texture_from_handle > amdgpu_bo_from_handle amdgpu_va_range_alloc2 > amdgpu_vamgr_find_va 18.76% libdrm_amdgpu.so.1.134.0 amdgpu_vamgr_free_va remove_and_destroy_resource KWin::LinuxDmaBufV1ClientBuffer::~LinuxDmaBufV1ClientBuffer (EglDisplay::importBufferAsImage destroyed-lambda) _eglDestroyImageCommon > dri2_destroy_image > si_resource_destroy amdgpu_bo_destroy > amdgpu_va_range_free > amdgpu_vamgr_free_va ``` Everything else is below 0.1%. ## Interpretation - The JavaFX/Xwayland client appears to create and destroy a new linux-dmabuf wl_buffer continuously (roughly once per frame) instead of reusing a small set, so kwin runs `testImportBuffer` (EGLImage create + destroy) for each one. - Each import/free costs milliseconds because `amdgpu_vamgr_find_va` / `amdgpu_vamgr_free_va` are slow in this long-running process, presumably because the VA hole list is long or fragmented. - Either factor alone would be harmless; together they saturate kwin's main thread. Possible improvements on the kwin side: avoid a full EGLImage import in `testImportBuffer` for every `create_immed` (for example cache the result per format/modifier/size, or defer the import to first attach), or do it off the main thread. Not yet tested: whether the cost drops after restarting kwin (a fresh session), which would confirm VA-space fragmentation as the multiplier. Workaround for affected JavaFX apps: `-Dprism.order=sw`. ## Attachments - kwin-perf-callgraph.txt (perf report, call graph) -- You are receiving this mail because: You are watching all bug changes.
