Repository navigation
Desktop stutters under memory pressure: protect the session and foreground apps, fence background work (cgroup defaults) #16444
dragosol
started this conversation in
Suggestions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
System details: Dell XPS 13 9350, Intel Core Ultra 7 256V (Lunar Lake, Arc 140V on
xe), 16 GB RAM, Omarchy 4.0.4, Hyprland 0.56.2, kernel 7.2.5-3-omarchy. Stock zram + swappiness 150 + MGLRU + systemd-oomd as Omarchy ships them.What happens
On a 16 GB laptop, any heavy background job (a build, a headless browser test, an AI agent's tool commands) makes the whole desktop stutter: cursor, scrolling and window moves freeze for 0.3–1.5 s at a time, repeatedly, until the job ends. Nothing gets OOM-killed, because this is the stall phase before oomd's thresholds. Omarchy's oomd setup handles the kill case well; it doesn't help with this one.
Measured
I wrote a small sampler: it pings the compositor 10×/s over its IPC socket, logs PSI and per-process faults every second, and captures the kernel stack of Hyprland's main thread whenever it stalls. Today, while a Playwright Chromium test (~190% CPU) and two leftover headless browsers ran in the background:
drm_exec_lock_obj < xe_validation_exec_lock < xe_exec_ioctl. Hyprland is waiting on a GPU buffer lock while xe/TTM evicts buffers under memory pressure. It's neither running nor waiting for CPU, so CPU priority alone can't fix it.Why the defaults allow it
memory_recursiveprot), and the top of the user tree has none.user.slice,user-1000.sliceanduser@1000.servicedefault toMemoryLow=0, so anyMemoryLowset lower down (session, compositor, apps) is capped at zero. I had raised these to 2G earlier, and even then Hyprland, the shell and the foreground apps all shared 2G.app-graphical.slicescope tree as the browser you're scrolling, with the same weight and the same reclaim priority.SCHED_OTHER(noCAP_SYS_NICE,LimitRTPRIO=0onwayland-wm@hyprland.desktop.service), so its built-ingainRealTime()never takes effect. I've reported that to Hyprland separately.What fixed it here (suggested defaults)
user.slice,user-1000.slice,user@.service→MemoryLow≈ 50% of RAM (8G here) andMemoryMin=1G, so protections below actually apply.session.slice→MemoryLow=2G,MemoryMin=1G;wayland-wm@hyprland.desktop.service→MemoryMin=1G(the compositor's working set can never be reclaimed).app-graphical.slice→MemoryLow(4G here), so interactive apps beat background work in reclaim.MemoryHigh=3G,CPUWeight=5, E-cores only (by affinity, sincecpusetisn't delegated to user managers), idle ioprio. Builds and tests go there (systemd-run --user --slice=… make), or a tiny watcher moves known background command trees in. Omarchy could ship the slice plus anomarchy-launch-backgroundhelper.After the change, under the same kind of load: 0 stalls >200 ms, worst 115 ms so far. The first background job ended a few minutes in, so I'm running a full 4-hour comparison and will post those numbers here.
All of these are
systemctl set-propertydrop-ins, persistent and trivially reversible. I'm happy to turn them into a migration PR if this direction is welcome.All reactions