Performance: multi-subsystem CPU submission, memory sync, shader recompiler & format throughput overhaul #637

Open
github-bot wants to merge 9 commits from github-bot/gh-637 into a-publier AGit
Owner

@⁠iWebbIO on GitHub · 2026-11-27 15:38 UTC · original
iWebbIO:perf/multi-subsystem-speedups → a-publier · +1506 −535 · 24 files · 9 commits · open

Summary

This pull request delivers 9 focused, invariant-preserving commits across victory-gpu, victory-shader, victory-formats, and victory (apps/victory), targeting the major bottlenecks documented in docs/findings.md and README.md:

  1. Submission preparation thread (40–48 ms/frame wall): Unlocking LANE.state during Job::Lists unfold, consolidating Lane::step locks, lock-free Lane::wake Dekker handshake, fusing ask_once + stale_under_flights scans, eliminating card_steps per-fill Box<dyn Iterator> / full cache wipes, cache-line aligning watch::Notes shards, word-level guard() bitmap scans, 128-byte AVX2 vptest fast-skip in shadow.rs, lock-free AtomicUsize work stealing in land::Pool, and O(log N) land_card with batched note_landings.
  2. 8-thread command-list translation (230–430 ms CPU work/frame): 64-shard RwLock<HashMap> for PLACED_TEXTURES, lock-free heap.host.get() fast path in descriptor::mirror, lock-free OnceLock canonical host_signature, zero-allocation targets / barrier, thread-local stat batching in port_cbv, and releasing upload::ARENAS before zeroing (skipping zeroing on fresh OS-zeroed VirtualAlloc2 blocks).
  3. Private memory footprint (~9 GB list allocators): Bounding list/thin::BACKS to 32 entries and converting list::IDLE to VecDeque with pressure-aware list::trim() called from pool::room().
  4. Pipeline stalls & offline warming (>200 ms spikes, victory warm): Deduplicating ID3D12RootSignature per (device, blake3(bytes)) (also fixing per-switch draw.rs root-signature cache misses), single-pass analyze_stores(), and replacing the 500 ms polling sleep in apps/victory/src/warm.rs with a Condvar watchdog.
  5. Texture streaming, layout & XMA2 audio (victory-formats): Macro-block cache-tiled detile/tile traversal with power-of-2 bounds-check elimination and 4-byte fast path, stack-allocated layout tables, 9-bit primary VLC LUT + u64::from_be_bytes peek32 + pow10_div20 LUT in XMA2, and cache-local branchless BucketInfo + compile-time SPREAD8/NIBBLES_LUT + u16 anchor bitmask + stack history in BCPack.
  6. Shader recompilation (victory-shader): Fast-path bailout in ir::unspill(), dense Vec-indexed defs/phis + FxHash sets + lazy exec in structure::Lanes, O(|BDD|) Bools::vars() + single-pass Bools::given(), and single-pass worklist Tracer::propagate_copies().

Verified Microbenchmark Results (Release, Linux x86_64, rustc 1.98.1)

victory-shader (cargo bench -p victory-shader --bench guard_runs)

Benchmark Before (median) After (median) Speedup
unmasked (0 masks, 512 VALU) 31.038 µs 18.519 µs 1.68× (-40.3%)
short runs (8 masks, run=1) 10.279 µs 6.870 µs 1.50× (-33.2%)
long runs (8 masks, run=64) 40.741 µs 25.287 µs 1.61× (-37.9%)

victory-formats (texture_layout_bench, detile/tile, XMA2, BCPack)

Benchmark Before After Speedup
BC7 64KB_D layout 171.0 ns/layout 158.6 ns/layout 1.08×
RGBA8 4KB_D layout 191.2 ns/layout 163.0 ns/layout 1.17×
RGBA8 linear layout 181.2 ns/layout 141.2 ns/layout 1.28×
BC7 4096×4096 SW_64KB_D detile 3.963 ms (4.23 GB/s) 1.397 ms (12.01 GB/s) 2.84×
RGBA8 2048×2048 SW_64KB_D detile 3.944 ms (4.25 GB/s) 1.720 ms (9.75 GB/s) 2.29×
R8 3D 128×128×64 SW_64KB_S detile 1.636 ms (0.64 GB/s) 0.154 ms (6.82 GB/s) 10.6×
XMA2 stereo 512-sample frame 21.55 µs 13.08 µs 1.65×
BCPack throughput (bcpack_throughput) BC1 ~62 / BC4 ~60 / BC7 ~35 MB/s BC1 75.9 / BC4 74.7 / BC7 45.7 MB/s 1.22×–1.30×

