Platform & HLE notes for 1:1 console parity and 30 FPS pacing: XMem split mappings, 4 MiB loose CBV inflation, watchdog contracts, and sync bottlenecks #38

Open
opened 2026-11-26 03:31:28 +00:00 by github-bot · 1 comment
Owner

@⁠owsware on GitHub · 2026-11-25 23:57 UTC · original

Sharing sanitized platform/HLE findings (no title binaries, symbols, offsets, or local paths) gathered while comparing console runtime contracts against our RTX 5080 (32 GB RAM, Ryzen 7 9800X3D) profiling on 0a43566.

1. Memory Mapping (XMem) & Virtual Address Space Contracts

  • Caller-split multi-slice placeholders: Console initialization reserves large contiguous virtual memory spans via XMemVirtualAlloc, splits them into multiple distinct protection regions (5 contiguous slices observed per block with mixed PAGE_READWRITE | PAGE_WRITECOMBINE / guard protections) backed by one XMemAllocatePhysicalPages allocation, and maps each slice individually via XMemMapPhysicalPages. Returning 0 (NULL) triggers an immediate debug break, and coalescing caller-split placeholders corrupts subsequent slice mappings (confirming the need for open PR #14's placeholder boundary preservation).
  • XMemUnmap with page_array = null: Console callers invoke unmap with a null page array pointer expecting actual unmapping rather than a silent no-op.
  • Sub-4 GiB (< 0x1_0000_0000) 32-bit reservations: Reserving headroom below 4 GiB at startup (~185 MiB budget) prevents high-address/sparse allocations from starving 32-bit address space allocators later.

2. Host RAM Pressure (~29 GB Commit) & 4 MiB Lengthless Root-View Inflation

  • Across all 7 RTX 5080 runs (0a43566), working set reached 22.9–25.1 GB and private commit reached 28.6–29.9 GB on a 32 GB host — dangerously close to OOM/thrashing on 16–32 GB systems.
  • Root cause found in host shadow tracking: lengthless shadow::find(addr, 1) calls from root_view allocate up to 4 MiB loose shadow windows even for small root constant buffers (<= 64 KiB D3D12 CBV maximum). In dense world scenes, 470+ lengthless windows (~1.88 GB of loose shadows alone) accumulate alongside ~8 GB of WC staging allocations.
  • Mitigation: Keep unaligned/root CBV scratch uploads bounded to the observed/64 KiB range instead of allocating 4 MiB loose shadow buffers (without truncating legitimate large lengthless SRVs/UAVs).

3. Render Watchdog Contracts & Optional D3D12.X Pre-Warm Slots

  • Watchdog timing (30 s / 300 s): Console runtimes poll the GPU heartbeat QPC every 1000 ms (ignoring >2 s host pause/debugger gaps) and force a deliberate null-address fault after 30 s without render progress (extended to 300 s across tracked blocking sections). Any crash log showing that sentinel null-dereference means the render queue stalled 30 s earlier (DXGI_ERROR_DEVICE_REMOVED, E_INVALIDARG, or blocked PSO/fence wait) — always inspect the earliest failure before the watchdog fires.
  • Optional D3D12.X device vtable slots (0x1b8, 0x1c8, 0x218): Returning E_NOTIMPL is confirmed benign; callers check HRESULT >= 0 before caching pre-warmed pipeline handles and fall back cleanly to standard pipeline creation. By contrast, fixed-size internal object pools will breakpoint immediately if guest memory/aliasing corruption breaks pool headers or counts.

4. 33.3 ms (30 FPS) Parity Bottlenecks & BVH/Video Contracts

Measured per-frame breakdown on RTX 5080 + Ryzen 7 9800X3D (0a43566):

  • THIN=1 recording overhead: 454.2 ms across recording threads (3.9 fps) in Default vs 164.5 ms (10.9 fps) with THIN=0 on LATE_WAIT_LISTS=32.
  • LATE_WAIT=0 vs CPU/GPU overlap: Even with 0 dynamic slot refusals and 0 indirect drops (testF_late0), 161.8 ms/frame (6.2 fps) is spent sequentially across 35.3 ms prepare (155.7 MB uploaded) + 89.8 ms GPU + 31.9 ms copy-back (69.1 MB), plus 133.2 ms across recording threads and 120+ MB compared back. Achieving <= 33.3 ms requires:
    • Non-blocking pipelined CPU/GPU frames without stalling DYNAMIC descriptor reclamation.
    • Resident/VRAM-backed shadow buffers (is_card) minimizing PCIe forward uploads (155–182 MB/frame) and CPU readbacks (42–69 MB/frame).
    • Batched indirect argument clamping/execution so thousands of indirect draws/dispatches do not serialize on redundant barriers/list splits.
  • Batched RT BVH build contract (16x / 256 B scratch): Console BVH builders batch up to 16 builds/rehydrations per invocation over 256-byte aligned reusable scratch buffers with UAV barrier synchronization (and 64-bit Morton codes on non-compacted paths). Fixing the 3 failed compute shaders in builder_runs keeps all 53 stages active rather than dropping ~1,129 world dispatches/frame (3,143–6,342/frame during scene streaming).
  • CPU planar video decode: Video frames decode on worker threads into registered planar buffers with synchronous frame wait and upload (~30 fps pacing already stable in RTX 5080 tests).
**@⁠owsware** on GitHub · 2026-11-25 23:57 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/issues/38) Sharing sanitized platform/HLE findings (no title binaries, symbols, offsets, or local paths) gathered while comparing console runtime contracts against our RTX 5080 (`32 GB` RAM, Ryzen 7 9800X3D) profiling on `0a43566`. ## 1. Memory Mapping (`XMem`) & Virtual Address Space Contracts - **Caller-split multi-slice placeholders**: Console initialization reserves large contiguous virtual memory spans via `XMemVirtualAlloc`, splits them into multiple distinct protection regions (5 contiguous slices observed per block with mixed `PAGE_READWRITE | PAGE_WRITECOMBINE` / guard protections) backed by one `XMemAllocatePhysicalPages` allocation, and maps each slice individually via `XMemMapPhysicalPages`. Returning `0` (`NULL`) triggers an immediate debug break, and coalescing caller-split placeholders corrupts subsequent slice mappings (confirming the need for open **PR #14**'s placeholder boundary preservation). - **`XMemUnmap` with `page_array = null`**: Console callers invoke unmap with a null page array pointer expecting actual unmapping rather than a silent no-op. - **Sub-`4 GiB` (`< 0x1_0000_0000`) 32-bit reservations**: Reserving headroom below `4 GiB` at startup (~`185 MiB` budget) prevents high-address/sparse allocations from starving 32-bit address space allocators later. ## 2. Host RAM Pressure (`~29 GB` Commit) & `4 MiB` Lengthless Root-View Inflation - Across all 7 RTX 5080 runs (`0a43566`), working set reached `22.9–25.1 GB` and private commit reached `28.6–29.9 GB` on a `32 GB` host — dangerously close to OOM/thrashing on `16–32 GB` systems. - **Root cause found in host shadow tracking**: lengthless `shadow::find(addr, 1)` calls from `root_view` allocate up to `4 MiB` loose shadow windows even for small root constant buffers (`<= 64 KiB` D3D12 CBV maximum). In dense world scenes, `470+` lengthless windows (`~1.88 GB` of loose shadows alone) accumulate alongside ~`8 GB` of WC staging allocations. - **Mitigation**: Keep unaligned/root CBV scratch uploads bounded to the observed/`64 KiB` range instead of allocating `4 MiB` loose shadow buffers (without truncating legitimate large lengthless SRVs/UAVs). ## 3. Render Watchdog Contracts & Optional D3D12.X Pre-Warm Slots - **Watchdog timing (`30 s` / `300 s`)**: Console runtimes poll the GPU heartbeat QPC every `1000 ms` (ignoring >`2 s` host pause/debugger gaps) and force a deliberate null-address fault after `30 s` without render progress (extended to `300 s` across tracked blocking sections). Any crash log showing that sentinel null-dereference means the render queue stalled `30 s` earlier (`DXGI_ERROR_DEVICE_REMOVED`, `E_INVALIDARG`, or blocked PSO/fence wait) — always inspect the earliest failure before the watchdog fires. - **Optional D3D12.X device vtable slots (`0x1b8`, `0x1c8`, `0x218`)**: Returning `E_NOTIMPL` is confirmed benign; callers check `HRESULT >= 0` before caching pre-warmed pipeline handles and fall back cleanly to standard pipeline creation. By contrast, fixed-size internal object pools will breakpoint immediately if guest memory/aliasing corruption breaks pool headers or counts. ## 4. `33.3 ms` (30 FPS) Parity Bottlenecks & BVH/Video Contracts Measured per-frame breakdown on RTX 5080 + Ryzen 7 9800X3D (`0a43566`): - **`THIN=1` recording overhead**: `454.2 ms` across recording threads (`3.9 fps`) in Default vs `164.5 ms` (`10.9 fps`) with `THIN=0` on `LATE_WAIT_LISTS=32`. - **`LATE_WAIT=0` vs CPU/GPU overlap**: Even with `0` dynamic slot refusals and `0` indirect drops (`testF_late0`), `161.8 ms/frame` (`6.2 fps`) is spent sequentially across `35.3 ms` prepare (`155.7 MB` uploaded) + `89.8 ms` GPU + `31.9 ms` copy-back (`69.1 MB`), plus `133.2 ms` across recording threads and `120+ MB` compared back. Achieving `<= 33.3 ms` requires: - Non-blocking pipelined CPU/GPU frames without stalling `DYNAMIC` descriptor reclamation. - Resident/VRAM-backed shadow buffers (`is_card`) minimizing PCIe forward uploads (`155–182 MB/frame`) and CPU readbacks (`42–69 MB/frame`). - Batched indirect argument clamping/execution so thousands of indirect draws/dispatches do not serialize on redundant barriers/list splits. - **Batched RT BVH build contract (`16x` / `256 B` scratch)**: Console BVH builders batch up to `16` builds/rehydrations per invocation over `256`-byte aligned reusable scratch buffers with UAV barrier synchronization (and `64`-bit Morton codes on non-compacted paths). Fixing the 3 failed compute shaders in `builder_runs` keeps all `53` stages active rather than dropping `~1,129` world dispatches/frame (`3,143–6,342/frame` during scene streaming). - **CPU planar video decode**: Video frames decode on worker threads into registered planar buffers with synchronous frame wait and upload (~`30 fps` pacing already stable in RTX 5080 tests).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:31:28 +00:00
Author
Owner

