Performance: submission sending on its own thread (VICTORY_PERF_NEXT master switch), AVX2 shadow compare/merge (VICTORY_SIMD), refresh diagnostics #3854

Closed
NICKNAMErutschovkonikovan wants to merge 86 commits from upstream-pr/3854 into main
NICKNAMErutschovkonikovan commented 2026-11-30 09:26:51 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by NICKNAMErutschovkonikovan on 2026-11-30T09:26:51Z.


Builds on #3590 (branch special-features). The commits of that PR are included here; the new work is the commits on top of 00decd38.

What's new

VICTORY_PERF_NEXT: one master switch for the optimizations below. It adds a restart-only F1 row, "PERFORMANCE OPTIMIZATIONS (RESTART)" (German: LEISTUNGS-OPTIMIERUNGEN), with ON/OFF and help text. Each optimization's own switch (0/1) wins over the master; VICTORY_PERF_NEXT=0 turns all of them off. See switch::perf(name, default) in switch.rs.

VICTORY_SUBMIT_SPLIT is on by default under the master switch.

  • Copies in the card's memory and the sending of the lists move to the sending thread.
  • The submitting thread then works 54–58 ms a frame instead of 62–63.
  • After review, the default yields in two cases:
    • When VICTORY_AB names the switch, A/B decides alone.
    • It stays off when the published path cannot carry something: VICTORY_LATE_FILLS, VICTORY_TEAM_FAST, VICTORY_RESIDENT_LATER or VICTORY_GPU_DIRTY. That case is logged.
  • VICTORY_SUBMIT_SPLIT=1 still forces it as before.

AVX2 paths for the shadow's page compare and merge (VICTORY_SIMD).

  • Values: auto / avx2 / off.
  • The level is chosen once at runtime with #[target_feature]. There is no global target-cpu.
  • changed_runs and back_piece get AVX2 versions. The scalar bodies are kept, and tests compare both.
  • Microbenchmarks (release, best of 9):
    • changed_runs: 4–6x dense, 1.6–2.2x sparse.
    • merge: 2.7–20x.
  • In game the gain is below noise, because these paths are a small part of the frame.
  • There is a restart-only F1 row, "CPU VECTOR CODE (RESTART)".

Diagnostics. A new frame line, "refreshes per frame", in every build. It shows where the refresh time goes: most of it is waiting on the guard lock behind VirtualProtect, not copying.

Measured

Setup: Ryzen 7 5800X3D, RTX 5090, 2560x1440, DLSS Q + FG, city scene that moves by itself, release build. Each run is 2 min in the world, and runs alternate in mirrored order (A B B A) because launches drift by about ±10% over a session.

fps ms/frame preparing
all off (VICTORY_PERF_NEXT=0, VICTORY_SIMD=off) 18.0 55.7 38.4
all on (default) 18.6 54.2 36.0

That is about +3% fps and about 2.5 ms less per frame on the submitting thread.

Tried and dropped:

  • VICTORY_ASK_FIRST, VICTORY_OFF_LINE and copying guarded views first: no gain.
  • Raising the VRAM caps (card buffers 16 GB, texture room 97%): no gain; card use rose only 15.9 → 16.5 GB.

Not done on purpose: coalescing the ~43k upload ranges a frame, because the gaps may hold bytes that shaders wrote.

Tests

  • cargo test -p victory-gpu --release: 1028 passed.
    • shader_cache::tests::every_switch_of_the_translator_is_in_the_key fails, as it already did upstream (VICTORY_SCALAR_SPLITS); cache keys are left untouched.
    • card_steps::tests::shared_scratch_eliminates_flight_settle_end_to_end can fail under parallel GPU load only. It passes alone with the master switch on and off.
  • The build with --features ab compiles.
  • xtask policy: only the pre-existing frame_users.rs finding from upstream.
  • The split commits were reviewed for ordering against fences, lifetimes, deadlocks and device loss. The three findings are fixed in the last commit.

Update: big cards, relay thread, review fixes

