Even frame delivery: frames arriving unevenly 76 % → 16 %, 1 % low +28 % (10.6 → 13.6 fps), average unchanged (present pace, on by default) #4636

Closed
github-bot wants to merge 1 commit from github-bot/gh-4635 into main AGit
Owner

@⁠thatblend on GitHub · 2026-12-01 00:24 UTC · original
thatblend:perf/present-pace → main · +353 −30 · 3 files · 1 commits · closed without merging

What it changes

On main the frames a player sees come in long and short pairs even when the frame rate is steady. Same build, same drive, the switch flipped every 12 s (VICTORY_AB):

Driving in traffic, RTX 4090, no frame generation pace off (as main) with this
Frames 10 ms or more off the one before 76 % 16 % 4.7x fewer
Mean change from one frame to the next 24.6 ms 5.1 ms
95th percentile frame 64.2 ms 46.7 ms -27 %
Slowest 1 % of frames (1 % low) 10.6 fps 13.6 fps +28 %
Mean frame 37.3 ms 37.5 ms unchanged (+0.4 %, inside the scatter)

The same drive with the camera swung round six times: 74 % → 20 % uneven, 95th percentile 67.0 → 52.9 ms, 1 % low 10.0 → 12.0 fps, mean 39.8 → 40.1 ms.

What was wrong. The title presents on an even beat (its presents were 37.4 ms apart in the mean), but its threads submit the next frame's lists while a present stands, and how much of that work lies ahead of each present in the line of submissions alternates from frame to frame. The host's Present is called when the line reaches it, so it comes early after little work and late after much: frames of some 30 and 50 ms on end at a 37 ms mean. The work is done at the same rate either way; the 1 % low is poor for the timing alone. A frame-rate cap does not help, since it paces the title, which is paced already.

What this does. A present that is ready early is held until the frames' mean time since the one before it has passed (97 % of it, and never longer than three fifths of a frame), and shown by a small thread of its own (victory-pace). Only the Present call waits: the frame's copy into the back buffer is recorded and sent where it was, and the submitting thread goes on with the next submissions, which is why the mean does not move. At most one present is ever held; the next present shows it first, so the back buffers keep their turn. In the runs four presents in five were held, 11 to 15 ms each.

New file crates/victory-gpu/src/host/pace.rs (the rule is a pure function with three unit tests); in host.rs the present call and what follows it become Presenter::show, so that the same code shows a present now or later.

VICTORY_PRESENT_PACE=0 shows presents as they come, as before. It is read through toggled!, so VICTORY_AB=12,VICTORY_PRESENT_PACE compares it in one run.

Left alone: presents with frame generation (Streamline reads the tagged depth and motion vectors when the present is called, and later submissions would have written them), any present through Streamline's or FidelityFX's swap chain, and presents handed to present_aside's thread (VICTORY_PRESENT_ASIDE, VICTORY_PRESENT_QUEUE). Those are shown as they come.

What it costs. A held frame reaches the screen up to three fifths of a frame later than it could have. Nothing is dropped and no frame is shown out of order.

How it was tested

  • GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): RTX 4090, Ryzen 7 9800X3D, 96 GB; Series X profile, 2560x1440, DLSS Quality, frame generation off, ray tracing off.
  • Game runs, at e1251c31 plus this change and nothing else (release, --features ab, warm caches): a scripted drive through traffic from one save, 240 s measured after 80 s of warm-up, VICTORY_AB=12,VICTORY_PRESENT_PACE (eleven phases and some 3,300 frames a side). Frame times are our presents to the host (the frame log).
    • Before (the phases with it off): 76 % of frames 10 ms or more off the one before, 95th percentile 64.2 ms, 1 % low 10.6 fps, mean 37.3 ms.
    • After (the phases with it on): 16 %, 46.7 ms, 13.6 fps, mean 37.5 ms.
    • A second run of the same with six camera swings of 10 s: 74 % → 20 %, 67.0 → 52.9 ms, 10.0 → 12.0 fps, mean 39.8 → 40.1 ms.
  • With DLSS frame generation 2x nothing is held, as intended, and frames are generated as before (one run of the same drive on a build that has this among other changes).
  • Not run on: AMD or Intel cards, FSR frame generation, the Series S profile.
  • For shader changes, the wave sizes tested (32 and/or 64 lanes): no shader change; the translator and its cache key are untouched.
  • cargo test passed for the crates it touches: yes. At this branch's head on 7d93ee07: cargo test --locked -p victory-gpu --lib: 1136 passed, 0 failed, 66 ignored; cargo clippy --locked -p victory-gpu --all-targets -- -D warnings and the same with --all-features: clean.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #3851 addresses the same long and short frame pairs with VICTORY_FRAME_PACE, and differs in two ways that are why this is a separate request. It is off by default, so a player gets nothing until they find the switch. And where it waits is on a thread the frame is made by: the title's thread at its present, or with VICTORY_PACE_AT_PRESENT=1 the thread that presents, before the swap chain's Present; here the submitting thread is never held (only the Present call is, on a thread that does nothing else), which is what leaves the mean frame time where it was. Also related, and left alone by this: #1988 and #2201 (VICTORY_PRESENT_QUEUE, VICTORY_PACE: a swap chain on a queue of its own, paced by refresh counts; opt-in).
**@⁠thatblend** on GitHub · 2026-12-01 00:24 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4635) `thatblend:perf/present-pace` → `main` · +353 −30 · 3 files · 1 commits · closed without merging ## What it changes On main the frames a player sees come in long and short pairs even when the frame rate is steady. Same build, same drive, the switch flipped every 12 s (`VICTORY_AB`): | Driving in traffic, RTX 4090, no frame generation | pace off (as main) | with this | | |---|---|---|---| | Frames 10 ms or more off the one before | 76 % | **16 %** | 4.7x fewer | | Mean change from one frame to the next | 24.6 ms | **5.1 ms** | | | 95th percentile frame | 64.2 ms | **46.7 ms** | -27 % | | Slowest 1 % of frames (1 % low) | 10.6 fps | **13.6 fps** | +28 % | | Mean frame | 37.3 ms | 37.5 ms | unchanged (+0.4 %, inside the scatter) | The same drive with the camera swung round six times: 74 % → 20 % uneven, 95th percentile 67.0 → 52.9 ms, 1 % low 10.0 → 12.0 fps, mean 39.8 → 40.1 ms. **What was wrong.** The title presents on an even beat (its presents were 37.4 ms apart in the mean), but its threads submit the next frame's lists while a present stands, and how much of that work lies ahead of each present in the line of submissions alternates from frame to frame. The host's `Present` is called when the line reaches it, so it comes early after little work and late after much: frames of some 30 and 50 ms on end at a 37 ms mean. The work is done at the same rate either way; the 1 % low is poor for the timing alone. A frame-rate cap does not help, since it paces the title, which is paced already. **What this does.** A present that is ready early is held until the frames' mean time since the one before it has passed (97 % of it, and never longer than three fifths of a frame), and shown by a small thread of its own (`victory-pace`). Only the `Present` call waits: the frame's copy into the back buffer is recorded and sent where it was, and the submitting thread goes on with the next submissions, which is why the mean does not move. At most one present is ever held; the next present shows it first, so the back buffers keep their turn. In the runs four presents in five were held, 11 to 15 ms each. New file `crates/victory-gpu/src/host/pace.rs` (the rule is a pure function with three unit tests); in `host.rs` the present call and what follows it become `Presenter::show`, so that the same code shows a present now or later. `VICTORY_PRESENT_PACE=0` shows presents as they come, as before. It is read through `toggled!`, so `VICTORY_AB=12,VICTORY_PRESENT_PACE` compares it in one run. **Left alone:** presents with frame generation (Streamline reads the tagged depth and motion vectors when the present is called, and later submissions would have written them), any present through Streamline's or FidelityFX's swap chain, and presents handed to `present_aside`'s thread (`VICTORY_PRESENT_ASIDE`, `VICTORY_PRESENT_QUEUE`). Those are shown as they come. **What it costs.** A held frame reaches the screen up to three fifths of a frame later than it could have. Nothing is dropped and no frame is shown out of order. ## How it was tested - GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): RTX 4090, Ryzen 7 9800X3D, 96 GB; Series X profile, 2560x1440, DLSS Quality, frame generation off, ray tracing off. - Game runs, at e1251c31 plus this change and nothing else (release, `--features ab`, warm caches): a scripted drive through traffic from one save, 240 s measured after 80 s of warm-up, `VICTORY_AB=12,VICTORY_PRESENT_PACE` (eleven phases and some 3,300 frames a side). Frame times are our presents to the host (the frame log). - Before (the phases with it off): 76 % of frames 10 ms or more off the one before, 95th percentile 64.2 ms, 1 % low 10.6 fps, mean 37.3 ms. - After (the phases with it on): 16 %, 46.7 ms, 13.6 fps, mean 37.5 ms. - A second run of the same with six camera swings of 10 s: 74 % → 20 %, 67.0 → 52.9 ms, 10.0 → 12.0 fps, mean 39.8 → 40.1 ms. - With DLSS frame generation 2x nothing is held, as intended, and frames are generated as before (one run of the same drive on a build that has this among other changes). - Not run on: AMD or Intel cards, FSR frame generation, the Series S profile. - For shader changes, the wave sizes tested (32 and/or 64 lanes): no shader change; the translator and its cache key are untouched. - `cargo test` passed for the crates it touches: yes. At this branch's head on 7d93ee07: `cargo test --locked -p victory-gpu --lib`: 1136 passed, 0 failed, 66 ignored; `cargo clippy --locked -p victory-gpu --all-targets -- -D warnings` and the same with `--all-features`: clean. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #3851 addresses the same long and short frame pairs with `VICTORY_FRAME_PACE`, and differs in two ways that are why this is a separate request. It is off by default, so a player gets nothing until they find the switch. And where it waits is on a thread the frame is made by: the title's thread at its present, or with `VICTORY_PACE_AT_PRESENT=1` the thread that presents, before the swap chain's `Present`; here the submitting thread is never held (only the `Present` call is, on a thread that does nothing else), which is what leaves the mean frame time where it was. Also related, and left alone by this: #1988 and #2201 (`VICTORY_PRESENT_QUEUE`, `VICTORY_PACE`: a swap chain on a queue of its own, paced by refresh counts; opt-in).
The title presents on an even beat, but how much of the next frame's
work lies ahead of each present in the line of submissions alternates,
so the host's presents came early and late in turn: frames of some 30
and 50 ms on end at a mean of 37 ms.

A present that is ready early is now held until the frames' mean time
since the one before has passed, on a thread of its own (victory-pace).
The frame's copy into the back buffer is recorded and sent where it was;
only the call that shows it waits, and the submitting thread goes on with
the next submissions. At most one present is held: the next one shows it
first.

Left as they come: presents with frame generation, through Streamline's
or FidelityFX's swap chain, and those handed to present_aside's thread
(VICTORY_PRESENT_ASIDE, VICTORY_PRESENT_QUEUE).

Ryzen 7 9800X3D, RTX 4090, 2560x1440, DLSS Quality, no frame generation,
driving in traffic, on and off every 12 s of one run (VICTORY_AB), eleven
phases of each: frames 10 ms or more from the one before 16 % against
76 %, the 95th hundredth 46.7 against 64.2 ms, the slowest hundredth 13.6
against 10.6 frames a second, the mean 37.5 against 37.3 ms. With the
camera swung round six times: 20 % against 74 %, 52.9 against 67.0 ms,
12.0 against 10.0 frames a second.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 00:29:10 +00:00
Author
Owner

@⁠shurhundo on GitHub · 2026-12-01 02:48 UTC · original

The presenting.is_none() && !swap_chain_proxied() && !live_swap_chain() exclusion is checked once, at the moment a present becomes "ready," and it can then sit held for up to 0.6x the mean frame time before show() fires, with no recheck at show time. If Streamline frame generation gets toggled on via the live F1 menu item during that hold window, is there anything that flushes/resets a pending held present, or could one that was vetted as "safe to delay" fire late without re-validation?

