Game: 200-470 ms stutters when many new textures arrive: the main thread waits ~0.3 s on a GPU fence after a frame of uploads (RTX 3090, Linux) #1268
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot#1268
Loadingβ¦
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What happens
Playing main with DLSS on an RTX 3090, the game is smooth most of the time (median frame 14.6 ms), but every so often there is a burst of long frames of 200 to 470 ms, plus small 30 to 45 ms stutters in between. In this session they came in two bursts, each when a lot of new textures arrived at once (the renderer's texture count jumped from 337 to 1071, then again near 3100).
Possibly related: #1111 (worsening stutter, RTX 4090, Windows).
The PC and the build
c9e3e542(#1218, with the slow-frame recorder), built withscripts/dev_build.py build --prepare(Compile shaders Most, DLSS on)RX_VK_DLSS=1), Threaded rendering on (RX_VK_ASYNC), NVIDIA Reflex on + boost for most of the runsystemd-run --user --scope -p MemorySwapMax=0): a first session showed 2.2 GB of the game in swap, and this rules that out. The game peaked at 13.5 GB.HOS_RECORD_STUTTERS=1 HOS_SLOW_FRAME_MS=30 RX_VK_PASS_TIMING=1 RX_VK_SLOW_LOG=33 HOS_FPS_LOG=1The numbers
About 23,700 frames played by hand. The first 7,500 are the menus (about 1.4 ms a frame).
The recorder wrote 21 slow frames (
logs/slow_frame-<n>.txt): two of 470 and 421 ms, one of 80 ms, and 18 of 30 to 68 ms.The two big bursts (frame trace,
logs/longshot_frames.csv)The pattern is the same in both bursts:
In the slow-frame samples of those frames (slow_frame-4 and -7), about 60% of
sead::MainThread's samples are inmkwvk::waitundern_nvnSyncWait, insidelibnvidia-glcore: a wait for a GPU fence.Presentation_Threadis inmkwvk::present(about 62%), andmkw_vk_recorderis idle (Recorder::idle/wait_for). So the CPU side has handed over its work, and the main thread waits about 0.3 s for the GPU to finish work submitted around those uploads.A first session without the recorder (
HOS_SAMPLE_ALL, main thread only) showed the same thing at its three bursts: 528, 478, 352 and 223 ms frames, main thread inn_nvnSyncWait.The small stutters (30-45 ms)
These have no wait on the GPU. The main thread is blocked 15 to 45 ms in
event_wait(on another game thread), often with 2 to 18 ms of program loads in the same frame (frames 9953, 13977-13985, 19228), or 6 to 7 ms of memory sync (15337-15338).Not the cause
main_vcore_msstays at 1.3 ms or less in every slow frame.Reflex
Reflex was on + boost until about 3/5 of the way in, then on, then off (the log has
Reflex: onat about frame 18600 and the saved option isnvidia_reflex=0). The player felt more lag with it on. In frame times, turning it off changed nothing measurable: median 14.5-15 ms before, 15.2-16 ms after, the same p99 and count of slow frames. Input latency wasn't measured. That needs a run withRX_VK_REFLEX_LOG=1, on and off in the same place.Also, turning Reflex off left no
vk: NVIDIA Reflex: offline in the log.reflex_swapchain_createdshould write one when the swapchain is made again without latency mode. This is worth a look, as is whether Off actually took effect before the next swapchain.Next
RX_VK_PASS_TIMING=1spans of this run are in its log. A run ofRX_VK_PASS_TIMING=2through the same spot would show whether it is the passes after the upload (first use of the new textures) or the uploads' own copies.The recordings (game log, frame trace, 21 slow-frame files) are on the tester's PC and can be shared if useful. They hold function addresses and timings, no game data.
π€ Generated with Claude Code
https://claude.ai/code/session_017vw8dzpak9jUZJcRrqmxhM
Possibly related, for context: