[PERF] VulkanVblankThr at nice 0: dropped frames under CPU load (much worse with Linux 7.3's default cgroup_mode)
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 28/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- linux
- Lĩnh vực
- operating-systems, performance
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Shell
- Star
- 1.2k
- Fork
- 58
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của ValveSoftware/SteamVR-for-Linux
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
ValveSoftware/SteamVR-for-Linux#981 · 4 bình luận · 1 reaction ·
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 38/100
ValveSoftware/SteamVR-for-Linux#1097 ·
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
ValveSoftware/SteamVR-for-Linux#1095 · 2 bình luận ·
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
ValveSoftware/SteamVR-for-Linux#1094 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
ValveSoftware/SteamVR-for-Linux#1093 ·
Tất cả issue của ValveSoftware/SteamVR-for-Linux
Issue tương tự
-
Bump runtime to 26.08Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
flathub/cc.arduino.IDE2#168 ·
-
area:docs community needs-triage
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
NetSparkleUpdater/NetSparkle#759 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
sidebandstudio/clawtrate#1114 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100