[PERF] VulkanVblankThr at nice 0: dropped frames under CPU load (much worse with Linux 7.3's default cgroup_mode)

Abierto
#1,072 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
28/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
linux

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

perf

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

  1. Start SteamVR and an app (I used hello_xr -g Vulkan from the OpenXR SDK), headset awake, frame timing graph open
  2. stress-ng --cpu $(nproc) in a terminal
  3. ps -T -o tid,cls,rtprio,ni,comm -p $(pgrep -x vrcompositor) | grep Vblank for the thread id, then sudo chrt -r -p 90 <tid>: most of the drops stop
  4. sudo chrt -o -p 0 <tid>: they come back
  5. cat /proc/$(pgrep -x vrcompositor)/task/<tid>/schedstat before 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 latency for 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):

stress-drops cgroup-mode-nice0-drops

Additional context

  • My test app is xr_pacing_probe.c in 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.txt in the results zip).

steamvr-vblank-tools.zip

vblank-results.zip

Note: Commenters who are also experiencing this issue are encouraged to include the "System Information" and "Perf Data" sections in their replies.

Lenguaje dominante
Shell
Estrellas
1.2k
Forks
58
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de ValveSoftware/SteamVR-for-Linux

Todos los issues de ValveSoftware/SteamVR-for-Linux

Issues similares

Más issues de Shell/Bash

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.