@⁠j-fuxa on GitHub · 2026-11-26 01:41 UTC · original

Numbers from a different tree of the same lineage that bear on section 2 (the 4 MiB loose windows) and on the ~29 GB private commit in #38 and #61. RTX 4060 Laptop 8 GB, 32 GB RAM, Windows 11, at world entry.

  • Loose 4 MiB windows held 1.76-1.99 GB of host buffer copies, but submissions touched only 665-838 MiB of them (by our counter of the ranges lists referenced; not the same counter as your window_use "ever copied" line, so compare with care). The windows barely overlap (24-48 MiB), so duplication is not what costs; the untouched part of each window is. The run-65 note in your shadow.rs (3,236 MB of windows, 1,988 MB ever copied) has a similar shape. Shrinking VICTORY_WINDOW_KB is not free, though: a 1 MiB grid made our world entry much slower in one run, and another tree measured about 50% more frame time with 256 KiB windows, so fetching only the touched sub-ranges looks like the better lever to test.
  • Snapshot pool: 1.2-1.3 GB out at once at its peak.
  • The emulator's own private memory (~8 GB) dominates; host buffer copies are 2.8-3.0 GB of it.
  • The title holds 7.1 GB of physical pages, mapped as 11.5 GB of its own views plus 2.3-2.5 GB of GPU page-mapping copies ("~20 GB mapped" is address space). Only 1.9-2.7 GB of distinct title pages were resident, and a zero-page scan found no eager touching.

