Skip to content

Frame pacing: VICTORY_FRAME_PACE=auto|<ms> evens out long/short frame pairs, with the wait at our present to the host (VICTORY_PACE_AT_PRESENT=1); the frame meter's report off the presenting thread - #3851

Open
duckey-dev wants to merge 2 commits into
trustno1-coder:mainfrom
duckey-dev:frame-pacer

Conversation

@duckey-dev

Copy link
Copy Markdown

The problem

On an RX 7900 XTX at native 1440p (ray tracing off), a walk in the open world keeps about 28 frames a second, but the frames do not come evenly. They come in long/short pairs, 56 ms and then 15 ms. The median difference between two neighbouring frames is 21 ms, and 20 % of frames are over 50 ms. The average is close to 30, but what you see is closer to 18 fps with an extra frame squeezed in.

How it happens: a heavier frame lets the card fall behind. The limit on host lists in flight (VICTORY_LATE_WAIT_LISTS) then stops the submitting thread, so that present is late. Meanwhile the card drains. The next frame is already made, so it goes out at once.

The frame clock in frame.rs does not prevent this at these rates. Its ticks are absolute (start plus whole intervals of the title's 33.3 ms). A wait whose tick has already passed ends at once. Once frames take longer than the interval, the title is always behind the clock, every wait ends at once, and nothing is paced.

A second, smaller cause of uneven frames: once a second the frame meter builds its report (frame-time lines, budget, the 5-second counters) on the thread that presents. A timeline capture showed that block holding the submitting thread for 33 ms.

What it changes

1. Frame pacing (crates/victory-gpu/src/pacer.rs, new; hooks in queue.rs and host.rs). Off unless VICTORY_FRAME_PACE is set.

  • Rule: in the world, a present is not let go before the previous present's release plus a target. A present that is already past that goes at once, and the next one counts from it. Nothing is caught up, so a long frame is not followed by a burst of short ones.
  • "In the world" means world_since() is set and frames have 500 draws or more (8 frames in a row under that turn pacing off). Menus, movies and loading screens are not paced.
  • VICTORY_FRAME_PACE=<ms>: a fixed target, 1 to 1000 ms.
  • VICTORY_FRAME_PACE=auto: the first target comes from the intervals between our presents to the host, less the wait the pacer itself added. It is a high quantile of neighbour means, so a 60/18 alternation reads as 39 ms, plus 5 %. From then on the share of late presents steers it, looking at the last 32 presents once every 16: three or more late raise the target 3 %, none late lowers it 1 %, and after four looks in a row with none late it comes down 3 % a look. The target stays between 8 and 60 ms.
  • Where the wait happens:
    • by default, on the title's thread in its Present (queue.rs), before the present goes to the line or the host;
    • with VICTORY_PACE_AT_PRESENT=1, the title's present only notes its turn and goes on. The thread that presents to the host waits just before the swap chain's Present (host.rs). The frame's copy has already been sent, so the card keeps working, and the next frame's lists are submitted during the wait. This is the measured setup. With the wait on the title's thread, a capture showed that thread asleep about 27 ms a frame while the next frame's lists sat unsubmitted, and the card idle 15 to 20 ms every other frame.
  • VICTORY_PACE_SLACK=<share> (0 to 2, default 0.2, only with VICTORY_PACE_AT_PRESENT=1): how far past its turn a present may be, as a share of the target, before auto counts it as late. Frames a few ms past their turn do not show. Counting them as late kept auto 4 to 8 ms above what the walk sustains.
  • A log line every 5 seconds gives the target, the number of presents held back and for how long, the late ones, and the unpaced ones.
  • With DLSS or FSR 3 frame generation, the rendered frames pass the same Present, so they are paced before their markers. The generated frames in between are spaced by the frame-generation runtime, not by this.

2. The frame meter's report off the presenting thread (host.rs, VICTORY_METER_OFF_THREAD, on unless 0). The presenting thread takes only the meter's own figures: intervals, the present budget's window, frame and draw counts, and the 5-second counts. It hands them to a victory-meter thread, which reads the other modules' counters and writes the lines. The window caption is still set from the presenting thread, as before. 0 keeps the report on the presenting thread, as before. The lines and their contents are unchanged. Counters read off the thread may count a moment longer into one report and the same amount shorter into the next.

Switch Default Effect
VICTORY_FRAME_PACE unset (off) auto, or a target in ms
VICTORY_PACE_AT_PRESENT unset (off) 1: wait at our present to the host, not on the title's thread
VICTORY_PACE_SLACK 0.2 share of the target a present may be late before auto counts it
VICTORY_METER_OFF_THREAD on 0: report on the presenting thread, as before

Pacing is off by default. Turning it on lowers the average frame rate, for even frames (see below).

How it was tested

  • GPU and profile: RX 7900 XTX, Ryzen 7 7800X3D, Windows 11, Series X, native 2560x1440, no DLSS/FSR, frame generation off, ray tracing off. A scripted 4-minute walk in the open world, counting frames after the first 75 s. Other tuned switches were on in every row.
fps median difference between neighbouring frames frames over 50 ms over 100 ms
Before: no pacing 27.9 21 ms (pairs of 56 and 15 ms) 20 %
After: auto + VICTORY_PACE_AT_PRESENT=1 25.7 to 26.8 0.3 to 1.8 ms 2 to 8.6 % none
After: fixed 34.5 ms at our present 28.0 about 1 ms 0.7 %
  • The fixed target that suits this machine and route keeps the average and makes the frames even. auto gives up 1 to 2 fps against it. Its target sometimes wanders up for a stretch, for example after a burst of streaming, and that is where its frames over 50 ms come from.
  • Meter: the 33 ms stall is from a timeline capture. The fps effect of the meter change by itself was not measured separately.
  • Limits: one machine, one route, one resolution. These are not general numbers.
  • cargo test passed for the crates it touches: no failure that main does not have on this machine (13 pacer tests pass). Both of CI's clippy runs add no warning over main.

Not tested

Checked for overlap

🤖 Generated with Claude Code

duckey-dev and others added 2 commits November 30, 2026 10:24
…the world evenly, no sooner than the one before plus a target; VICTORY_PACE_AT_PRESENT=1 takes the wait at our present to the host (off unless set)

Without pacing a heavier frame lets the card fall behind, the bound on host
lists in flight stops the submitting thread, that present is late, and the
next one goes out at once: frames come in long/short pairs (56 and 15 ms).
The frame clock does not help at these rates: its ticks are absolute, and
once the title is behind them every wait ends at once.

Each present in the world now waits until the previous one's release plus
a target; one already past that goes at once and the next counts from it
(nothing is caught up). The target is a number of milliseconds, or auto:
first estimated from the intervals between our presents to the host, then
steered by the share of late presents (three of 32 raise it 3 %, none
lowers it 1 %, longer runs with none late 3 %), 8 to 60 ms.

VICTORY_PACE_AT_PRESENT=1: the title's present only notes its turn and goes
on; the thread that presents waits just before the swap chain's Present, so
the next frame's lists are submitted meanwhile. There a present counts late
for auto only when more than VICTORY_PACE_SLACK (0.2 unless set) of the
target past its turn.

A 5-second log line gives the target, presents held back and late ones.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…CTORY_METER_OFF_THREAD, on unless 0)

The presenting thread takes the meter's own figures (intervals, the present
budget's window, frames, the 5-second counts) and hands them to
victory-meter, which takes the other modules' counters and logs. A timeline
capture had the report stand the presenting thread 33 ms once a second. The
caption stays on the presenting thread. 0: the report on the presenting
thread, as before.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@github-actions github-actions Bot added the pr-performance Pull request: makes it faster or use less memory label Nov 30, 2026
@github-actions github-actions Bot changed the title [pr-performance] Frame pacing: VICTORY_FRAME_PACE=auto|<ms> evens out long/short frame pairs, with the wait at our present to the host (VICTORY_PACE_AT_PRESENT=1); the frame meter's report off the presenting thread Frame pacing: VICTORY_FRAME_PACE=auto|<ms> evens out long/short frame pairs, with the wait at our present to the host (VICTORY_PACE_AT_PRESENT=1); the frame meter's report off the presenting thread Nov 30, 2026
moritz-eckhard-nickel added a commit to moritz-eckhard-nickel/VIctory-NVIDIA that referenced this pull request Nov 30, 2026
…E), both frame lines kept

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-performance Pull request: makes it faster or use less memory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant