perf: release-profile flags, AVX2 baseline, gate diagnostics allocato… #537

Closed
github-bot wants to merge 3 commits from github-bot/gh-537 into main AGit
Owner

@⁠hqjake on GitHub · 2026-11-28 00:31 UTC · original
perf/release-tuning → main · +389 −2 · 5 files · 3 commits · closed without merging

…r, cache single-flight

Four zero-code-risk changes aimed at the submission-prep wall (findings.md: 48 ms of a 55 ms water-scene frame).

Cargo.toml [profile.release]
lto = "thin", codegen-units = 1, panic = "abort", incremental = false.
Cross-crate inlining on the hot CPU path; drops landing pads from every
function in the hot command-list code.

.cargo/config.toml
target-cpu = x86-64-v3 for x86_64. The fork already assumes AVX2
(findings.md's title-byte compares); this lets rustc emit AVX2, BMI1/2
and FMA throughout, which is exactly what auto-vectorizes the prep
thread's dword scans and hashing.

crates/victory-gpu/src/copystat.rs
Gate the Counting global allocator and its backing arrays behind
cfg(any(feature = "diagnostics", test)). The allocator's own docstring
said "diagnostics builds only" but it was active in release, so every
allocation paid two atomics plus a small-block branch for stats nobody
reads outside the diagnostics build. Release now uses the system
allocator directly. Tests still install Counting under cfg(test).

crates/victory-pipeline/src/cache.rs
Single-flight per key + race-tolerant publish + peek().

  • Cache is now Arc with inflight: Mutex<HashMap<CacheKey, Arc<Mutex<()>>>>. Threads converting the same key serialize on the per-key mutex; the first converts and publishes, the rest double-check and return the published path. In the shader-cache startup burst this turns duplicate translations of the same container across threads into disk reads.
  • publish() recovers when rename() fails but the destination is already a plain file: the key is content-addressed, so the bytes match by definition. Removes spurious errors when a sibling process wins.
  • Cache::peek(&CacheKey) -> Option for read-only lookup.
  • Miss trace parity, error context on create_dir_all and rename, poisoned-mutex tolerance via a small lock() helper.

Verification:
cargo test -p victory-pipeline -> 11/11 pass
cargo test -p victory-gpu -> 434/436 (two failing tests are
pre-existing live-D3D12 tests
that also fail on a clean
v2026.11.27.8 extraction)
cargo check --release -p victory-gpu -> clean, no new warnings

Expected: 5-10% off the submission-prep wall; neutral on GPU-bound scenes.

**@⁠hqjake** on GitHub · 2026-11-28 00:31 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/537) `perf/release-tuning` → `main` · +389 −2 · 5 files · 3 commits · closed without merging …r, cache single-flight Four zero-code-risk changes aimed at the submission-prep wall (findings.md: 48 ms of a 55 ms water-scene frame). Cargo.toml [profile.release] lto = "thin", codegen-units = 1, panic = "abort", incremental = false. Cross-crate inlining on the hot CPU path; drops landing pads from every function in the hot command-list code. .cargo/config.toml target-cpu = x86-64-v3 for x86_64. The fork already assumes AVX2 (findings.md's title-byte compares); this lets rustc emit AVX2, BMI1/2 and FMA throughout, which is exactly what auto-vectorizes the prep thread's dword scans and hashing. crates/victory-gpu/src/copystat.rs Gate the Counting global allocator and its backing arrays behind cfg(any(feature = "diagnostics", test)). The allocator's own docstring said "diagnostics builds only" but it was active in release, so every allocation paid two atomics plus a small-block branch for stats nobody reads outside the diagnostics build. Release now uses the system allocator directly. Tests still install Counting under cfg(test). crates/victory-pipeline/src/cache.rs Single-flight per key + race-tolerant publish + peek(). - Cache is now Arc<Inner> with inflight: Mutex<HashMap<CacheKey, Arc<Mutex<()>>>>. Threads converting the same key serialize on the per-key mutex; the first converts and publishes, the rest double-check and return the published path. In the shader-cache startup burst this turns duplicate translations of the same container across threads into disk reads. - publish() recovers when rename() fails but the destination is already a plain file: the key is content-addressed, so the bytes match by definition. Removes spurious errors when a sibling process wins. - Cache::peek(&CacheKey) -> Option<PathBuf> for read-only lookup. - Miss trace parity, error context on create_dir_all and rename, poisoned-mutex tolerance via a small lock() helper. Verification: cargo test -p victory-pipeline -> 11/11 pass cargo test -p victory-gpu -> 434/436 (two failing tests are pre-existing live-D3D12 tests that also fail on a clean v2026.11.27.8 extraction) cargo check --release -p victory-gpu -> clean, no new warnings Expected: 5-10% off the submission-prep wall; neutral on GPU-bound scenes.
Four zero-code-risk changes aimed at the submission-prep wall (findings.md:
48 ms of a 55 ms water-scene frame).

Cargo.toml [profile.release]
  lto = "thin", codegen-units = 1, panic = "abort", incremental = false.
  Cross-crate inlining on the hot CPU path; drops landing pads from every
  function in the hot command-list code.

.cargo/config.toml
  target-cpu = x86-64-v3 for x86_64. The fork already assumes AVX2
  (findings.md's title-byte compares); this lets rustc emit AVX2, BMI1/2
  and FMA throughout, which is exactly what auto-vectorizes the prep
  thread's dword scans and hashing.

crates/victory-gpu/src/copystat.rs
  Gate the Counting global allocator and its backing arrays behind
  cfg(any(feature = "diagnostics", test)). The allocator's own docstring
  said "diagnostics builds only" but it was active in release, so every
  allocation paid two atomics plus a small-block branch for stats nobody
  reads outside the diagnostics build. Release now uses the system
  allocator directly. Tests still install Counting under cfg(test).

crates/victory-pipeline/src/cache.rs
  Single-flight per key + race-tolerant publish + peek().

  - Cache is now Arc<Inner> with inflight: Mutex<HashMap<CacheKey,
    Arc<Mutex<()>>>>. Threads converting the same key serialize on the
    per-key mutex; the first converts and publishes, the rest double-check
    and return the published path. In the shader-cache startup burst this
    turns duplicate translations of the same container across threads
    into disk reads.
  - publish() recovers when rename() fails but the destination is already
    a plain file: the key is content-addressed, so the bytes match by
    definition. Removes spurious errors when a sibling process wins.
  - Cache::peek(&CacheKey) -> Option<PathBuf> for read-only lookup.
  - Miss trace parity, error context on create_dir_all and rename,
    poisoned-mutex tolerance via a small lock() helper.

Verification:
  cargo test -p victory-pipeline        -> 11/11 pass
  cargo test -p victory-gpu              -> 434/436 (two failing tests are
                                            pre-existing live-D3D12 tests
                                            that also fail on a clean
                                            v2026.11.27.8 extraction)
  cargo check --release -p victory-gpu   -> clean, no new warnings

Expected: 5-10% off the submission-prep wall; neutral on GPU-bound scenes.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 00:34:40 +00:00
Cache now exposes `get_or_convert_chunks(converter, &[&[u8]])` and
`CacheKey::from_chunks`. Both hash the chunks in order with no
concatenation; the result matches `CacheKey::new` on the same bytes
joined end-to-end. On a cache miss the chunks are concatenated exactly
once before `Converter::convert` runs; on a cache hit nothing is
allocated.

The sole consumer, victory-gpu's shader cache, previously did
`let input = [&build[..], container].concat();` on every call to
`cached(..)`, which allocated and memcpy'd the concatenation per shader
request even on warm-cache hits. On a typical scene the game asks for
shaders continuously through its own PSO pipeline, so this ran per
graphics/compute pipeline creation. The call site now hands the two
slices directly to `get_or_convert_chunks` and the concatenation only
happens when the cache actually misses.

Tests:
  - `chunks_hash_matches_concatenation_and_skips_concat_on_hit`:
    verifies the key matches the concatenated form, that convert runs
    with the concatenated bytes on miss, and that convert is not called
    on hit.
  - Existing `translations_come_back_from_the_cache` still passes,
    confirming the shader-cache call-site change is correctness-neutral.

victory-pipeline: 12/12 pass
victory-gpu shader_cache tests: 2/2 pass
Author
Owner

@⁠POMXARK on GitHub · 2026-11-28 02:11 UTC · original · edited 2026-11-28 03:57 UTC

Testing feedback on AMD Ryzen 7 5700X (8C/16T), NVIDIA RTX 5080 16 GB, 32 GB RAM, Windows 11, Series X 1440p + DLSS Quality + DLSS MFG 4× (4 MiB default windows, VICTORY_GPU_BCPACK=0, VICTORY_WAIT_RESIDENT=0, VICTORY_TEXTURE_ROOM_PERCENT=70, VICTORY_LAND_SKIP=1), full 12-minute (720 s) 3D A/B workload.

Full disclosure: tested on a fork branch based on v2026.11.27.7 with local GPU patches, applying only the compiler profile subset of this PR:

  • .cargo/config.toml: rustflags = ["-C", "target-cpu=x86-64-v3"]
  • Cargo.toml [profile.release]: lto = "thin", codegen-units = 1 (omitted panic = "abort", see note below)

Strictly 3D-only, draw-count-matched 12-minute A/B results

Bucket (3D only, fps < 20, draws >= 100) Baseline With x86-64-v3 + ThinLTO + cgu=1 Delta
ALL 3D (n=118 vs 113) 9.7 p50 / 10.30 mean (103.2 ms, Prep 81.6, copies 47.6) 11.2 p50 / 11.55 mean (89.1 ms, Prep 66.7, copies 35.3) +15.5% p50 (-14.1 ms)
Late 3D (last 30 samples) 7.9 p50 / 7.09 mean (126.7 ms, Prep 92.8, copies 60.7) 9.4 p50 / 9.20 mean (106.4 ms, Prep 73.0, copies 47.2) +19.0% p50 / +29.8% mean
High-draw 3D (7k–10k draws) (p50 ~8.35k) 8.45 p50 / 7.81 mean (118.6 ms, Prep 89.4) 9.30 p50 / 9.37 mean (107.4 ms, Prep 73.9) +10.1% p50 / +20.0% mean
Very-high-draw 3D (>=10k draws) (p50 ~11k) 7.20 p50 / 6.45 mean (139.9 ms) 7.80 p50 / 8.62 mean (127.6 ms) +8.3% p50 / +33.6% mean
Memory & stability SharedMax 9776 MB, 0 errors / 0 DevRem SharedMax 9261 MB, 0 errors / 0 DevRem clean, lower pressure

Two code-review notes

  1. panic = "abort" in [profile.release]: there are 6 active std::panic::catch_unwind sites in worker loops (crates/victory-gpu/src/descriptor.rs, host/aside.rs, list/thin.rs, land.rs, queue/behind.rs). Setting panic = "abort" turns any caught worker panic into an immediate process abort, so keeping default panic = "unwind" is safer.
  2. #[global_allocator] Counting in copystat.rs: in crates/victory-gpu/src/lib.rs, mod copystat; is already gated behind #[cfg(all(windows, feature = "diagnostics"))], so plain release builds were not compiling Counting (adding the inner #[cfg] inside copystat.rs is still harmless).
**@⁠POMXARK** on GitHub · 2026-11-28 02:11 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/537#issuecomment-7232188532) · edited 2026-11-28 03:57 UTC Testing feedback on **AMD Ryzen 7 5700X (8C/16T), NVIDIA RTX 5080 16 GB, 32 GB RAM**, Windows 11, Series X 1440p + DLSS Quality + DLSS MFG 4× (`4 MiB` default windows, `VICTORY_GPU_BCPACK=0`, `VICTORY_WAIT_RESIDENT=0`, `VICTORY_TEXTURE_ROOM_PERCENT=70`, `VICTORY_LAND_SKIP=1`), full 12-minute (720 s) 3D A/B workload. Full disclosure: tested on a fork branch based on `v2026.11.27.7` with local GPU patches, applying **only** the compiler profile subset of this PR: - `.cargo/config.toml`: `rustflags = ["-C", "target-cpu=x86-64-v3"]` - `Cargo.toml` `[profile.release]`: `lto = "thin"`, `codegen-units = 1` (omitted `panic = "abort"`, see note below) ### Strictly 3D-only, draw-count-matched 12-minute A/B results | Bucket (3D only, `fps < 20`, `draws >= 100`) | Baseline | With `x86-64-v3` + ThinLTO + `cgu=1` | Delta | |---|---:|---:|---:| | **ALL 3D** (`n=118` vs `113`) | `9.7` p50 / `10.30` mean (`103.2 ms`, `Prep 81.6`, `copies 47.6`) | **`11.2` p50 / `11.55` mean** (`89.1 ms`, `Prep 66.7`, `copies 35.3`) | **`+15.5%` p50** (`-14.1 ms`) | | **Late 3D (last 30 samples)** | `7.9` p50 / `7.09` mean (`126.7 ms`, `Prep 92.8`, `copies 60.7`) | **`9.4` p50 / `9.20` mean** (`106.4 ms`, `Prep 73.0`, `copies 47.2`) | **`+19.0%` p50 / `+29.8%` mean** | | **High-draw 3D (`7k–10k draws`)** (`p50 ~8.35k`) | `8.45` p50 / `7.81` mean (`118.6 ms`, `Prep 89.4`) | **`9.30` p50 / `9.37` mean** (`107.4 ms`, `Prep 73.9`) | **`+10.1%` p50 / `+20.0%` mean** | | **Very-high-draw 3D (`>=10k draws`)** (`p50 ~11k`) | `7.20` p50 / `6.45` mean (`139.9 ms`) | **`7.80` p50 / `8.62` mean** (`127.6 ms`) | **`+8.3%` p50 / `+33.6%` mean** | | **Memory & stability** | `SharedMax 9776 MB`, `0` errors / `0` DevRem | **`SharedMax 9261 MB`, `0` errors / `0` DevRem** | clean, lower pressure | ### Two code-review notes 1. **`panic = "abort"` in `[profile.release]`:** there are 6 active `std::panic::catch_unwind` sites in worker loops (`crates/victory-gpu/src/descriptor.rs`, `host/aside.rs`, `list/thin.rs`, `land.rs`, `queue/behind.rs`). Setting `panic = "abort"` turns any caught worker panic into an immediate process abort, so keeping default `panic = "unwind"` is safer. 2. **`#[global_allocator] Counting` in `copystat.rs`:** in `crates/victory-gpu/src/lib.rs`, `mod copystat;` is already gated behind `#[cfg(all(windows, feature = "diagnostics"))]`, so plain release builds were not compiling `Counting` (adding the inner `#[cfg]` inside `copystat.rs` is still harmless).
github-bot closed this pull request 2026-12-01 06:37:33 +00:00

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!537
No description provided.