DankMaterialShell icon indicating copy to clipboard operation
DankMaterialShell copied to clipboard

IPC latency is very high

Open AveryanAlex opened this issue 8 months ago • 5 comments

Compositor

Niri

Distribution

NixOS

If Other, please specify

No response

Select your Installation Method

Distro Packaging

Was this your original Installation method?

Yes

If no, specify

No response

dms doctor -vC

Click to expand ## DMS Doctor Report

System

  • [ok] Operating System: NixOS 26.05 (Yarara)
    • Supported for runtime (install via NixOS module or Flake)
  • [ok] Architecture: amd64
  • [ok] Display Server: Wayland
    • WAYLAND_DISPLAY=wayland-1

Versions

  • [ok] DMS CLI: dms 1.4.4+date=2026-03-20_1f64bb8
    • /nix/store/srrs2h9rvaibfvx7mr4ahv0c12shvdsg-dms-shell-1.4.4+date=2026-03-20_1f64bb8/bin/.dms-wrapped
  • [ok] Quickshell: quickshell 0.2.1, revision 41828c4180fb921df7992a5405f5ff05d2ac2fff, distributed by: Official-Nix-Flake
    • /etc/profiles/per-user/alex/bin/qs
  • [ok] DMS Shell: 1.4.4+date=2026-03-20_1f64bb8
    • /nix/store/srrs2h9rvaibfvx7mr4ahv0c12shvdsg-dms-shell-1.4.4+date=2026-03-20_1f64bb8/share/quickshell/dms

Installation

  • [ok] DMS Configuration: Found
    • /nix/store/srrs2h9rvaibfvx7mr4ahv0c12shvdsg-dms-shell-1.4.4+date=2026-03-20_1f64bb8/share/quickshell/dms
  • [ok] shell.qml: Present
    • /nix/store/srrs2h9rvaibfvx7mr4ahv0c12shvdsg-dms-shell-1.4.4+date=2026-03-20_1f64bb8/share/quickshell/dms/shell.qml
  • [info] Install Type: Nix store
    • /nix/store/srrs2h9rvaibfvx7mr4ahv0c12shvdsg-dms-shell-1.4.4+date=2026-03-20_1f64bb8/share/quickshell/dms

Compositor

  • [ok] niri: niri unstable 2026-03-10 (commit b07bde3ee82dd73115e6b949e4f3f63695da35ea)
    • /run/current-system/sw/bin/niri
  • [info] Active: niri

Quickshell Features

  • [ok] Polkit: Available
    • Authentication prompts
  • [ok] IdleMonitor: Available
    • Idle detection
  • [ok] IdleInhibitor: Available
    • Prevent idle/sleep
  • [ok] ShortcutInhibitor: Available
    • Allow shortcut management (niri)

Optional Features

  • [ok] accountsservice: Available
    • User accounts
  • [ok] power-profiles-daemon: Available
    • Power profile management
  • [ok] logind: Available
    • Session management
  • [ok] cups-pk-helper: Available
    • Printer management
  • [info] I2C/DDC: No monitors detected
    • External monitor brightness control
  • [ok] qt6-imageformats: Installed (4 formats)
    • Formats: WebP, TIFF, JP2, ICNS (/nix/store/qzsfgk79hv21dksvmc38rl5fz9xlfcr5-qtimageformats-6.10.2/lib/qt-6/plugins/imageformats)
  • [ok] kimageformats: Installed (4 formats)
    • Formats: AVIF, HEIF, JXL, EXR (/nix/store/4dbjqmnphycqjapsm3b8chpp9gvm9blh-kimageformats-6.24.0/lib/qt-6/plugins/imageformats)
  • [ok] Terminal: alacritty
  • [ok] Network: NetworkManager
    • NetworkManager present. Using NM API.
  • [ok] matugen: Installed
    • Dynamic theming
  • [ok] dgop: Installed
    • System monitoring
  • [ok] cava: Installed
    • Audio visualizer
  • [ok] khal: Installed
    • Calendar events
  • [info] danksearch: Not installed
    • File search
  • [info] fprintd: Not installed
    • Fingerprint auth

