https://bugs.kde.org/show_bug.cgi?id=529260

            Bug ID: 529260
           Summary: Kwin experiences higher CPU and stuttering, when total
                    available memory is Low and a swap device exists
    Classification: Plasma
           Product: kwin
      Version First unspecified
       Reported In:
          Platform: openSUSE
                OS: Linux
            Status: REPORTED
          Severity: minor
          Priority: NOR
         Component: performance
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

Created attachment 198764
  --> https://bugs.kde.org/attachment.cgi?id=198764&action=edit
Kwin Debug console showfps toggle, while stuttering

***
If you're not sure this is actually a bug or valid feature request, instead
post about it at https://discuss.kde.org

If you're reporting a crash, attach a backtrace with debug symbols; see
https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
Do not paste LLM output.

Please remove this comment after reading and before submitting - thanks!
***

DESCRIPTION
I am experiencing high CPU stutters in kwin_wayland when the total amount of
available memory is low (less than 1 GB remaining) and a swap device is
enabled. I used a C program to allocate a lot of memory on my system
artificially, but it was not a key component.

The issue occurs even when no swap IO is occurring (checked with vmstat) and
when `vm.swappiness=0` is set. If anything, swap IO actually helps, since that
lowers the memory pressure of my system. I used systemd and cgroups to disable
swap entirely for Kwin, which did not help. It occurred across Zswap, regular
swap, and Zram. I was having this in some earlier unspecified 6.x kernels. The
only solution at the moment, to disable it completely, is to run `swapoff -a`.
Yet, I need swap for certain things...

I decided to profile the process that was causing it, kwin_wayland. I also
attached a picture of the Kwin debug console with showfps toggled where you can
see a flat line (no lag) followed by a big spike (the stutter).

If it is ok with you all, here is a Google drive link to the profiler data. It
was way larger than I expected.

https://drive.google.com/drive/folders/1vJF8dy4Ijb9G2WK8OKZw88rPTXr9fjRk?usp=sharing

Filenames are self-explanatory: "stress" meant lagging and "normal" meant with
swap disabled, both under the same memory conditions. There are library calls
to EGL mesa, dri, gallium and GI ioctl that take quite a lot of CPU. This issue
clearly feels like a kernel problem given the condition of Linux for Lunar Lake
at the moment. I do not disagree. I just want to contact KDE first to get
advice on the bug. Yes, it also occurs on Gnome.

STEPS TO REPRODUCE
1. Create a swap file or partition, mkswap, then swapon.
2. Run `sysctl -w vm.swappiness=0` (optional).
3. Look at the output of free -hm and allocate close to the amount listed under
"Available".
3b. Use the provided C program by editing the macro and compiling.
3c. Wait until it says "Done".
4. Open the Kwin debug console and click "showfps" or start profiling, then
trigger some stuttering by hovering over the taskbar, dragging windows,
minimizing and maximizing windows, spawning new windows.
5. Then, repeat the test after running `swapoff -a`.

OBSERVED RESULT
Stuttering every few seconds, represented as a quick interruption, lasting
several milliseconds.

EXPECTED RESULT
Zero stuttering, same as when swap is disabled. Perf profiling attached for
Plasma and Gnome of baseline performance.

SOFTWARE/OS VERSIONS
Operating System (available in the Info Center app, or by running `kinfo` in a
terminal window):
KDE Plasma Version: 6.8.3
KDE Frameworks Version: 6.32.0
Qt Version: 6.12.0

ADDITIONAL INFORMATION
Intel Core Ultra 256V, Arc 130/140V (xe2), 16GB RAM, 1 TB NVMe storage. Laptop
model is 15ILL9. Running OpenSUSE Tumbleweed on kernel 7.3.5.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to