Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions docs/experiments.md
Original file line number Diff line number Diff line change
Expand Up @@ -17299,3 +17299,94 @@ needs support for consuming the resulting `srv ... buf root` manifest record.
```powershell
ctest --test-dir out/build/release --no-tests=error -R "^startup_compute_global_load_(controls|warp|hardware)$" -V
```

## Design B descriptor retention and host commit on a 16 GiB system (#2379)

R0Y00's standing decision on #2379 keeps **design B** (#2679): a materialized descriptor and its copies own the
resource until the slot is overwritten, copied over, or the heap wrapper is destroyed. A final guest `Release()`
plus completed release fences retire prior references and submissions, but a live descriptor slot must still
support rebinding, so `drain_retired_resources()` frees a class member only when `retire_view_refs == 0` and no
recording hold or in-flight submission names it. Slice 3 ended with #2719 (slots 19-21 tracked like slot 18);
`X2W_D3D12_RELEASE_RETIRED_VIEWS` stays a legacy diagnostic that logs clearing is disabled. This rule intentionally retains live descriptor-owned bytes. The measurements below report total pressure and, where available, its ownership breakdown.

### Matched retention pair (AMD Radeon RX 9070 XT, 16 GB, driver 32.0.32029.2010, Windows 11 26300)

One release build, `main` `6b9fb9d9` (#2468 merged), only `X2W_D3D12_RELEASE_RETIRED` differs; same executable,
saved profile, warm shader cache, 32 GiB job cap, `X2W_D3D12_BUDGET=1`, `run.ps1 -Render`, 600 s window, scripted
input that clears the legal/acceptance page. [Matched RX 9070 XT runs](https://github.com/R0Y00/Xbox2Windows/issues/2379#issuecomment-7173347195)

| | switch off | switch on |
|---|---|---|
| first failure / timeout | access violation at **490.7 s** after 8x `0x8007000e` | none; still running at the 600 s timeout |
| `0x8007000e` / device removed | 8 / 0 | 0 / 0 |
| desktop references dropped by the drain | 0 | 53,000 |
| texture retained, peak | **10.67 GB / 4,874** | **9.41 GB / 4,364** |
| texture retained, end | 10.67 GB / 4,874 | 9.10 GB / 4,267 |
| DXGI local usage / budget, peak | 20.32 / 14.51 GB | 19.91 / 14.46 GB |
| DXGI non-local usage, peak | 6.01 GB | 6.43 GB |
| system commit 10 s after exit | 24.9 GiB | 25.0 GiB |

Retention climbs in steps and does not come back down (switch-on: ~0.08 GB at 290 s, 3.80 GB at 375 s, 6.28 GB at
460 s, 9.39 GB at 520 s). Slice 2 removed the out-of-memory failure inside the window but left local usage about
5.4 GB over the DXGI budget; a second switch-on run at `e29b1a7b` reached the timeout with 9.14 GB retained. The
~9 GB is the retained texture budget measured in these runs. The attribution below comes from a separate run.

### Attribution: live slots vs recording holds vs in-flight work

A separate roughly six-minute startup run at `1cce2a32` used a local opt-in counter to attribute each final-released resource that was still live. [Attribution report](https://github.com/R0Y00/Xbox2Windows/issues/2379#issuecomment-7174634554)

```
x2w-retire held: view-refs=2297/4445110272(oldest 4374f) never-class:buffer=8178/551813120
never-class:dimension=4/262144 never-class:rt-ds-uav=14/200212480
view-refs-in-visible-heap=2297/4445110272 total=10493/5197398016 unattributed=0/0
```

About **4.4 GB** (4,445,110,272 bytes / 2,297 objects, oldest 4,374 frames) are slot 133 class members kept alive
only by a descriptor in a shader-visible heap that is never overwritten (`view-refs`, all in visible heaps);
~0.55 GB are never-class buffers and ~0.2 GB never-class RT/DS/UAV textures. `unattributed=0/0`: the counter
accounts for every retained byte.

Upstream `X2W_D3D12_RETIRE_REASONS=1` (with `X2W_D3D12_RELEASE_RETIRED=1` and `X2W_D3D12_BUDGET=1`) emits one
`x2w-retire held:` heartbeat line from `retire_reasons_line` (`src/startup_stubs/d3d12_xs_device.cpp`). The `Held`
taxonomy distinguishes the three ownership kinds R0Y00 asked to separate:

- **live descriptor slots** - `view-refs` (a tracked `HeapInfo::shadow` cell still names the resource), plus
`view-refs-in-visible-heap` for the shader-visible subset;
- **recording holds** - `list-hold` (`retire_list_holds`, a closed recording that names the resource) and
`unqueued` / `drain-pending`;
- **in-flight work** - `flight` (`retire_flights`, a submission behind an unsignalled fence) and
`queued-waiting-fence`;
- resources that left the class are reported as `left-class:{view,view-copy,residency,present,hold-missed}` and
`never-class:{slot,buffer,dimension,msaa,rt-ds-uav,heap-type,heap-flags,title-memory,aliased,reserved}`, with
`total` and `unattributed` (budget `retained` minus the attributed sum) closing the line.

On a GTX 1660 SUPER diagnostic run with the current tree the line reads
`never-class:buffer=2/131072 never-class:dimension=4/262144 never-class:rt-ds-uav=3/103481344 total=9/103874560
unattributed=0/0`; the descriptor-owned bytes stay in the budget `retained` column because design B keeps them
resolvable, exactly as the matched pair above measures.

### Host-commit measurements on a 16 GiB system

The reporter used a GTX 1660 SUPER with 5,966 MiB of VRAM on Windows 11 and a 22,931.8 MiB system commit limit. A release build of main at `d1b2be6a`, including #2767 and #2770, ran for 180 seconds with `-Render -Translate -FakeUser -GpuMirror -LazyMemory`. It recorded 3,260 storage requests, 3,994 frames, and a host-commit peak of **11,053 MiB**. The reporter observed zero device-removal, out-of-memory or mapping-failure lines during the window. [Main-only result](https://github.com/R0Y00/Xbox2Windows/pull/2780#issuecomment-7187587300)

A separate experimental build included #2767/#2770 and local versions of #2773/#2775. It enabled lazy textures and the large existing-heap cap and ran for 300 seconds, recording 3,260 storage requests and 6,434 frames. The existing-heap cap used in that build now requires `X2W_D3D12_CAP_EXISTING_HEAP=1`. These figures compare the reported historical baseline with the experimental combination. The runs do not isolate the contribution of individual patches. [Combined experimental result](https://github.com/R0Y00/Xbox2Windows/pull/2775#issuecomment-7186316341)

| Metric | Reported historical baseline | 300 s experimental combination |
|---|---:|---:|
| Host commit peak | 12,144 MiB | 8,787 MiB |
| DXGI non-local peak | 2,897 MiB | 695 MiB |
| Existing-heap bytes | 2,199 MiB | 0 MiB |

The experiment identifies remaining commit from slot 133 render-target, depth and UAV textures, small buffers subject to WDDM allocation granularity, and duplicate committed buffers for mapped memory. The descriptor retention rule described above still applies.

### Verification

```powershell
ctest --preset dev --no-tests=error -R "^startup_resource_(retire|budget)" -V
ctest --preset dev --no-tests=error -R "^startup_slot133_heap_cap_" -V
ctest --preset dev --no-tests=error -R "^(xmem_|startup_run_ps1)" -V
python -B tests/docs_links_check.py
```

`startup_resource_retire_reasons` drives the `Held` attribution line; `startup_resource_retire_views` proves the
design-B keep cases (a live slot stays reboundable after final `Release()` and completed fences). The tables above record contributors' local executable runs. The fixtures validate the retention behavior independently. Refs #2379, #2679, #2719, #1199.
Loading