Config Files

  • [ok] settings.json: Present
    • /home/alex/.config/DankMaterialShell/settings.json
  • [info] clsettings.json: Not yet created
    • /home/alex/.config/DankMaterialShell/clsettings.json
  • [info] plugin_settings.json: Not yet created
    • /home/alex/.config/DankMaterialShell/plugin_settings.json
  • [ok] session.json: Present
    • /home/alex/.local/state/DankMaterialShell/session.json
  • [ok] dms-colors.json: Present
    • /home/alex/.cache/DankMaterialShell/dms-colors.json

Services

  • [ok] dms.service: enabled, active
  • [ok] greetd: enabled

Environment

  • [info] QT_QPA_PLATFORMTHEME: Not set
  • [info] QS_ICON_THEME: Not set

Summary: 0 error(s), 0 warning(s), 30 ok

Description

Internal dms ipc command adds high latency. qs ipc works much faster:

  • dms ipc spotlight toggle: p50 ~190 ms, avg ~193 ms
  • qs ipc --pid <pid> call spotlight toggle: p50 ~100 ms, avg ~142 ms

qs ipc still has noticeably more latency than niri-native actions, so it will be good if dms and qs ipc will be optimized to near-instant speed.

Expected Behavior

Dms ipc wrapper adds ~0 latency

Steps to Reproduce

Performance testing script and report from GPT-5.4:

# `dms ipc` latency is noticeable/high for interactive actions

Summary

dms ipc feels noticeably slow for interactive actions like launcher, notifications, and power menu toggles.

On my machine, even simple dms ipc calls have a visible baseline latency, and UI toggle actions are slower still. Direct qs ipc calls against the running shell are materially faster than dms ipc for equivalent actions.

This makes it look like a significant part of the delay is in the dms ipc client path itself, not only in the shell action handler.

Environment

  • DMS: 1.4.4+date=2026-03-20_1f64bb8
  • Quickshell: 0.2.1
  • OS: NixOS
  • Session: niri
  • DMS is running as a long-lived user systemd service

What I measured

CLI baseline

  • dms version: ~76–95 ms

Simple IPC read

  • dms ipc theme getMode: p50 ~160 ms, avg ~185 ms

Interactive toggles via dms ipc

  • dms ipc spotlight toggle: p50 ~190 ms, avg ~193 ms
  • dms ipc notifications toggle: p50 ~177 ms, avg ~176 ms

In some earlier spot measurements, toggle actions also reached the ~300–560 ms range.

Direct qs ipc against the running shell

Using the live Quickshell PID directly:

  • qs ipc --pid <pid> call theme getMode: p50 ~74 ms, avg ~108 ms
  • qs ipc --pid <pid> call spotlight toggle: p50 ~100 ms, avg ~142 ms
  • qs ipc --pid <pid> call notifications toggle: p50 ~77 ms, avg ~118 ms

So direct qs ipc is consistently faster than dms ipc for equivalent actions.

Reproduction

1. Make sure DMS is already running

systemctl --user status dms.service --no-pager

2. Measure dms ipc

python - <<'PY'
import subprocess, time, statistics
batches = {
    'dms_theme': [["dms","ipc","theme","getMode"] for _ in range(8)],
    'dms_spotlight': [["dms","ipc","spotlight","toggle"] for _ in range(8)],
    'dms_notifications': [["dms","ipc","notifications","toggle"] for _ in range(8)],
}
for name, cmds in batches.items():
    vals=[]
    for cmd in cmds:
        t0=time.perf_counter()
        p=subprocess.run(cmd, capture_output=True, text=True)
        dt=(time.perf_counter()-t0)*1000
        if p.returncode==0:
            vals.append(dt)
    print(f"{name} count={len(vals)} min_ms={min(vals):.1f} p50_ms={statistics.median(vals):.1f} avg_ms={statistics.mean(vals):.1f} max_ms={max(vals):.1f}")
PY

3. Measure direct qs ipc against the live shell

Find the Quickshell PID first from systemctl --user status dms.service or similar, then:

qs ipc --pid <pid> show
python - <<'PY'
import subprocess, time, statistics
PID = "<pid>"
batches = {
    'qs_theme': [["qs","ipc","--pid",PID,"call","theme","getMode"] for _ in range(8)],
    'qs_spotlight': [["qs","ipc","--pid",PID,"call","spotlight","toggle"] for _ in range(8)],
    'qs_notifications': [["qs","ipc","--pid",PID,"call","notifications","toggle"] for _ in range(8)],
}
for name, cmds in batches.items():
    vals=[]
    for cmd in cmds:
        t0=time.perf_counter()
        p=subprocess.run(cmd, capture_output=True, text=True)
        dt=(time.perf_counter()-t0)*1000
        if p.returncode==0:
            vals.append(dt)
    print(f"{name} count={len(vals)} min_ms={min(vals):.1f} p50_ms={statistics.median(vals):.1f} avg_ms={statistics.mean(vals):.1f} max_ms={max(vals):.1f}")
PY

Expected behavior

Interactive actions like launcher, notifications, and power menu toggles should feel near-instant, especially when DMS is already running.

Actual behavior

dms ipc has noticeable latency on every invocation, enough to feel laggy on hotkeys. The daemon is already warm, but the command path still feels slow.

Error Messages/Logs

No response

Screenshots/Recordings

No response

AveryanAlex avatar Mar 23 '26 00:03 AveryanAlex

fd1facfce81686747f9102572f9005da3355f2db cuts it down, but I'm not sure if it will cause regressions or any unintended behavior for others. There will always be some fork+exec overhead when calling any CLI command, albeit 142ms seems excessively high.

Part of the problem was the --any-display check which spawned a quickshell command to check for the capability (since only quickshell-git has the regression that requires the flag), but targeting pid directly eliminates it.

before:
❯ hyperfine 'dms ipc call spotlight toggle'
Benchmark 1: dms ipc call spotlight toggle
  Time (mean ± σ):      75.3 ms ±  13.1 ms    [User: 45.1 ms, System: 20.0 ms]
  Range (min … max):    58.9 ms … 103.2 ms    32 runs

after:
❯ hyperfine 'dms ipc call spotlight toggle'
Benchmark 1: dms ipc call spotlight toggle
  Time (mean ± σ):      49.5 ms ±  16.2 ms    [User: 24.4 ms, System: 10.1 ms]
  Range (min … max):    31.1 ms …  79.6 ms    83 runs

bbedward avatar Mar 23 '26 14:03 bbedward

On my system, IPC still has some noticeable extra delay compared to opening UIs directly with the mouse (which feels pretty much instant), here's my benchmark on dms 1.5-beta+date=2026-03-27_62c6090

 > hyperfine 'dms ipc call spotlight toggle'
Benchmark 1: dms ipc call spotlight toggle
  Time (mean ± σ):     155.7 ms ±  38.7 ms    [User: 70.6 ms, System: 27.8 ms]
  Range (min … max):    96.3 ms … 237.1 ms    28 runs

2gibbert avatar Mar 28 '26 18:03 2gibbert

Wondering if anything can be done about this. My hotkeys to open the notifications, launcher, etc. are annoyingly slow.

b0o avatar May 27 '26 04:05 b0o

Another place this shows up is the default niri volume binds, which spawn dms ipc call audio increment / decrement on every wheel detent.

Those handlers read the sink volume and write an absolute level. On a HyperX Cloud III S Wireless (USB 03f0:06be) the wheel emits volume-key edges faster than the calls finish, so detents collapse into one step or the slider jumps backward. Here dms ipc call audio status is only about 9 ms on dms-shell 1.6.3, and that is already enough. niri also repeats the binds while the key is held.

Relative PipeWire steps avoid the read-modify-write:

XF86AudioRaiseVolume allow-when-locked=true repeat=false {
    spawn "wpctl" "set-volume" "@DEFAULT_AUDIO_SINK@" "3%+" "-l" "1.0";
}
XF86AudioLowerVolume allow-when-locked=true repeat=false {
    spawn "wpctl" "set-volume" "@DEFAULT_AUDIO_SINK@" "3%-";
}

Continuous turning then tracks. A single detent can still do nothing, and a few turns still step backward; those look like the headset rather than IPC. Write-up: https://gist.github.com/hyperverse/9d8a9ebf06013ddaa99b74bd534247cf

hyperverse avatar Oct 11 '26 15:10 hyperverse

Thanks, we made some adjustments here that should alleviate it. The IPC latency itself should have closed this one out a couple months ago.

purian23 avatar Oct 11 '26 16:10 purian23