Stop the hybrid-GPU checks keeping the discrete GPU awake - #11038
Stop the hybrid-GPU checks keeping the discrete GPU awake#11038ReidenXerx wants to merge 2 commits into
Conversation
lspci reads PCI config space, and the kernel must runtime-resume a suspended device to answer that. On a hybrid laptop the discrete GPU this detector is asking about is usually asleep, so the check woke the very card it was measuring, then held it awake for the driver's autosuspend tail. Count display-class devices from the cached sysfs IDs instead. 0x03* covers VGA (0x0300), 3D (0x0302) and Display (0x0380), matching what the lspci grep counted. omarchy-hw-nvidia and omarchy-hw-nvidia-gsp already avoid lspci for this reason. The test expresses the GPU count as PCI device fixtures under OMARCHY_PCI_DEVICES_PATH rather than stubbing lspci, and asserts the detector contains no lspci call outside comments.
Setting __GLX_VENDOR_LIBRARY_NAME=nvidia makes every OpenGL client render on the discrete GPU. On a hybrid laptop the panel hangs off the integrated GPU, so those frames still have to be copied back to reach the display: the card wakes at login and never idles again, costing battery for no visible gain. Skip the pin when omarchy-hw-hybrid-gpu reports a hybrid system, leaving the Mesa default in place and letting the discrete card be opted into per application via prime-run or __NV_PRIME_RENDER_OFFLOAD=1. Desktops where NVIDIA actually drives the display are not hybrid, so they are unaffected.
|
A datapoint from an AMD+NVIDIA machine in favour of the sysfs count, plus the reason the Hardware: Framework Laptop 16, Ryzen AI 9 HX 370 / Radeon 890M ( Why the fallback runs at all. The gate bounds Which read does it, measured. From One more waker in the same shell start, outside this PR: the bar's dictation indicator runs Disclosure: this diagnosis and write-up were produced by Claude (Fable 5.1, via Claude Code) working on my laptop; the measurements are from my machine and I reviewed the text before posting. |
On a hybrid laptop the discrete GPU is meant to stay runtime-suspended until something asks for it. Two things in Omarchy stop that happening. They are separate bugs, but the second depends on the first being fixed, so they are here together as two commits.
Count GPUs from sysfs instead of lspci
omarchy-hw-hybrid-gpucounted GPUs withlspci | grep -cE 'VGA|3D|Display'.lspcireads PCI config space, and the kernel has to runtime-resume a suspended device to answer:So the detector woke the very card it was asking about, and the card then stayed powered for the driver's autosuspend tail (~18s on the machine below) before settling back to D3cold.
That matters because the Omarchy shell re-runs its menu-state probes, and this is one of them:
Counting display-class devices from the cached sysfs IDs gives the same answer without touching config space.
0x03*covers VGA (0x0300), 3D (0x0302) and Display (0x0380) — the same set thelspcigrep matched.omarchy-hw-nvidiaandomarchy-hw-nvidia-gspalready avoidlspcifor exactly this reason; this brings the third detector in line.The test now expresses the GPU count as PCI device fixtures under
OMARCHY_PCI_DEVICES_PATHinstead of stubbinglspci, keeps an ethernet device in the fixture to prove non-display classes are not counted, and asserts the detector has nolspcicall outside comments.Don't pin GLX to NVIDIA on hybrid laptops
nvidia.luasets__GLX_VENDOR_LIBRARY_NAME=nvidiawhenever an NVIDIA card is present. On a hybrid laptop that points every OpenGL client at the discrete GPU, but the panel hangs off the integrated GPU — so the frames still have to be copied back to reach the display. The card wakes at login and never idles again: a constant battery cost for no visible gain.This skips the pin when
omarchy-hw-hybrid-gpureports a hybrid system, leaving the Mesa default in place and letting the discrete card be opted into per application (prime-run, or__NV_PRIME_RENDER_OFFLOAD=1). Desktops where NVIDIA actually drives the display are not hybrid, so they are unaffected.This is also why the ordering matters: the guard calls
omarchy-hw-hybrid-gpuduring Hyprland's config load, which is only safe once that detector has stopped resuming the GPU.Testing
test/shell.d/hw-hybrid-gpu-test.shpasses (10 assertions, including two new ones), at each commit independently../test/shellshows no new failures. Four files fail on this machine, but they fail identically on unmodifiedquattro:config,snapperandunowned-system-pathsneed anomarchy-pkgscheckout that is not present, andlocateis unrelated (see below).nvidia580.x, RTD3). With both changes the discrete GPU reaches and stays atD3coldwhile idle instead of being woken by the shell's periodic probes.Unrelated, noticed while testing
test/shell.d/locate-test.shdoesrglob("*")overbin/,install/andmigrations/and callsread_text()on every file, so it dies with aUnicodeDecodeErrorif any binary file is present in those trees. A straybin/__pycache__/*.pyc(left by runningbin/omarchy-agent-usage-*) is enough to trigger it. Not touched here since it is a separate concern — happy to send a follow-up if useful.