CPU: auto-free hybrid CPUs, BTreeMap RETIRED drain, 64k descriptor rings, and recording hot-path opts #394

Open
github-bot wants to merge 2 commits from github-bot/gh-394 into main AGit
Owner

@⁠Lakanya on GitHub · 2026-12-06 00:04 UTC · original
Lakanya:pr/cpu-hybrid-and-hotpaths → main · +101 −36 · 8 files · 2 commits · open

Reduces CPU recording/submission overhead and 1%/0.1% low frame-time spikes with zero visual or rendering shortcuts.

What is in it

  • crates/larp-hle/src/modules/placement.rs: skip affinity pinning when the host has fewer than 14 better logical CPUs (wanted.count_ones() < 14), preventing 8 recording threads + render/submit/layer threads from oversubscribing 4 P-cores on hybrid mobile/desktop CPUs.
  • crates/larp-gpu/src/host.rs:
    • Replace Mutex<Vec<...>> O(N) partition scans in RETIRED and RETIRED_RELEASE with BTreeMap<u64, Vec<...>> split_off drains (ported from Darner PR #274).
    • Gate per-draw HostList::note_program() SetMarker + UTF-16 String/Vec allocations behind LARP_D3D12_DRED=markers (keeping DRED breadcrumbs/page-faults intact under LARP_D3D12_DRED=1).
    • Gate HostList::used_pipeline() String allocation behind dred_on() || cfg!(feature = "diagnostics"), and add single-lock HostList::keep_pair() for PSO + root signature in draw.rs.
  • crates/larp-gpu/src/frame.rs: skip std::thread::sleep(Duration::ZERO) on zero-timeout WaitFrameEventX polls (ported from Darner PR #538).
  • crates/larp-gpu/src/descriptor/stage.rs & descriptor.rs: raise stage::LOG (4096 -> 65536) and ENDED_LOG (16384 -> 65536) to avoid 83k-slot view-heap rescans during streaming.
  • apps/larp/src/subrender.rs: 64-way shard TRACK and SHADOW_VIEWS RwLock<HashMap>s to remove cross-core contention on added recording threads 5-7.
  • crates/larp-gpu/src/descriptor/host.rs: track dynamic_kept: AtomicBool so HostHeap::release() skips the per-slot Mutex loop when no dynamic slot ever stored into kept.

Tested

  • Hardware: Windows 11 x64, RTX 5070 Mobile (8 GB VRAM), 16-thread hybrid CPU, Series X profile @ 2560x1440 DLSS Performance (FG off).
  • cargo test --lib -p larp-gpu -p larp-hle -- --test-threads=4 + cargo check --workspace: larp-gpu 24 passed / 0 failed / 6 ignored; larp-hle 76 passed / 0 failed / 4 ignored.
  • Live A/B (opening 3D gameplay scene, 0 dropped draws): steady FPS 14.2 -> 27.8-28.1 fps (at 30 fps scene cap), p95 444.9 -> 45.3 ms, p99 730.6 -> 79.9 ms.
  • Not tested on Linux/Wine.

AI-assisted by Antigravity (Gemini 4 Neon Medium).

**@⁠Lakanya** on GitHub · 2026-12-06 00:04 UTC · [original](https://github.com/gamingwithhomie/larp/pull/394) `Lakanya:pr/cpu-hybrid-and-hotpaths` → `main` · +101 −36 · 8 files · 2 commits · open Reduces CPU recording/submission overhead and 1%/0.1% low frame-time spikes with zero visual or rendering shortcuts. ### What is in it - `crates/larp-hle/src/modules/placement.rs`: skip affinity pinning when the host has fewer than 14 better logical CPUs (`wanted.count_ones() < 14`), preventing 8 recording threads + render/submit/layer threads from oversubscribing 4 P-cores on hybrid mobile/desktop CPUs. - `crates/larp-gpu/src/host.rs`: - Replace `Mutex<Vec<...>>` O(N) partition scans in `RETIRED` and `RETIRED_RELEASE` with `BTreeMap<u64, Vec<...>>` `split_off` drains (ported from Darner PR #274). - Gate per-draw `HostList::note_program()` `SetMarker` + UTF-16 `String`/`Vec` allocations behind `LARP_D3D12_DRED=markers` (keeping DRED breadcrumbs/page-faults intact under `LARP_D3D12_DRED=1`). - Gate `HostList::used_pipeline()` `String` allocation behind `dred_on() || cfg!(feature = "diagnostics")`, and add single-lock `HostList::keep_pair()` for PSO + root signature in `draw.rs`. - `crates/larp-gpu/src/frame.rs`: skip `std::thread::sleep(Duration::ZERO)` on zero-timeout `WaitFrameEventX` polls (ported from Darner PR #538). - `crates/larp-gpu/src/descriptor/stage.rs` & `descriptor.rs`: raise `stage::LOG` (`4096 -> 65536`) and `ENDED_LOG` (`16384 -> 65536`) to avoid 83k-slot view-heap rescans during streaming. - `apps/larp/src/subrender.rs`: 64-way shard `TRACK` and `SHADOW_VIEWS` `RwLock<HashMap>`s to remove cross-core contention on added recording threads 5-7. - `crates/larp-gpu/src/descriptor/host.rs`: track `dynamic_kept: AtomicBool` so `HostHeap::release()` skips the per-slot `Mutex` loop when no dynamic slot ever stored into `kept`. ### Tested - Hardware: Windows 11 x64, RTX 5070 Mobile (8 GB VRAM), 16-thread hybrid CPU, Series X profile @ 2560x1440 DLSS Performance (FG off). - `cargo test --lib -p larp-gpu -p larp-hle -- --test-threads=4` + `cargo check --workspace`: `larp-gpu` 24 passed / 0 failed / 6 ignored; `larp-hle` 76 passed / 0 failed / 4 ignored. - Live A/B (opening 3D gameplay scene, 0 dropped draws): steady FPS `14.2 -> 27.8-28.1 fps` (at 30 fps scene cap), p95 `444.9 -> 45.3 ms`, p99 `730.6 -> 79.9 ms`. - Not tested on Linux/Wine. AI-assisted by Antigravity (Gemini 4 Neon Medium).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-06 00:07:30 +00:00
Author
Owner

@⁠vanya890 on GitHub · 2026-12-06 01:36 UTC · original · reviewed

The benchmark is encouraging, especially the p95/p99 reduction, and the change is sensibly aimed at contention rather than reducing rendering quality. One point worth documenting is the wanted.count_ones() < 14 placement cutoff: the PR explains the eight recording threads and four P-cores on the tested machine, but the threshold is now a general policy for every CPU topology. Could you add a short rationale for why 14 is the safe boundary, or a small unit test covering representative hybrid layouts (for example 6P+8E and 8P+8E)? That would make the heuristic easier to maintain when newer hybrid CPUs have different P/E ratios.

**@⁠vanya890** on GitHub · 2026-12-06 01:36 UTC · [original](https://github.com/gamingwithhomie/larp/pull/394#pullrequestreview-6207481017) · **reviewed** The benchmark is encouraging, especially the p95/p99 reduction, and the change is sensibly aimed at contention rather than reducing rendering quality. One point worth documenting is the `wanted.count_ones() < 14` placement cutoff: the PR explains the eight recording threads and four P-cores on the tested machine, but the threshold is now a general policy for every CPU topology. Could you add a short rationale for why 14 is the safe boundary, or a small unit test covering representative hybrid layouts (for example 6P+8E and 8P+8E)? That would make the heuristic easier to maintain when newer hybrid CPUs have different P/E ratios.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/394/head:github-bot/gh-394'
git switch 'github-bot/gh-394'

Merge

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