[PERF] VulkanVblankThr at nice 0: dropped frames under CPU load (much worse with Linux 7.3's default cgroup_mode)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 28/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- linux
- Ambito
- operating-systems, performance
Direzione di ricerca
Start by reproducing with stress-ng --cpu $(nproc) and comparing /proc/<tid>/schedstat for VulkanVblankThr at nice 0 versus chrt -r -p 90, as the report does. The attached tools include vblank_ab.sh, cgmode_ab.sh, plot_ab.py and xr_pacing_probe.c; use the A/B block method to separate scheduling changes from run-to-run noise. Done would be a SteamVR-side policy that gives this thread realtime priority when CAP_SYS_NICE is available, with dropped-frame counts near the SCHED_RR 90 column under the same load.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
vrcompositor's VulkanVblankThr runs as SCHED_OTHER at nice 0 (RenderThread and SignalThread get nice -10). On Linux 7.3.4, when every CPU thread is busy, it spends 250-445 ms of each second runnable but waiting for a CPU, and the compositor drops roughly 400 to 1200 frames a minute (of 5400 at 90 Hz). If I give that one thread a realtime priority with chrt, the waiting goes to under 0.3 ms a second and the drops to 20-60 a minute. They come back as soon as I undo it. nice -10 is not enough: 173 a minute under the load where SCHED_RR 90 gets 20.
Linux 7.3's new default cgroup weight mode makes it much worse (concur, https://github.com/torvalds/linux/commit/fb1050ac8e40aaa014291b5b53612d27890c2b09): a cgroup's weight now grows with the number of its runnable threads, so a 32-thread job weighs far more against a single nice 0 thread in another cgroup than it used to. Switching back to the old formula inside one session (echo smp > /sys/kernel/debug/sched/cgroup_mode) takes the drops from 1049 a minute to 127.
To Reproduce
- Start SteamVR and an app (I used
hello_xr -g Vulkanfrom the OpenXR SDK), headset awake, frame timing graph open stress-ng --cpu $(nproc)in a terminalps -T -o tid,cls,rtprio,ni,comm -p $(pgrep -x vrcompositor) | grep Vblankfor the thread id, thensudo chrt -r -p 90 <tid>: most of the drops stopsudo chrt -o -p 0 <tid>: they come backcat /proc/$(pgrep -x vrcompositor)/task/<tid>/schedstatbefore and after each step: the second number is the time in ns the thread was runnable but not running
vblank_ab.sh in the attached tools zip does the switching in 90 s blocks (A B B A) and prints the numbers below; cgmode_ab.sh switches the kernel's mode instead.
Expected behavior
CPU load elsewhere on the machine doesn't turn into hundreds of dropped frames a minute. A realtime priority for VulkanVblankThr when vrcompositor has CAP_SYS_NICE would do that here.
System Information (please complete the following information):
- Distribution: Arch Linux, kernel 7.3.4
- SteamVR version: 2.19.3 beta (build 26655409). Same thread policy and the same picture on 2.18.4.
- Steam client version: 1794536281
- Opted into Steam client beta?: No
- Graphics driver version: NVIDIA 620.70.06, open kernel modules
- Gist for SteamVR System Information: not attached; I can add one if it helps. Bigscreen Beyond 2e at 90 Hz, Lighthouse tracking, KWin 6.8.2 (Wayland, DRM lease), Mesa 26.2.7.
Performance Data (optional, but very helpful):
- CPU: i9-14900KS (32 threads)
- GPU: RTX 4090
- Gist for perf top:
perf sched latencyfor the thread is in the results zip. Per wakeup under load: 1.1 ms on average and up to 51 ms at nice 0, 1.6 µs on average at SCHED_RR 90. - Link to gpuvis trace: none captured. I can make one if it helps.
Dropped frames per minute (sum of m_nNumDroppedFrames). VulkanVblankThr was switched every 90 s between nice 0 (A) and SCHED_RR 90 (B) in the order A B B A, the first 5 s of each block not counted; brackets give the lowest and highest block. SteamVR 2.19.3 unless noted:
| App, load | nice 0 (as shipped) | SCHED_RR 90 |
|---|---|---|
my test app, stress-ng --cpu 32, 8 blocks |
1216 (1084-1383) | 20 (16-23) |
my test app, kernel build (make -j32), 4 blocks |
764 | 57 |
hello_xr, stress-ng --cpu 32, 4 blocks |
422 | 28 |
SteamVR 2.18.4, my test app, stress-ng --cpu 32, 4 blocks of 60 s |
801 | 22 |
The thread is busy: at SCHED_RR 90 it uses 77-79 ms of CPU per second with hello_xr and 178-195 with my test app.
The kernel's part: cgroup weight mode switched every 60 s inside one session (S C C S S C C S), same load, thread as shipped unless noted:
smp (formula of 7.2 and earlier) |
concur (7.3 default) |
|
|---|---|---|
| my test app | 127 | 1049 |
| my test app, VulkanVblankThr at SCHED_RR 90 (4 blocks) | 1 | 12 |
hello_xr |
57 | 416 |
Screenshots
Dropped frames per 5 s for the first row of each table (drawn by plot_ab.py):
Additional context
- My test app is
xr_pacing_probe.cin the tools zip: about 2 ms of CPU and 4.5 ms of GPU work per frame. - Measured on my daily desktop with its usual background jobs running. The comparison inside each session is the evidence.
- RenderThread and SignalThread at SCHED_RR 99 instead of nice -10 made it worse under the same load: 1275 dropped frames a minute against 986 with the vblank thread at nice 0, 42 against 16 with it at SCHED_RR 90 (
renderthread-rr99.txtin the results zip).
Note: Commenters who are also experiencing this issue are encouraged to include the "System Information" and "Perf Data" sections in their replies.
- Lingua principale
- Shell
- Stelle
- 1.2k
- Fork
- 58
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di ValveSoftware/SteamVR-for-Linux
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
ValveSoftware/SteamVR-for-Linux#981 · 4 commenti · 1 reazione ·
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 38/100
ValveSoftware/SteamVR-for-Linux#1097 ·
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
ValveSoftware/SteamVR-for-Linux#1095 · 2 commenti ·
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
ValveSoftware/SteamVR-for-Linux#1094 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
ValveSoftware/SteamVR-for-Linux#1093 ·
Tutte le issue di ValveSoftware/SteamVR-for-Linux
Issue simili
-
Bump runtime to 26.08Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
flathub/cc.arduino.IDE2#168 ·
-
area:docs community needs-triage
Difficoltà 1/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
NetSparkleUpdater/NetSparkle#759 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
sidebandstudio/clawtrate#1114 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100