**@⁠shurhundo** on GitHub · 2026-12-01 02:48 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4635#issuecomment-7299019460) The `presenting.is_none() && !swap_chain_proxied() && !live_swap_chain()` exclusion is checked once, at the moment a present becomes "ready," and it can then sit held for up to 0.6x the mean frame time before `show()` fires, with no recheck at show time. If Streamline frame generation gets toggled on via the live F1 menu item during that hold window, is there anything that flushes/resets a pending held present, or could one that was vetted as "safe to delay" fire late without re-validation?
Author
Owner

@⁠isgti07-hub on GitHub · 2026-12-01 02:57 UTC · original

Tested on an RTX 5090 32 GB, Ryzen 7 9800X3D, 64 GB RAM, Windows 11; Series X, 3840x2160 output, DLSS Quality, no frame generation, no ray tracing. Release build with --features ab: this PR's head merged onto main 7d93ee07, together with #4640 and some changes of my own (#4603, #4644, #4645 and two that only add counters and a profiler).

One run, about 15 minutes of driving through the city, VICTORY_AB=12,VICTORY_PRESENT_PACE,<one switch of mine>: 68 phases of 12 s with gameplay, 34 with the pace on and 34 off. Per phase, the per-second frame times lines (they are measured after the present is shown, so they include the hold), averaged; the effect is from a least-squares fit with the phase's draws a frame as a covariate:

per phase pace off pace on effect (± standard error)
median frame 44.5 ms 44.4 ms +0.1 ± 1.0 ms
95th percentile frame 70.5 ms 53.7 ms −16.7 ± 2.2 ms
99th percentile frame 85.9 ms 69.4 ms −16.4 ± 3.8 ms
p95 minus median, within a second 26.0 ms 9.3 ms −16.7 ± 1.4 ms
frames over 50 ms 31.3 % 22.8 % −8.1 ± 3.8 points

The same as your numbers on the RTX 4090: the mean stays where it was and the long and short frames even out. It also feels smoother in play. No crash or device loss in the run.

Not tested: frame generation (the PR leaves it alone), other cards.

🤖 Generated with Claude Code

**@⁠isgti07-hub** on GitHub · 2026-12-01 02:57 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4635#issuecomment-7299167299) Tested on an RTX 5090 32 GB, Ryzen 7 9800X3D, 64 GB RAM, Windows 11; Series X, 3840x2160 output, DLSS Quality, no frame generation, no ray tracing. Release build with `--features ab`: this PR's head merged onto main 7d93ee07, together with #4640 and some changes of my own (#4603, #4644, #4645 and two that only add counters and a profiler). One run, about 15 minutes of driving through the city, `VICTORY_AB=12,VICTORY_PRESENT_PACE,<one switch of mine>`: 68 phases of 12 s with gameplay, 34 with the pace on and 34 off. Per phase, the per-second `frame times` lines (they are measured after the present is shown, so they include the hold), averaged; the effect is from a least-squares fit with the phase's draws a frame as a covariate: | per phase | pace off | pace on | effect (± standard error) | |---|---|---|---| | median frame | 44.5 ms | 44.4 ms | +0.1 ± 1.0 ms | | 95th percentile frame | 70.5 ms | 53.7 ms | **−16.7 ± 2.2 ms** | | 99th percentile frame | 85.9 ms | 69.4 ms | **−16.4 ± 3.8 ms** | | p95 minus median, within a second | 26.0 ms | 9.3 ms | **−16.7 ± 1.4 ms** | | frames over 50 ms | 31.3 % | 22.8 % | −8.1 ± 3.8 points | The same as your numbers on the RTX 4090: the mean stays where it was and the long and short frames even out. It also feels smoother in play. No crash or device loss in the run. Not tested: frame generation (the PR leaves it alone), other cards. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
Owner

@⁠Aniseto on GitHub · 2026-12-01 07:44 UTC · original

Ran the pace tests and the victory-gpu lib suite at 0484229c on an NVIDIA Blackwell desktop part with 16 GB of VRAM, with the failing test repeated on main 5fabb46e in a separate target directory.

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB, mesh shaders) driver 32.0.16.2140 (621.40), Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5, debug build, detached worktree at the exact PR head, own CARGO_TARGET_DIR, no local patches.

cargo test -q -p victory-gpu --lib host::pace -- --test-threads=1
3 passed; 0 failed; 0 ignored; 1199 filtered out      (exit 0)

cargo test -q -p victory-gpu --lib -- --test-threads=4          (0484229c)
1135 passed; 1 failed; 66 ignored; 0 filtered out      (exit 101)

host::packed_present_tests::packed_float_single_planes_are_presented, alone at 0484229c
0 passed; 1 failed; 0 ignored; 1201 filtered out      (exit 101)

same test alone on main 5fabb46e (own CARGO_TARGET_DIR)
0 passed; 1 failed; 0 ignored; 1160 filtered out      (exit 101)

full lib on main 5fabb46e (own CARGO_TARGET_DIR)
1094 passed; 1 failed; 66 ignored; 0 filtered out      (exit 101)

The three new pace tests pass here. The one lib failure is host::packed_present_tests::packed_float_single_planes_are_presented: it panics at host.rs:17778 here and at host.rs:17713 on main, so the same pre-existing failure reproduces on this host and is not introduced by this head. The description's 1136/0/66 was on its base 7d93ee07; on current main the lib suite selects fewer tests (1161 here against 1202 at the head), and the same test fails there too. The full-tree timing and the in-world pace measurement were not repeated here.

Not tested: a title run with VICTORY_PRESENT_PACE, the 12-second A/B, DLSS/frame generation, WARP, AMD and Intel GPUs, Wine, release profile, game data.

AI-assisted (OpenCode), model: MiMo-V2.6-Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.

**@⁠Aniseto** on GitHub · 2026-12-01 07:44 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4635#issuecomment-7304432579) Ran the `pace` tests and the `victory-gpu` lib suite at `0484229c` on an NVIDIA Blackwell desktop part with 16 GB of VRAM, with the failing test repeated on `main` `5fabb46e` in a separate target directory. Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB, mesh shaders) driver 32.0.16.2140 (621.40), Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5, debug build, detached worktree at the exact PR head, own `CARGO_TARGET_DIR`, no local patches. ``` cargo test -q -p victory-gpu --lib host::pace -- --test-threads=1 3 passed; 0 failed; 0 ignored; 1199 filtered out (exit 0) cargo test -q -p victory-gpu --lib -- --test-threads=4 (0484229c) 1135 passed; 1 failed; 66 ignored; 0 filtered out (exit 101) host::packed_present_tests::packed_float_single_planes_are_presented, alone at 0484229c 0 passed; 1 failed; 0 ignored; 1201 filtered out (exit 101) same test alone on main 5fabb46e (own CARGO_TARGET_DIR) 0 passed; 1 failed; 0 ignored; 1160 filtered out (exit 101) full lib on main 5fabb46e (own CARGO_TARGET_DIR) 1094 passed; 1 failed; 66 ignored; 0 filtered out (exit 101) ``` The three new `pace` tests pass here. The one lib failure is `host::packed_present_tests::packed_float_single_planes_are_presented`: it panics at `host.rs:17778` here and at `host.rs:17713` on `main`, so the same pre-existing failure reproduces on this host and is not introduced by this head. The description's 1136/0/66 was on its base `7d93ee07`; on current `main` the lib suite selects fewer tests (1161 here against 1202 at the head), and the same test fails there too. The full-tree timing and the in-world pace measurement were not repeated here. Not tested: a title run with `VICTORY_PRESENT_PACE`, the 12-second A/B, DLSS/frame generation, WARP, AMD and Intel GPUs, Wine, release profile, game data. AI-assisted (OpenCode), model: **MiMo-V2.6-Flash Free** - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
github-bot closed this pull request 2026-12-01 18:37:06 +00:00
Author
Owner

@⁠trustno1-coder on GitHub · 2026-12-01 18:36 UTC · original

Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

**@⁠trustno1-coder** on GitHub · 2026-12-01 18:36 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4635#issuecomment-7321203296) Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
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
github/trustno1-coder--VIctory-NVIDIA!4636
No description provided.