VICTORY_VRAM_WINDOWS_BAR (on by default, off with =0).

  • On cards with a budget of 20 GiB or more and card memory the CPU can map (Resizable BAR), the windows are kept once, in GPU_UPLOAD card memory. Up to a quarter of the budget is used.
  • Before, each window was kept twice: once on the card and once in the PC's memory that the card shares.
  • Memory the PC shares with the card: 7.9 → 3.8 GB. Committed memory: about 5 GB less.
  • fps with frame generation, 3 runs each: 17.8 / 17.6 / 17.1 → 18.6 / 18.4 / 18.5, about +6%.
  • Smaller cards behave as before.

Upstream fixes taken over. Both are switches of VICTORY_PERF_NEXT:

  • 223f22f0 (VICTORY_REMAP_BACKOFF) backs off the RemapQueue compaction. "opening or noting guards" falls from 4.8 to about 1 ms.
  • PR #1358 (VICTORY_BURY_THREAD) moves the COM drops of bury() to a thread of their own.
    • The relay thread's remaining part falls from 13–15 ms to about 4 ms.
    • Objects are only ever released later than before, never sooner.
    • A drop that panics is caught, and the thread goes on.

Measured without frame generation. Same saved game for every run, 6 runs, alternating:

fps frames over 100 ms
before 18.39 247
after 18.84 215

Screenshots of the same scene are equivalent.

Tried and dropped (no gain or worse frame pacing):

  • VICTORY_PORT_CONSTANTS=1: the card reads the title heap over the bus and runs 3x slower.
  • Batched slot release: no gain.
  • VICTORY_PORT_GUARD: frames over 100 ms rose from 14 to 50.
  • VICTORY_JOIN_PARTS=16: −4%.
  • VICTORY_WAIT_SPIN=500: −1%.
  • VICTORY_RANGE_LOCK=1: no gain.

The remaining bottleneck is the submitting thread's preparation, 35–37 ms a frame; the GPU needs only 2–4 ms.

Tests: cargo test -p victory-gpu --release -- --test-threads=1: 1033 passed. The only failure is the known upstream every_switch_of_the_translator_is_in_the_key.

