perf(gpu): optimize draw/heap tables, descriptor host heap, write-watch pruning, and pool caps #525

Open
github-bot wants to merge 1 commit from github-bot/gh-525 into main AGit
Owner

@⁠ZerefDragnee1l on GitHub · 2026-12-06 01:53 UTC · original
ZerefDragnee1l:perf/gpu-hot-paths-and-memory-caps → main · +1106 −316 · 11 files · 1 commits · open

Splits the non-pipeline GPU hot-path optimizations and pool/journal memory caps out of #408 onto current main (preserving #376 WindowsIdentity scoping and #452 NVIDIA 616.x handling in host.rs).

Summary

  • Draw / heap tables (crates/larp-gpu/src/draw.rs):
    • Key HostList::first_use per strides_buffer, reuse Scratch vecs, cache Picks spans/slots, and replace bytes.contains with BYTES bitflags.
    • Gate duplicate WHOLE unwatched copies per (frame, from, to) so wider ranges within the same frame still refresh (*from >= last_from && *to <= last_to), while narrower repeats only hold the copy for cross-queue ordering.
  • Descriptor host heap (crates/larp-gpu/src/descriptor/host.rs):
    • Lock-free Acquire/Release fast-hit path in make_from, 64-bit word bitset allocator in dynamic/release pools, batched COM retires, and no-op keep() guard.
  • Write-watch pruning (crates/larp-gpu/src/watch.rs):
    • Prune MEM_FREE and stale unguarded MEM_MAPPED view entries when j.written exceeds written_prune_at, keeping live/dirty/guarded pages (views, protected, clean, absent, hot, or when >= asked.min(ahead_asked)) intact.
  • Host, allocators, staging, copyback, perf overlay & capture (host.rs, allocators.rs, staging.rs, copyback/buffers.rs, slotfree.rs, overlay/perf.rs, capture.rs, stall.rs):
    • Prefer high-performance GPU adapter (DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE) & triple buffering, gate diagnostics-only fields/CardClock, skip empty KEPT locks, use unstamped cursor in slotfree, cap idle allocators (64) and staging arenas (16), use O(N) select_nth_unstable_by in overlay/perf.rs, and fast-path disabled capture/stall hooks.

Verification

  • git diff --check -> clean
  • cargo check -p larp -> exited 0 (larp-gpu compiled with 0 warnings)
  • cargo test -p larp-gpu --lib -- --skip hardware_test --skip compare_listed_shader_resolution -> 32 passed; 0 failed; 5 ignored (2 filtered out for skipped tests; 5 hardware/D3D12/SM6.6 tests ignored by #[ignore]), including descriptor::host::tests::dynamic_bitset_alloc_and_release, host::windows_pipeline_identity_uses_device_instance_across_luid_changes, and host::copy_runs_tests::copy_runs_matches_reference_fuzz.
**@⁠ZerefDragnee1l** on GitHub · 2026-12-06 01:53 UTC · [original](https://github.com/gamingwithhomie/larp/pull/525) `ZerefDragnee1l:perf/gpu-hot-paths-and-memory-caps` → `main` · +1106 −316 · 11 files · 1 commits · open Splits the non-pipeline GPU hot-path optimizations and pool/journal memory caps out of #408 onto current `main` (preserving #376 `WindowsIdentity` scoping and #452 NVIDIA 616.x handling in `host.rs`). ### Summary - **Draw / heap tables (`crates/larp-gpu/src/draw.rs`)**: - Key `HostList::first_use` per `strides_buffer`, reuse `Scratch` vecs, cache `Picks` spans/slots, and replace `bytes.contains` with `BYTES` bitflags. - Gate duplicate `WHOLE` unwatched copies per `(frame, from, to)` so wider ranges within the same frame still refresh (`*from >= last_from && *to <= last_to`), while narrower repeats only hold the copy for cross-queue ordering. - **Descriptor host heap (`crates/larp-gpu/src/descriptor/host.rs`)**: - Lock-free `Acquire`/`Release` fast-hit path in `make_from`, 64-bit word bitset allocator in dynamic/release pools, batched COM retires, and no-op `keep()` guard. - **Write-watch pruning (`crates/larp-gpu/src/watch.rs`)**: - Prune `MEM_FREE` and stale unguarded `MEM_MAPPED` view entries when `j.written` exceeds `written_prune_at`, keeping live/dirty/guarded pages (`views`, `protected`, `clean`, `absent`, `hot`, or `when >= asked.min(ahead_asked)`) intact. - **Host, allocators, staging, copyback, perf overlay & capture (`host.rs`, `allocators.rs`, `staging.rs`, `copyback/buffers.rs`, `slotfree.rs`, `overlay/perf.rs`, `capture.rs`, `stall.rs`)**: - Prefer high-performance GPU adapter (`DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE`) & triple buffering, gate diagnostics-only fields/`CardClock`, skip empty `KEPT` locks, use unstamped cursor in `slotfree`, cap idle allocators (64) and staging arenas (16), use `O(N)` `select_nth_unstable_by` in `overlay/perf.rs`, and fast-path disabled capture/stall hooks. ### Verification - `git diff --check` -> clean - `cargo check -p larp` -> exited 0 (`larp-gpu` compiled with 0 warnings) - `cargo test -p larp-gpu --lib -- --skip hardware_test --skip compare_listed_shader_resolution` -> `32 passed; 0 failed; 5 ignored` (`2 filtered out` for skipped tests; 5 hardware/D3D12/SM6.6 tests ignored by `#[ignore]`), including `descriptor::host::tests::dynamic_bitset_alloc_and_release`, `host::windows_pipeline_identity_uses_device_instance_across_luid_changes`, and `host::copy_runs_tests::copy_runs_matches_reference_fuzz`.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-06 01:54:28 +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/525/head:github-bot/gh-525'
git switch 'github-bot/gh-525'

Merge

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