Accounting traps we hit:

  • On NVIDIA the driver charged D3D12 default-heap textures to process commit at full size (8 x 16 MiB textures = +128 MiB private; about 4.3 GB at world entry). Private commit there is not RAM, but a pagefile or job-object commit limit counts it.
  • Private working set misses title memory held in pagefile-backed sections (counted as shareable, about 7 GiB).
  • Whole working set counts a page mapped at two addresses twice (0.6-1.0 GiB here). QueryWorkingSet's share count saturates at 7, so it cannot dedupe; walking the working set over the known views and counting each section page once does.

Caveat: one GPU and one scene for the NVIDIA commit figure; not measured on AMD.

**@⁠j-fuxa** on GitHub · 2026-11-26 01:41 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/issues/38#issuecomment-7180020625) Numbers from a different tree of the same lineage that bear on section 2 (the 4 MiB loose windows) and on the ~29 GB private commit in #38 and #61. RTX 4060 Laptop 8 GB, 32 GB RAM, Windows 11, at world entry. - Loose 4 MiB windows held 1.76-1.99 GB of host buffer copies, but submissions touched only 665-838 MiB of them (by our counter of the ranges lists referenced; not the same counter as your `window_use` "ever copied" line, so compare with care). The windows barely overlap (24-48 MiB), so duplication is not what costs; the untouched part of each window is. The run-65 note in your `shadow.rs` (3,236 MB of windows, 1,988 MB ever copied) has a similar shape. Shrinking `VICTORY_WINDOW_KB` is not free, though: a 1 MiB grid made our world entry much slower in one run, and another tree measured about 50% more frame time with 256 KiB windows, so fetching only the touched sub-ranges looks like the better lever to test. - Snapshot pool: 1.2-1.3 GB out at once at its peak. - The emulator's own private memory (~8 GB) dominates; host buffer copies are 2.8-3.0 GB of it. - The title holds 7.1 GB of physical pages, mapped as 11.5 GB of its own views plus 2.3-2.5 GB of GPU page-mapping copies ("~20 GB mapped" is address space). Only 1.9-2.7 GB of distinct title pages were resident, and a zero-page scan found no eager touching. Accounting traps we hit: - On NVIDIA the driver charged D3D12 default-heap textures to process commit at full size (8 x 16 MiB textures = +128 MiB private; about 4.3 GB at world entry). Private commit there is not RAM, but a pagefile or job-object commit limit counts it. - Private working set misses title memory held in pagefile-backed sections (counted as shareable, about 7 GiB). - Whole working set counts a page mapped at two addresses twice (0.6-1.0 GiB here). `QueryWorkingSet`'s share count saturates at 7, so it cannot dedupe; walking the working set over the known views and counting each section page once does. Caveat: one GPU and one scene for the NVIDIA commit figure; not measured on AMD.
This discussion has been locked. Commenting is limited to contributors.
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/avatarmanz--VIctory-7900XTX#38
No description provided.