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

Open
opened 2026-11-16 23:35:37 +00:00 by HumanBean Β· 1 comment
Owner

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

  • main c9e3e542 (#1218, with the slow-frame recorder), built with scripts/dev_build.py build --prepare (Compile shaders Most, DLSS on)
  • Linux (CachyOS, kernel 7.3.3), sway (Wayland), AMD Ryzen 9 7900X, 31 GB RAM
  • NVIDIA RTX 3090 24 GB, driver 620.70.06, 3840x2160 at 240 Hz, V-Sync Auto (mailbox)
  • DLSS Quality forced (RX_VK_DLSS=1), Threaded rendering on (RX_VK_ASYNC), NVIDIA Reflex on + boost for most of the run
  • Kept out of swap (systemd-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.
  • Switches: HOS_RECORD_STUTTERS=1 HOS_SLOW_FRAME_MS=30 RX_VK_PASS_TIMING=1 RX_VK_SLOW_LOG=33 HOS_FPS_LOG=1

The numbers

About 23,700 frames played by hand. The first 7,500 are the menus (about 1.4 ms a frame).

Frames Median p99 Frames > 33 ms
7501-9000 2.1 ms 20.7 ms 9
9001-12000 12.8-14.5 ms 17.6-20.6 ms 1
13501-15000 15.0 ms 32.0 ms 12
15001-18000 14.5-14.6 ms 23.7-25.9 ms 3
18001-23730 15.2-16.1 ms 22.8-27.4 ms 5

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)

Frame ms main CPU main blocked uploads programs wait render wait GPU textures
8510 367 18.9 9.7 56.9 20.5 0 0 337
8511 181 6.8 463 1.1 0.4 6.1 0 351
8525 352 9.9 269 44.3 28.3 0.2 39.9 1071
13966 195 18.5 4.6 47.2 22.2 0 0 3177
13967 253 43.9 373 0.7 0.3 0 0 3091
13968 120 3.5 81.9 2.5 18.5 77.3 1.1 3189

The pattern is the same in both bursts:

  1. One frame with 45 to 57 ms of texture uploads and 20 to 28 ms of program loads in the replay.
  2. Then a frame where the game's main thread is blocked for 270 to 460 ms.

In the slow-frame samples of those frames (slow_frame-4 and -7), about 60% of sead::MainThread's samples are in mkwvk::wait under n_nvnSyncWait, inside libnvidia-glcore: a wait for a GPU fence. Presentation_Thread is in mkwvk::present (about 62%), and mkw_vk_recorder is 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 in n_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

  • No pipelines compiled during play: the program census shows 0 created; the play files show 1 to 4 pipelines, all from the driver's cache.
  • Swap: the game was kept out of it.
  • Virtual cores: main_vcore_ms stays 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: on at about frame 18600 and the saved option is nvidia_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 with RX_VK_REFLEX_LOG=1, on and off in the same place.

Also, turning Reflex off left no vk: NVIDIA Reflex: off line in the log. reflex_swapchain_created should 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

  • What the GPU does in those 0.3 s. The RX_VK_PASS_TIMING=1 spans of this run are in its log. A run of RX_VK_PASS_TIMING=2 through the same spot would show whether it is the passes after the upload (first use of the new textures) or the uploads' own copies.
  • Whether the uploads and program loads of frames 8510, 8525 and 13966 can be spread over several frames instead of one.

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

## 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](https://git.magicbean.dev/MagicBeanDev/Longshot/issues/1111) (worsening stutter, RTX 4090, Windows). ## The PC and the build - main `c9e3e542` (#1218, with the slow-frame recorder), built with `scripts/dev_build.py build --prepare` (Compile shaders Most, DLSS on) - Linux (CachyOS, kernel 7.3.3), sway (Wayland), AMD Ryzen 9 7900X, 31 GB RAM - NVIDIA RTX 3090 24 GB, driver 620.70.06, 3840x2160 at 240 Hz, V-Sync Auto (mailbox) - DLSS Quality forced (`RX_VK_DLSS=1`), Threaded rendering on (`RX_VK_ASYNC`), NVIDIA Reflex on + boost for most of the run - Kept out of swap (`systemd-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. - Switches: `HOS_RECORD_STUTTERS=1 HOS_SLOW_FRAME_MS=30 RX_VK_PASS_TIMING=1 RX_VK_SLOW_LOG=33 HOS_FPS_LOG=1` ## The numbers About 23,700 frames played by hand. The first 7,500 are the menus (about 1.4 ms a frame). | Frames | Median | p99 | Frames > 33 ms | |---|---|---|---| | 7501-9000 | 2.1 ms | 20.7 ms | 9 | | 9001-12000 | 12.8-14.5 ms | 17.6-20.6 ms | 1 | | 13501-15000 | 15.0 ms | 32.0 ms | 12 | | 15001-18000 | 14.5-14.6 ms | 23.7-25.9 ms | 3 | | 18001-23730 | 15.2-16.1 ms | 22.8-27.4 ms | 5 | 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`) | Frame | ms | main CPU | main blocked | uploads | programs | wait render | wait GPU | textures | |---|---|---|---|---|---|---|---|---| | 8510 | 367 | 18.9 | 9.7 | **56.9** | **20.5** | 0 | 0 | 337 | | 8511 | 181 | 6.8 | **463** | 1.1 | 0.4 | 6.1 | 0 | 351 | | 8525 | 352 | 9.9 | **269** | **44.3** | **28.3** | 0.2 | 39.9 | 1071 | | 13966 | 195 | 18.5 | 4.6 | **47.2** | **22.2** | 0 | 0 | 3177 | | 13967 | 253 | 43.9 | **373** | 0.7 | 0.3 | 0 | 0 | 3091 | | 13968 | 120 | 3.5 | 81.9 | 2.5 | 18.5 | **77.3** | 1.1 | 3189 | The pattern is the same in both bursts: 1. One frame with 45 to 57 ms of texture uploads and 20 to 28 ms of program loads in the replay. 2. Then a frame where the game's main thread is blocked for 270 to 460 ms. In the slow-frame samples of those frames (slow_frame-4 and -7), about 60% of `sead::MainThread`'s samples are in `mkwvk::wait` under `n_nvnSyncWait`, inside `libnvidia-glcore`: a wait for a GPU fence. `Presentation_Thread` is in `mkwvk::present` (about 62%), and `mkw_vk_recorder` is 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 in `n_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 - No pipelines compiled during play: the program census shows 0 created; the play files show 1 to 4 pipelines, all from the driver's cache. - Swap: the game was kept out of it. - Virtual cores: `main_vcore_ms` stays 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: on` at about frame 18600 and the saved option is `nvidia_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 with `RX_VK_REFLEX_LOG=1`, on and off in the same place. Also, turning Reflex off left no `vk: NVIDIA Reflex: off` line in the log. `reflex_swapchain_created` should 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 - What the GPU does in those 0.3 s. The `RX_VK_PASS_TIMING=1` spans of this run are in its log. A run of `RX_VK_PASS_TIMING=2` through the same spot would show whether it is the passes after the upload (first use of the new textures) or the uploads' own copies. - Whether the uploads and program loads of frames 8510, 8525 and 13966 can be spread over several frames instead of one. 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.com/claude-code) https://claude.ai/code/session_017vw8dzpak9jUZJcRrqmxhM
Collaborator

Possibly related, for context:

  • #1111 Game: Worsening stuttering across the map, worst in Hyrule Field and Death Mountain (latest RC, RTX 4090) β€” General RTX stuttering report, but lacks the measured upload-triggered GPU-fence stalls and differs in OS/GPU.
  • #395 Game: Crash in nvoglv64.dll after Vulkan 64 MB staging arena allocation failures during heavy texture uploads β€” Heavy texture-upload spikes on NVIDIA; that issue is a crash during uploads, not the reported long fence waits.
  • #1069 Memory issue: Every area load decodes ~1 GB of ASTC again, revisits included: textures come back at new addresses and the address-keyed cache misses them β€” Area-load texture decoding and uploads can cause long frame delays; separate cache/memory behavior.
  • #1120 Kokiri Forrest unusual GPU fence time in certain camera angle β€” Another NVIDIA GPU-fence stutter report, but tied to a specific camera angle rather than texture arrivals.
Possibly related, for context: - #1111 Game: Worsening stuttering across the map, worst in Hyrule Field and Death Mountain (latest RC, RTX 4090) β€” General RTX stuttering report, but lacks the measured upload-triggered GPU-fence stalls and differs in OS/GPU. - #395 Game: Crash in nvoglv64.dll after Vulkan 64 MB staging arena allocation failures during heavy texture uploads β€” Heavy texture-upload spikes on NVIDIA; that issue is a crash during uploads, not the reported long fence waits. - #1069 Memory issue: Every area load decodes ~1 GB of ASTC again, revisits included: textures come back at new addresses and the address-keyed cache misses them β€” Area-load texture decoding and uploads can cause long frame delays; separate cache/memory behavior. - #1120 Kokiri Forrest unusual GPU fence time in certain camera angle β€” Another NVIDIA GPU-fence stutter report, but tied to a specific camera angle rather than texture arrivals.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot#1268
No description provided.