perf(gpu): skip redundant shape_see on TLS hit and gate NAMED_WHOLE #505

Manually merged
github merged 1 commit from github-bot/gh-505 into main 2026-12-05 17:30:18 +00:00 AGit
Owner

@⁠Not4Eric on GitHub · 2026-12-04 20:24 UTC · original
Not4Eric:perf/descriptor-tls-hit → main · +16 −10 · 1 files · 1 commits · merged 2026-12-05 17:29 UTC

What this does

In victory_gpu::descriptor::words_for, skips calling shape_see (which re-wrote the thread-local cache) when shape_seen already hit, and gates NAMED_WHOLE behind #[cfg(feature = "diagnostics")] since views_kept() is its only reader and is already #[cfg(all(windows, feature = "diagnostics"))]. This removes redundant TLS writes and global atomic RMWs from the descriptor-recording hot path without changing behaviour.

Checks

  • N/A: pure performance optimization preserving identical behaviour; no new behaviour or switch introduced.
  • N/A: no switches added, changed, or removed.
  • No unrelated cleanup: diff is limited to NAMED_WHOLE and the shape_seen fast path in crates/victory-gpu/src/descriptor.rs.
  • N/A: behavioural invariance verified by existing descriptor:: unit tests; no failure mode existed before that a unit test could distinguish without timing assertions.
  • Checked open PR queue: independent of #503 and of perf/descriptor-fxhash-views (separate regions of descriptor.rs).
  • cargo xtask policy passed (359 files ok); no fork-only files, configs, or build outputs.

Verified

  • cargo xtask policy — 359 files ok
  • PROFILE=diag PKG=victory-gpu ./build.sh check — 0 warnings (verified both diagnostics-on and default builds)
  • PKG=victory-gpu ./build.sh test --lib -- descriptor:: --skip views_die_with_their_resource --test-threads=1 (Proton Wine on Linux, RX 9070 XT) — 40 passed; 0 failed
  • Also exercised as part of a combined gameplay run on GTA 6 Series S (Ryzen 5 7600X, RX 9070 XT, CachyOS + Proton); not benchmarked in isolation.

Cost

None (removes two AtomicU64 increments in non-diagnostic builds and redundant TLS writes on shape_seen hits; 0 new warnings).

AI-assisted: yes

**@⁠Not4Eric** on GitHub · 2026-12-04 20:24 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/505) `Not4Eric:perf/descriptor-tls-hit` → `main` · +16 −10 · 1 files · 1 commits · merged 2026-12-05 17:29 UTC ## What this does In `victory_gpu::descriptor::words_for`, skips calling `shape_see` (which re-wrote the thread-local cache) when `shape_seen` already hit, and gates `NAMED_WHOLE` behind `#[cfg(feature = "diagnostics")]` since `views_kept()` is its only reader and is already `#[cfg(all(windows, feature = "diagnostics"))]`. This removes redundant TLS writes and global atomic RMWs from the descriptor-recording hot path without changing behaviour. ## Checks - N/A: pure performance optimization preserving identical behaviour; no new behaviour or switch introduced. - N/A: no switches added, changed, or removed. - [x] No unrelated cleanup: diff is limited to `NAMED_WHOLE` and the `shape_seen` fast path in `crates/victory-gpu/src/descriptor.rs`. - N/A: behavioural invariance verified by existing `descriptor::` unit tests; no failure mode existed before that a unit test could distinguish without timing assertions. - [x] Checked open PR queue: independent of #503 and of `perf/descriptor-fxhash-views` (separate regions of `descriptor.rs`). - [x] `cargo xtask policy` passed (`359 files ok`); no fork-only files, configs, or build outputs. ## Verified - `cargo xtask policy` — `359 files ok` - `PROFILE=diag PKG=victory-gpu ./build.sh check` — 0 warnings (verified both diagnostics-on and default builds) - `PKG=victory-gpu ./build.sh test --lib -- descriptor:: --skip views_die_with_their_resource --test-threads=1` (Proton Wine on Linux, RX 9070 XT) — `40 passed; 0 failed` - Also exercised as part of a combined gameplay run on GTA 6 Series S (Ryzen 5 7600X, RX 9070 XT, CachyOS + Proton); not benchmarked in isolation. ## Cost None (removes two `AtomicU64` increments in non-diagnostic builds and redundant TLS writes on `shape_seen` hits; 0 new warnings). AI-assisted: yes
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-04 20:27:17 +00:00
Author
Owner

@⁠Kal0s-design on GitHub · 2026-12-04 22:34 UTC · original

Checked 863a9ca on native Windows (didn't run the game). Merges clean on current main, victory-gpu lib tests show the same failures as main (indirect host_list x2, pipeline library loads x2, plus the flaky watch test the_rest_of_the_one_asking_has_a_number_of_its_own, which also fails on main when run alone) and clippy with and without diagnostics adds nothing.

The hit path returns the same number as before. On main a hit already skipped the lock, and the shape_see after it was a no-op anyway because its guard (descriptor.rs:893) only writes when the slot differs, so what's saved is a second TLS lookup and hash rather than a write. It can't go stale either, since shape_seen compares the whole shape and shapes/shape_index are only ever appended to (descriptor.rs:742), so a number never changes meaning across heaps or threads. NAMED_WHOLE is only read by views_kept, which is already windows + diagnostics only (descriptor.rs:915, 939), so gating the counter changes nothing outside diagnostics builds.

Looks fine to me.

AI-assisted: yes

**@⁠Kal0s-design** on GitHub · 2026-12-04 22:34 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/505#issuecomment-7426088219) Checked 863a9ca on native Windows (didn't run the game). Merges clean on current main, victory-gpu lib tests show the same failures as main (indirect host_list x2, pipeline library loads x2, plus the flaky watch test the_rest_of_the_one_asking_has_a_number_of_its_own, which also fails on main when run alone) and clippy with and without diagnostics adds nothing. The hit path returns the same number as before. On main a hit already skipped the lock, and the shape_see after it was a no-op anyway because its guard (descriptor.rs:893) only writes when the slot differs, so what's saved is a second TLS lookup and hash rather than a write. It can't go stale either, since shape_seen compares the whole shape and shapes/shape_index are only ever appended to (descriptor.rs:742), so a number never changes meaning across heaps or threads. NAMED_WHOLE is only read by views_kept, which is already windows + diagnostics only (descriptor.rs:915, 939), so gating the counter changes nothing outside diagnostics builds. Looks fine to me. AI-assisted: yes
Author
Owner

@⁠Not4Eric on GitHub · 2026-12-05 00:00 UTC · original

Thank you so much for helping, I'm not the best at this and I'm heavily relying on AI to even do this

**@⁠Not4Eric** on GitHub · 2026-12-05 00:00 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/505#issuecomment-7427747514) Thank you so much for helping, I'm not the best at this and I'm heavily relying on AI to even do this
github manually merged commit e1ae88076f into main 2026-12-05 17:30:18 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.