Skip to content

perf(gpu): lock-free spin fast-path in AskedFirst::wait + largest-first texture refresh - #41

Open
DjCanigia wants to merge 1 commit into
Kemerd:mainfrom
DjCanigia:exp/broadside-rtx3090-opt
Open

DjCanigia wants to merge 1 commit into
Kemerd:mainfrom
DjCanigia:exp/broadside-rtx3090-opt

Conversation

@DjCanigia

Copy link
Copy Markdown

Summary

Two small, low-risk CPU frame-preparation optimizations tested on Ryzen 9 5950X + RTX 3090 24 GB + 32 GB RAM (Windows 11, Series S profile, DLSS Performance, FG off):

  1. crates/victory-gpu/src/watch.rs — Lock-free fast-path & bounded spin in AskedFirst::wait()

    • Adds an AtomicBool completion flag checked with Acquire before taking the Mutex/Condvar.
    • When victory-ask is still finishing, spins up to crate::shadow::wait_spin() (VICTORY_WAIT_SPIN) before falling back to Condvar::wait, avoiding ~150–300 µs Windows thread wakeup penalties across ~17 submissions/frame.
  2. crates/victory-gpu/src/host.rs — Largest-first texture ordering in refresh_front & refresh_textures

    • Sorts due textures by descending byte size (memory().1) alongside longest_first(&mut spans) in refresh_front and before wide_each_scoped in refresh_textures, reducing straggler tail latency at worker joins.

Measured results (RTX 3090 24 GB + Ryzen 9 5950X, RT off, FG off)

Steady world gameplay (~4,500–4,900 draws/frame, VICTORY_REFLEX_ORIGIN_SLEEP=0, VICTORY_IMAGE=1, VICTORY_MEMORY_LEAN=1, VICTORY_STAGING_NO_ZERO=1, VICTORY_WC_BAR=1, VICTORY_WAIT_SPIN=800):

  • Broadside-RT baseline (3c6961e): 18.0 fps avg (20.8 fps max), 57.2 ms/frame (48.6 ms min), 36.7–43.9 ms preparing, 18.5–20.0 ms copy-back.
  • With this PR (+ VICTORY_INPLACE=1): up to 22.2–22.5 fps rendered (45.0–46.8 ms/frame), 34.2–34.7 ms preparing, 12.1–12.3 ms copy-back, 0.1–0.2 ms GPU wait, 0 refused/invalidated in-place windows (78 windows / 498 MB).

Extra telemetry note for RTX 3090 (Ampere, 32 GB RAM) with VICTORY_RT_HW=native

Tested rt-test-14 (VICTORY_RT_NATIVE=1, VICTORY_RT_HW=native) on RTX 3090 24 GB:

  • Hardware DXR Tier 1.2 initialized cleanly with zero crashes (3,609 BLAS structures / 384 MiB, 4–5 TLAS/frame with ~496 instances).
  • GPU RT cost on Ampere was ~36.5–72.7 ms (rehydrate) + ~57.8 ms (trace native hardware) with process private commit reaching ~34.2 GB (pressured=true on 32 GB RAM), whereas RT off sits at ~25.5–25.8 GB commit and 0.1 ms GPU wait.

Verification

  • Clean release build (cargo build --release -p victory, x86-64-v3).
  • Verified in-game stability with zero regressions, zero device removals, and zero refused pipelines.

AI-assisted analysis, profiling, and patch authoring: Antigravity (Google DeepMind), verified and benchmarked locally on RTX 3090 24 GB + Ryzen 9 5950X.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant