perf(gpu): batch constant_slots under one SHADER_HEAPS lock, skip Does::Refresh without copies, and zero-clone prelude_uploads #4042

Closed
github-bot wants to merge 1 commit from github-bot/gh-4042 into main AGit
Owner

@⁠qlfu on GitHub · 2026-11-30 15:05 UTC · original
qlfu:pr/perf-batched-constant-slots-and-prelude-uploads → main · +156 −39 · 5 files · 1 commits · closed without merging

Summary

Cuts submitting-thread and sending-thread CPU overhead in card_steps and prelude_uploads:

  1. Batched descriptor::constant_slots_batch & constant_slots_shown (descriptor.rs, descriptor/host.rs, host/card_steps.rs):
    • Holds SHADER_HEAPS.read() once outside the worker pool instead of ~11,000 contended RwLock acquisitions/frame across 8 threads.
    • Pre-resolves distinct &HostHeap targets once, pre-buckets ops by worker (index / 4 % parts) so workers do not scan the full slice 8x, and passes precomputed buffer_gpu via HostHeap::constant_at_with_base to eliminate ~11,000 COM GetGPUVirtualAddress() calls/frame.
  2. Skip Does::Refresh in card_steps::does_of when no Step::Copy exists:
    • Does::Refresh is only consulted by elsewhere() when evaluating Does::Copy; skipping refreshes when !has_copy shrinks does/steps/taken/given by ~5-10x on copy-free submissions.
  3. Zero-clone HostList::prelude_uploads fast path (texture.rs, host.rs):
    • Adds lock-free PreludeUpload::needs_finish_refresh() so prelude_uploads avoids cloning the entire Vec (and 3 Arcs per entry) for the ~99% of textures already uploaded and clean, while still releasing self.deferred() before calling finish_refresh().

Verification

  • cargo check -p victory-gpu --all-targets --all-features --locked: exit 0.
  • cargo test -p victory-gpu --lib --locked -- descriptor:: host::card_steps:: --test-threads=1: 125 passed, 0 failed.
  • git merge-tree --write-tree 41adb551 HEAD: clean merge.
  • 90s in-game runs (RTX 4070 Ti, 1440p DLSS Balanced Native & FG 2x, 0 WARNs / 0 ERRORs): sending-thread heaps + slots down to 0.2 ms.
**@⁠qlfu** on GitHub · 2026-11-30 15:05 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4042) `qlfu:pr/perf-batched-constant-slots-and-prelude-uploads` → `main` · +156 −39 · 5 files · 1 commits · closed without merging ## Summary Cuts submitting-thread and sending-thread CPU overhead in `card_steps` and `prelude_uploads`: 1. **Batched `descriptor::constant_slots_batch` & `constant_slots_shown` (`descriptor.rs`, `descriptor/host.rs`, `host/card_steps.rs`)**: - Holds `SHADER_HEAPS.read()` once outside the worker pool instead of ~11,000 contended `RwLock` acquisitions/frame across 8 threads. - Pre-resolves distinct `&HostHeap` targets once, pre-buckets ops by worker (`index / 4 % parts`) so workers do not scan the full slice 8x, and passes precomputed `buffer_gpu` via `HostHeap::constant_at_with_base` to eliminate ~11,000 COM `GetGPUVirtualAddress()` calls/frame. 2. **Skip `Does::Refresh` in `card_steps::does_of` when no `Step::Copy` exists**: - `Does::Refresh` is only consulted by `elsewhere()` when evaluating `Does::Copy`; skipping refreshes when `!has_copy` shrinks `does`/`steps`/`taken`/`given` by ~5-10x on copy-free submissions. 3. **Zero-clone `HostList::prelude_uploads` fast path (`texture.rs`, `host.rs`)**: - Adds lock-free `PreludeUpload::needs_finish_refresh()` so `prelude_uploads` avoids cloning the entire `Vec` (and 3 `Arc`s per entry) for the ~99% of textures already uploaded and clean, while still releasing `self.deferred()` before calling `finish_refresh()`. ## Verification - `cargo check -p victory-gpu --all-targets --all-features --locked`: exit 0. - `cargo test -p victory-gpu --lib --locked -- descriptor:: host::card_steps:: --test-threads=1`: 125 passed, 0 failed. - `git merge-tree --write-tree 41adb551 HEAD`: clean merge. - 90s in-game runs (RTX 4070 Ti, 1440p DLSS Balanced Native & FG 2x, 0 WARNs / 0 ERRORs): sending-thread `heaps + slots` down to `0.2 ms`.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 15:10:45 +00:00
github-bot closed this pull request 2026-12-01 18:50:45 +00:00
Author
Owner

@⁠trustno1-coder on GitHub · 2026-12-01 18:46 UTC · original

Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

**@⁠trustno1-coder** on GitHub · 2026-12-01 18:46 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4042#issuecomment-7321530335) Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

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