🤖 Generated with Claude Code

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5562529631 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3854). Originally posted by [NICKNAMErutschovkonikovan](https://github.com/NICKNAMErutschovkonikovan) on 2026-11-30T09:26:51Z. --- Builds on #3590 (branch `special-features`). The commits of that PR are included here; the new work is the commits on top of `00decd38`. ## What's new **`VICTORY_PERF_NEXT`: one master switch for the optimizations below.** It adds a restart-only F1 row, "PERFORMANCE OPTIMIZATIONS (RESTART)" (German: LEISTUNGS-OPTIMIERUNGEN), with ON/OFF and help text. Each optimization's own switch (`0`/`1`) wins over the master; `VICTORY_PERF_NEXT=0` turns all of them off. See `switch::perf(name, default)` in `switch.rs`. **`VICTORY_SUBMIT_SPLIT` is on by default under the master switch.** - Copies in the card's memory and the sending of the lists move to the sending thread. - The submitting thread then works 54–58 ms a frame instead of 62–63. - After review, the default yields in two cases: - When `VICTORY_AB` names the switch, A/B decides alone. - It stays off when the published path cannot carry something: `VICTORY_LATE_FILLS`, `VICTORY_TEAM_FAST`, `VICTORY_RESIDENT_LATER` or `VICTORY_GPU_DIRTY`. That case is logged. - `VICTORY_SUBMIT_SPLIT=1` still forces it as before. **AVX2 paths for the shadow's page compare and merge (`VICTORY_SIMD`).** - Values: `auto` / `avx2` / `off`. - The level is chosen once at runtime with `#[target_feature]`. There is no global target-cpu. - `changed_runs` and `back_piece` get AVX2 versions. The scalar bodies are kept, and tests compare both. - Microbenchmarks (release, best of 9): - changed_runs: 4–6x dense, 1.6–2.2x sparse. - merge: 2.7–20x. - In game the gain is below noise, because these paths are a small part of the frame. - There is a restart-only F1 row, "CPU VECTOR CODE (RESTART)". **Diagnostics.** A new frame line, "refreshes per frame", in every build. It shows where the refresh time goes: most of it is waiting on the guard lock behind `VirtualProtect`, not copying. ## Measured Setup: Ryzen 7 5800X3D, RTX 5090, 2560x1440, DLSS Q + FG, city scene that moves by itself, release build. Each run is 2 min in the world, and runs alternate in mirrored order (A B B A) because launches drift by about ±10% over a session. | | fps | ms/frame | preparing | |---|---|---|---| | all off (`VICTORY_PERF_NEXT=0`, `VICTORY_SIMD=off`) | 18.0 | 55.7 | 38.4 | | all on (default) | 18.6 | 54.2 | 36.0 | That is about +3% fps and about 2.5 ms less per frame on the submitting thread. Tried and dropped: - `VICTORY_ASK_FIRST`, `VICTORY_OFF_LINE` and copying guarded views first: no gain. - Raising the VRAM caps (card buffers 16 GB, texture room 97%): no gain; card use rose only 15.9 → 16.5 GB. Not done on purpose: coalescing the ~43k upload ranges a frame, because the gaps may hold bytes that shaders wrote. ## Tests - `cargo test -p victory-gpu --release`: 1028 passed. - `shader_cache::tests::every_switch_of_the_translator_is_in_the_key` fails, as it already did upstream (`VICTORY_SCALAR_SPLITS`); cache keys are left untouched. - `card_steps::tests::shared_scratch_eliminates_flight_settle_end_to_end` can fail under parallel GPU load only. It passes alone with the master switch on and off. - The build with `--features ab` compiles. - `xtask policy`: only the pre-existing `frame_users.rs` finding from upstream. - The split commits were reviewed for ordering against fences, lifetimes, deadlocks and device loss. The three findings are fixed in the last commit. ## Update: big cards, relay thread, review fixes **`VICTORY_VRAM_WINDOWS_BAR` (on by default, off with `=0`).** - On cards with a budget of 20 GiB or more and card memory the CPU can map (Resizable BAR), the windows are kept once, in GPU_UPLOAD card memory. Up to a quarter of the budget is used. - Before, each window was kept twice: once on the card and once in the PC's memory that the card shares. - Memory the PC shares with the card: 7.9 → 3.8 GB. Committed memory: about 5 GB less. - fps with frame generation, 3 runs each: 17.8 / 17.6 / 17.1 → 18.6 / 18.4 / 18.5, about +6%. - Smaller cards behave as before. **Upstream fixes taken over.** Both are switches of `VICTORY_PERF_NEXT`: - 223f22f0 (`VICTORY_REMAP_BACKOFF`) backs off the RemapQueue compaction. "opening or noting guards" falls from 4.8 to about 1 ms. - PR #1358 (`VICTORY_BURY_THREAD`) moves the COM drops of `bury()` to a thread of their own. - The relay thread's remaining part falls from 13–15 ms to about 4 ms. - Objects are only ever released later than before, never sooner. - A drop that panics is caught, and the thread goes on. **Measured without frame generation.** Same saved game for every run, 6 runs, alternating: | | fps | frames over 100 ms | |---|---|---| | before | 18.39 | 247 | | after | 18.84 | 215 | Screenshots of the same scene are equivalent. **Tried and dropped (no gain or worse frame pacing):** - `VICTORY_PORT_CONSTANTS=1`: the card reads the title heap over the bus and runs 3x slower. - Batched slot release: no gain. - `VICTORY_PORT_GUARD`: frames over 100 ms rose from 14 to 50. - `VICTORY_JOIN_PARTS=16`: −4%. - `VICTORY_WAIT_SPIN=500`: −1%. - `VICTORY_RANGE_LOCK=1`: no gain. The remaining bottleneck is the submitting thread's preparation, 35–37 ms a frame; the GPU needs only 2–4 ms. Tests: `cargo test -p victory-gpu --release -- --test-threads=1`: 1033 passed. The only failure is the known upstream `every_switch_of_the_translator_is_in_the_key`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
tillo88 commented 2026-11-30 12:44:54 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by tillo88 on 2026-11-30T12:44:54Z.


Measured this PR as it is (defaults: VICTORY_PERF_NEXT on, so the submission split and VICTORY_SIMD=auto → avx2; the log confirms both) on top of v2026.11.29.05, 2 runs, against 18 runs of the release as it is.

fps ms/frame submitting thread ms refresh ms p95 ms p99 ms
v2026.11.29.05, 18 runs (mean) 29.40 37.4 31.4 8.21 57.3 138.7
with #3854, run 1 26.27 41.1 30.6 8.76 61.3 165.8
with #3854, run 2 25.82 41.7 31.1 8.74 62.3 163.6

Slower here: −11% fps (26.05 vs 29.40), and both runs are below the slowest of the 18 baseline runs (27.79). The submitting thread's time per frame is about the same as the release's, and refreshes are only ~0.5 ms longer, so the ~4 ms per frame that was added does not show up in the submitting thread as measured by the frame-rate log. Note this branch also carries #3590's commits, so the loss may come from those rather than the new ones. For comparison, #3809 (submission split plus the lazy-compare and table-same switches on, on the same release) measured +3.9% on this bench. No crash in either run.

Setup: Ryzen 7 9800X3D, RTX 5070 Ti 16 GB (driver 621.40), 32 GB RAM, Windows 11, release build, Series X 1440p, DLSS Quality, frame generation off, ray tracing off. Same save restored before each run (start of the game), prison cutscene, plane cutscene, first boat section, about 6 minutes; warm-up run not counted.

Measured unattended on a replay bench (same save, recorded controller input via VICTORY_INPUT_REPLAY); numbers and text prepared with Claude.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7278867135 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3854#issuecomment-7278867135). Originally posted by [tillo88](https://github.com/tillo88) on 2026-11-30T12:44:54Z. --- Measured this PR as it is (defaults: `VICTORY_PERF_NEXT` on, so the submission split and `VICTORY_SIMD=auto` → avx2; the log confirms both) on top of **v2026.11.29.05**, 2 runs, against 18 runs of the release as it is. | | fps | ms/frame | submitting thread ms | refresh ms | p95 ms | p99 ms | |---|---|---|---|---|---|---| | v2026.11.29.05, 18 runs (mean) | 29.40 | 37.4 | 31.4 | 8.21 | 57.3 | 138.7 | | with #3854, run 1 | 26.27 | 41.1 | 30.6 | 8.76 | 61.3 | 165.8 | | with #3854, run 2 | 25.82 | 41.7 | 31.1 | 8.74 | 62.3 | 163.6 | **Slower here: −11% fps** (26.05 vs 29.40), and both runs are below the slowest of the 18 baseline runs (27.79). The submitting thread's time per frame is about the same as the release's, and refreshes are only ~0.5 ms longer, so the ~4 ms per frame that was added does not show up in the submitting thread as measured by the frame-rate log. Note this branch also carries #3590's commits, so the loss may come from those rather than the new ones. For comparison, #3809 (submission split plus the lazy-compare and table-same switches on, on the same release) measured +3.9% on this bench. No crash in either run. Setup: Ryzen 7 9800X3D, RTX 5070 Ti 16 GB (driver 621.40), 32 GB RAM, Windows 11, release build, Series X 1440p, DLSS Quality, frame generation off, ray tracing off. Same save restored before each run (start of the game), prison cutscene, plane cutscene, first boat section, about 6 minutes; warm-up run not counted. Measured unattended on a replay bench (same save, recorded controller input via VICTORY_INPUT_REPLAY); numbers and text prepared with Claude.
NICKNAMErutschovkonikovan commented 2026-12-01 10:12:03 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by NICKNAMErutschovkonikovan on 2026-12-01T10:12:03Z.


Replaced by #4771: its parts (SUBMIT_SPLIT, VRAM_WINDOWS_BAR and the rest) are there, each behind its own switch under VICTORY_PERF_NEXT, on top of current main.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7307823333 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3854#issuecomment-7307823333). Originally posted by [NICKNAMErutschovkonikovan](https://github.com/NICKNAMErutschovkonikovan) on 2026-12-01T10:12:03Z. --- Replaced by #4771: its parts (SUBMIT_SPLIT, VRAM_WINDOWS_BAR and the rest) are there, each behind its own switch under VICTORY_PERF_NEXT, on top of current main.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
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.

Reference
trustno1-coder/VIctory-NVIDIA!3854
No description provided.