Commit Breakdown

  1. perf(victory-formats): macro-block tiled detile, XMA2 VLC/pow10 LUTs, and branchless BCPack rANS
    • crates/victory-formats/src/texture.rs, xma.rs, bcpack.rs
  2. perf(victory-shader): fast-path unspill, dense Vec tables + single-pass Bools::given, and worklist copy propagation
    • crates/victory-shader/src/ir.rs, structure.rs, resource.rs
  3. perf(victory-gpu/queue): unlock LANE during unfold, consolidate Lane::step, lock-free wake, and TLS port stats
    • crates/victory-gpu/src/queue/behind.rs, port_cbv.rs, port_journal.rs
  4. perf(victory-gpu/host): fuse ask_once/stale scans, optimize card_steps & join_ranges, and unlock upload::ARENAS
    • crates/victory-gpu/src/host.rs, host/card_steps.rs, upload.rs
  5. **`perf(victory-gpu/watch): align Notes shards, zero-alloc scans, word-level guard check, and lock-free PROTECTED
**@⁠iWebbIO** on GitHub · 2026-11-27 15:38 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/637) `iWebbIO:perf/multi-subsystem-speedups` → `a-publier` · +1506 −535 · 24 files · 9 commits · open ## Summary This pull request delivers **9 focused, invariant-preserving commits** across `victory-gpu`, `victory-shader`, `victory-formats`, and `victory` (`apps/victory`), targeting the major bottlenecks documented in [`docs/findings.md`](docs/findings.md) and [`README.md`](README.md): 1. **Submission preparation thread (`40–48 ms/frame` wall)**: Unlocking `LANE.state` during `Job::Lists` unfold, consolidating `Lane::step` locks, lock-free `Lane::wake` Dekker handshake, fusing `ask_once` + `stale_under_flights` scans, eliminating `card_steps` per-fill `Box<dyn Iterator>` / full cache wipes, cache-line aligning `watch::Notes` shards, word-level `guard()` bitmap scans, 128-byte AVX2 `vptest` fast-skip in `shadow.rs`, lock-free `AtomicUsize` work stealing in `land::Pool`, and `O(log N)` `land_card` with batched `note_landings`. 2. **8-thread command-list translation (`230–430 ms` CPU work/frame)**: 64-shard `RwLock<HashMap>` for `PLACED_TEXTURES`, lock-free `heap.host.get()` fast path in `descriptor::mirror`, lock-free `OnceLock` canonical `host_signature`, zero-allocation `targets` / `barrier`, thread-local stat batching in `port_cbv`, and releasing `upload::ARENAS` before zeroing (skipping zeroing on fresh OS-zeroed `VirtualAlloc2` blocks). 3. **Private memory footprint (`~9 GB` list allocators)**: Bounding `list/thin::BACKS` to 32 entries and converting `list::IDLE` to `VecDeque` with pressure-aware `list::trim()` called from `pool::room()`. 4. **Pipeline stalls & offline warming (`>200 ms` spikes, `victory warm`)**: Deduplicating `ID3D12RootSignature` per `(device, blake3(bytes))` (also fixing per-switch `draw.rs` root-signature cache misses), single-pass `analyze_stores()`, and replacing the 500 ms polling sleep in `apps/victory/src/warm.rs` with a `Condvar` watchdog. 5. **Texture streaming, layout & XMA2 audio (`victory-formats`)**: Macro-block cache-tiled detile/tile traversal with power-of-2 bounds-check elimination and 4-byte fast path, stack-allocated layout tables, 9-bit primary VLC LUT + `u64::from_be_bytes` `peek32` + `pow10_div20` LUT in XMA2, and cache-local branchless `BucketInfo` + compile-time `SPREAD8`/`NIBBLES_LUT` + `u16` anchor bitmask + stack `history` in BCPack. 6. **Shader recompilation (`victory-shader`)**: Fast-path bailout in `ir::unspill()`, dense `Vec`-indexed `defs`/`phis` + `FxHash` sets + lazy `exec` in `structure::Lanes`, `O(|BDD|)` `Bools::vars()` + single-pass `Bools::given()`, and single-pass worklist `Tracer::propagate_copies()`. ## Verified Microbenchmark Results (Release, Linux x86_64, `rustc 1.98.1`) ### `victory-shader` (`cargo bench -p victory-shader --bench guard_runs`) | Benchmark | Before (median) | After (median) | Speedup | | --- | ---: | ---: | ---: | | `unmasked` (0 masks, 512 VALU) | 31.038 µs | **18.519 µs** | **1.68× (-40.3%)** | | `short runs` (8 masks, run=1) | 10.279 µs | **6.870 µs** | **1.50× (-33.2%)** | | `long runs` (8 masks, run=64) | 40.741 µs | **25.287 µs** | **1.61× (-37.9%)** | ### `victory-formats` (`texture_layout_bench`, detile/tile, XMA2, BCPack) | Benchmark | Before | After | Speedup | | --- | ---: | ---: | ---: | | `BC7 64KB_D` layout | 171.0 ns/layout | **158.6 ns/layout** | **1.08×** | | `RGBA8 4KB_D` layout | 191.2 ns/layout | **163.0 ns/layout** | **1.17×** | | `RGBA8 linear` layout | 181.2 ns/layout | **141.2 ns/layout** | **1.28×** | | `BC7 4096×4096 SW_64KB_D` detile | 3.963 ms (4.23 GB/s) | **1.397 ms (12.01 GB/s)** | **2.84×** | | `RGBA8 2048×2048 SW_64KB_D` detile | 3.944 ms (4.25 GB/s) | **1.720 ms (9.75 GB/s)** | **2.29×** | | `R8 3D 128×128×64 SW_64KB_S` detile | 1.636 ms (0.64 GB/s) | **0.154 ms (6.82 GB/s)** | **10.6×** | | XMA2 stereo 512-sample frame | 21.55 µs | **13.08 µs** | **1.65×** | | BCPack throughput (`bcpack_throughput`) | BC1 ~62 / BC4 ~60 / BC7 ~35 MB/s | **BC1 75.9 / BC4 74.7 / BC7 45.7 MB/s** | **1.22×–1.30×** | ## Commit Breakdown 1. **`perf(victory-formats): macro-block tiled detile, XMA2 VLC/pow10 LUTs, and branchless BCPack rANS`** * `crates/victory-formats/src/texture.rs`, `xma.rs`, `bcpack.rs` 2. **`perf(victory-shader): fast-path unspill, dense Vec tables + single-pass Bools::given, and worklist copy propagation`** * `crates/victory-shader/src/ir.rs`, `structure.rs`, `resource.rs` 3. **`perf(victory-gpu/queue): unlock LANE during unfold, consolidate Lane::step, lock-free wake, and TLS port stats`** * `crates/victory-gpu/src/queue/behind.rs`, `port_cbv.rs`, `port_journal.rs` 4. **`perf(victory-gpu/host): fuse ask_once/stale scans, optimize card_steps & join_ranges, and unlock upload::ARENAS`** * `crates/victory-gpu/src/host.rs`, `host/card_steps.rs`, `upload.rs` 5. **`perf(victory-gpu/watch): align Notes shards, zero-alloc scans, word-level guard check, and lock-free PROTECTED
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 15:50:58 +00:00
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/637/head:github-bot/gh-637'
git switch 'github-bot/gh-637'

Merge

Merge the changes and update on Forgejo.
git switch 'a-publier'
git merge --no-ff 'github-bot/gh-637'
git switch 'github-bot/gh-637'
git rebase 'a-publier'
git switch 'a-publier'
git merge --ff-only 'github-bot/gh-637'
git switch 'github-bot/gh-637'
git rebase 'a-publier'
git switch 'a-publier'
git merge --no-ff 'github-bot/gh-637'
git switch 'a-publier'
git merge --squash 'github-bot/gh-637'
git switch 'a-publier'
git merge --ff-only 'github-bot/gh-637'
git switch 'a-publier'
git merge 'github-bot/gh-637'
git push origin 'a-publier'
This discussion has been locked. Commenting is limited to contributors.
No description provided.