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

            Bug ID: 520084
           Summary: Excessive DRM_IOCTL_MODE_ATOMIC affecting input
                    latency
    Classification: Plasma
           Product: kwin
      Version First 6.6.4
       Reported In:
          Platform: NixOS
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

DESCRIPTION

I've been measuring desktop latency on KWin Wayland, and noticed it degrading
in two scenarios:

1. Bursty input from a mouse (amplitude of the spike seems correlated with the
polling rate of the device)
2. A specific app being composited (not-minimized and on the current virtual
desktop). The app is the Zed editor (zed.dev)

I don't know what the root cause is, but I've found a pretty good proxy metric
for the degradation, hence naming a specific IOCTL in the title:

```console
$ kwincg="/sys/fs/cgroup$(systemctl --user show -p ControlGroup --value
plasma-kwin_wayland.service)"
$ sudo bpftrace -e '
tracepoint:syscalls:sys_enter_ioctl
/cgroup == cgroupid("'$kwincg'") && args->cmd == 0xc03864bc/
{
  $flags = *uptr((uint32 *)args->arg);
  @mode_atomic[$flags & 0x100 ? "test" : "commit"] = count();
}

interval:s:1
{
  print(@mode_atomic);
  clear(@mode_atomic);
}
'
```

Specifically: on an idle desktop, at 120Hz refresh rate (VRR disabled), it
bottoms out at ~4 of these ioctls with the ATOMIC_TEST_ONLY flag and ~4
without, per second. With the Zed window shown, it jumps to its max sustained
rate of 120/s with the flag and 120/s without it.

When this happens, the click-to-photon latency floor jumps higher, and the
distribution of measurements gets wider as well.

A similar impact is felt whenever I start to move my mouse (the bursty behavior
I described earlier):

```
# idle desktop baseline:
@mode_atomic[commit]: 4
@mode_atomic[test]: 4
@mode_atomic[commit]: 4
@mode_atomic[test]: 4
@mode_atomic[commit]: 4
# start of continuous movement, ioctl rate overshoots:
@mode_atomic[commit]: 127
@mode_atomic[test]: 1839
@mode_atomic[commit]: 128
@mode_atomic[test]: 947
@mode_atomic[test]: 120
# movement continues, but now the rate of ioctls stabilizes
@mode_atomic[commit]: 120
@mode_atomic[test]: 120
@mode_atomic[commit]: 120
# movement stops, going back to idle:
@mode_atomic[test]: 64
@mode_atomic[commit]: 65
@mode_atomic[test]: 5
@mode_atomic[commit]: 5
```

STEPS TO REPRODUCE
1. Start monitoring ioctls with bpftrace
2. Open a Zed editor window
3. Observe the sustained rate maxing out

OBSERVED RESULT

While the zed window is being composited:

```
@mode_atomic[commit]: 120
@mode_atomic[test]: 120
```

EXPECTED RESULT

Should stay at a low level while idle, same as with every other app's window
not causing this behavior:

```
@mode_atomic[commit]: 4
@mode_atomic[test]: 4
```


SOFTWARE/OS VERSIONS
Operating System: NixOS 26.05
KDE Plasma Version: 6.6.4
KDE Frameworks Version: 6.25.0
Qt Version: 6.11.0

ADDITIONAL INFORMATION

No such effect, as far as I can tell, is present in full-screen apps.

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

Reply via email to