Skip to content

perf(gpu/queue): let the title's present go once the frame ahead has at most n submissions left (VICTORY_PRESENT_RELEASE, 2 in play) - #330

Open
PiloteCode wants to merge 1 commit into
Androtim:mainfrom
PiloteCode:pr/present-release

Conversation

@PiloteCode

Copy link
Copy Markdown

Summary

With the submission line (VICTORY_ASYNC_SUBMIT / VICTORY_THIN), a title thread presenting frame N waits until present N-1 has been done by our thread. Our line and the card then run dry while the title has not started frame N+1 (4.2-6.6 ms a frame of an empty queue in a new game's street, nearly all of it while the title had not submitted).

VICTORY_PRESENT_RELEASE=<n> lets the title go on once present N-1 is being done or has at most n submissions in front of it in the line (0: when we take it). It is less than VICTORY_SUBMIT_FRAMES=2 (a whole frame more in the line), and never lets the title run with two presents ahead of its own. Unset in the layer (unchanged behaviour); 2 in play's settings and in verify-world.ps1's PlayParity block. Diagnostics builds can switch it inside a run (VICTORY_AB; on = the variable's n, else 0). The lane's frame line now says how many presents a frame were let go early.

In our fork's play defaults since 30 Nov.

Changes

  • crates/victory-gpu/src/queue/behind.rs: Lane::wait_presents_ahead and Lane::released (same lane state, no new locks); release_ahead(); present() uses it; frame-line counter; unit test the_title_is_let_go_as_the_present_ahead_comes_near.
  • apps/victory/src/play.rs, scripts/verify-world.ps1: VICTORY_PRESENT_RELEASE=2 (parity kept).

Rig Specs Tested On (our fork, not this tree)

  • CPU: Intel i9-14900KF (32 logical processors); also held to 12 logical processors (6-core stand-in)
  • GPU & VRAM: RTX 5090 32 GB; 12 GB card-budget stand-in for the 12-thread run
  • System RAM: 128 GB
  • OS & GPU Driver: Windows 11; driver not recorded

Run Settings & Profile

  • Profile: Series X, 1440p class with DLSS (full machine); 1080p (12-thread stand-in); RT off; FG off
  • Method: in-run A/B with VICTORY_AB (4-8 switches, 10 s phases in a mixed order, 56 phases at the busiest place of a saved game), drift fitted; n = 2
  • Scene: a busy, crowded street area, ~15 min per run

Measurements & Verification

Run Machine Frame median Frame p90 Slowest 1 % Title waiting at presents (raw arm means, off -> on)
big-cp-3 32 threads -0.94 +- 0.84 ms -7.46 +- 2.18 ms -23 +- 14 ms 17.1 -> 14.2 ms/frame
big-cp-4 32 threads -1.12 +- 0.75 ms -2.00 +- 1.78 ms -0.2 +- 8.1 ms 16.6 -> 14.0 ms/frame
both (inverse-variance) 32 threads -1.0 +- 0.6 ms -4.2 +- 1.4 ms -6 +- 7 ms
big-cp-5 12 threads, 1080p -0.57 +- 0.53 ms -0.09 +- 0.91 ms -1.0 +- 3.8 ms 9.8 -> 7.9 ms/frame
  • 0.60-0.75 presents a frame were let go early; the time from the title's present call to ours shown was not longer (80.3 vs 81.1 ms and 82.1 vs 83.6 ms with/without): no added latency.
  • Pictures compared at fixed points: the same. No crash or device removal.
  • Automated checks on this branch (rebased on main 3230974; offline, --locked, toolchain 1.98.1-msvc):
    • cargo clippy --workspace --all-targets --locked -- -D warnings
    • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
    • cargo test (not run by us on this tree)
    • cargo xtask policy (not run; host.rs untouched)

Limits

  • Measured on our fork, not on MiniVI. The lane code is the same origin (MiniVI's behind.rs is an older form of ours); MiniVI's folded entries count as submissions in front of a present, as ours do.
  • The win is on the p90 on a fast 32-thread machine; on the 12-thread stand-in only the median moved, and not resolved (-0.6 +- 0.5).
  • VICTORY_SUBMIT_FRAMES=2, the bigger version of the same idea, was measured and rejected in our fork (median -1.4 ms but p90 +9.3 +- 1.2 ms, run big-fg-1).

…at most n submissions left (VICTORY_PRESENT_RELEASE, 2 in play)
@Androtim

Androtim commented Dec 2, 2026

Copy link
Copy Markdown
Owner

Read-only security & triage review on 097d2c45 (external author PiloteCode — awaiting manual owner approval per repository security allowlist policy; not built/executed locally and not auto-merged):

  • Security / Supply-Chain / Clean-Room: Clean on Rust files (apps/victory/src/play.rs, crates/victory-gpu/src/queue/behind.rs); flags 1-line script edit in scripts/verify-world.ps1 (VICTORY_PRESENT_RELEASE = '2') for owner review. No Cargo.toml, build.rs, .github/workflows/, binaries, or clean-room violations.
  • Architecture note: Substantive queue pacing change (VICTORY_PRESENT_RELEASE=2). Needs manual owner approval to run CI + plain---release A/B verification (including frame-pacing & VRAM headroom check).

@Androtim

Androtim commented Dec 2, 2026 •

Copy link
Copy Markdown
Owner

Automated triage for the maintainers (not an approval).

Verdict: needs-gpu-test · CI (check): passing

Review Summary

Clean, well-scoped change to async submission pacing in crates/victory-gpu/src/queue/behind.rs, with default enablement (VICTORY_PRESENT_RELEASE=2) mirrored in apps/victory/src/play.rs and scripts/verify-world.ps1. CI is passing.

Code & Correctness Checks

  • Lane::wait_presents_ahead & Lane::released (crates/victory-gpu/src/queue/behind.rs):
    • Preserves exact existing behavior when VICTORY_PRESENT_RELEASE is unset (None delegates directly to Lane::wait_presents).
    • Correctly caps in-flight presents at most + 1 (if state.presents > most + 1 { return false; }), so with the default VICTORY_SUBMIT_FRAMES=1 the title never gets two presents ahead of its own.
    • Handles the in-flight present case (lined < state.presents, when Lane::step has popped the oldest Present to execute go() before decrementing state.presents) as well as counting e.what.runs() ahead of the oldest queued Present.
    • No new locks or wakeup hazards: Lane::step calls self.moved.notify_all() after every unfolded/completed entry and Lane::serve notifies after each look(), so wait_presents_ahead wakes reliably.
    • release_ahead() cleanly integrates with crate::ab::pick("VICTORY_PRESENT_RELEASE") under #[cfg(feature = "diagnostics")], and line() reports early releases via RELEASED_AHEAD.
    • Unit test the_title_is_let_go_as_the_present_ahead_comes_near covers the threshold boundaries, popped-present state, immediate return, and most + 1 cap.
  • Launcher & verification parity (apps/victory/src/play.rs, scripts/verify-world.ps1):
    • Adds VICTORY_PRESENT_RELEASE=2 to SETTINGS in play.rs and to $envVars in verify-world.ps1 (no other changes to verify-world.ps1).

Why needs-gpu-test

This changes GPU submission/present pacing and enables VICTORY_PRESENT_RELEASE=2 by default in the launcher (play.rs), and the PR measurements were collected on a fork rather than on MiniVI main. A local real-GPU smoke/regression test on MiniVI is warranted before merging to verify frame pacing, stability, and absence of latency regressions or visual glitches.


Generated with Antigravity CLI (agy).

@Androtim Androtim added triage: needs gpu test Security & logic checks passed; requires local real-GPU smoke test area: gpu D3D12 host, descriptors, memory, or rendering area: launcher Launcher scripts, presets, or docs labels Dec 2, 2026
@Androtim

Androtim commented Dec 2, 2026

Copy link
Copy Markdown
Owner

Allowlist & Architect Deep Review (PiloteCode is now on the trusted allowlist; CI 46881360834 is GREEN):

Code audit (crates/victory-gpu/src/queue/behind.rs, apps/victory/src/play.rs, scripts/verify-world.ps1):

  • Queue concurrency and wakeup logic (wait_presents_ahead, released, self.moved.notify_all() in step/serve) are clean and deadlock-free; caps in-flight presents strictly at most + 1.
  • Kill-switch footgun to clarify: VICTORY_PRESENT_RELEASE=0 parses via number() as Some(0) (meaning early release with 0 submissions ahead of the present, not disabled), whereas play.rs / verify-world.ps1 set VICTORY_PRESENT_RELEASE=2. Because every other VICTORY_* override uses =0 to disable, passing VICTORY_PRESENT_RELEASE=0 silently keeps early release active (only a non-numeric string like off disables it). Consider documenting off explicitly or making off/disabled unambiguous alongside a default-on runtime path if the A/B wins.

Next step (triage: needs gpu test): Ready for plain --release (no --features diagnostics) A/B on main (b0842d93+) checking median/p90 FPS, preparing/copyback ms, WS/VRAM, and 0 crashes/DRED.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: gpu D3D12 host, descriptors, memory, or rendering area: launcher Launcher scripts, presets, or docs triage: needs gpu test Security & logic checks passed; requires local real-GPU smoke test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants