gpu: lazily attach host lists on reset and trim idle list/send pools under memory pressure #319

Closed
github-bot wants to merge 1 commit from github-bot/gh-319 into a-publier AGit
Owner

@⁠mynzjerko on GitHub · 2026-11-26 20:03 UTC · original
mynzjerko:perf/lazy-host-list-and-idle-trim → a-publier · +292 −52 · 4 files · 1 commits · closed without merging

Addresses the idle command-list allocator and upload-pool memory pressure noted on 32 GB / RX 9070 systems (see #298).

Summary

1. Lazy HostList attachment across detach / reset and thin::BACKS (RAM + CPU)

  • Previously, list::detach and list::detach_parts eagerly popped or created a fresh_list() (each holding a D3D12 ID3D12CommandAllocator and optional prelude allocator) and immediately called fresh.close() so the idle List kept a live HostList until its next Reset() — where host.reset() then reset the empty allocator and list a second time.
  • Under VICTORY_THIN=1 (default in scripts/play.ps1), thin::back_list also created a HostList + close() even though every Recording starts with RESET, and thin::BACKS was an unbounded pool of raw Box<List> shells whose parked/abandoned entries retained HostLists, uploads, and draw state.
  • Now:
    • detach / detach_parts simply take() list.host (leaving None), eliminating redundant close() + second reset() calls and preventing idle title lists and thin::BACKS from holding D3D12 command allocators.
    • list::reset lazily attaches an already-open, already-reset HostList via fresh_list() when list.host is None (and calls HostList::mark_used to preserve LISTS[3] accounting).
    • thin::back_list allocates an empty shell (host: None), Recording::drop calls list::release_idle_back to strip/recycle any unsubmitted HostList, earlier parts, uploads, and draw state before parking, and BACKS is bounded (BACKS_MOST = 128) with excess shells dropped outside the lock.

2. Trim idle HostList and send::SPARE upload pools under VICTORY_RESIDENCY=1

  • list::IDLE (previously always capped at 512 and never trimmed) now scales its limit with residency (512 default -> 128 on <=32 GB limited_host_ram -> 32 under pressured -> 0 under critical_commit) and exposes list::trim_idle() to drop the oldest idle HostLists outside the lock during the 1 Hz sweep.
  • host::send::SPARE (previously always capped at 768 MiB and dropping buffers under the mutex) now scales its budget with residency (768 MiB default -> 256 MiB limited -> 64 MiB pressured -> 0 critical; 256 MiB BAR unchanged), drops freed D3D12 upload buffers outside the lock, and exposes send::trim_spare() for the 1 Hz sweep.
  • Both trimmers are invoked alongside trim_spare_chunks() in host.rs when residency::pressured() || residency::critical_commit().

Verification (Windows 11, RX 9070 / 32 GB RAM)

  • cargo xtask policy: passed (269 files ok)
  • cargo test -p victory-gpu --locked --lib -- --test-threads=1 list:: queue:: host::send:: residency:: (default & --all-features): 21/21 passed, including live D3D12 tests for lazy detach/reset, release_idle_back, and trim_idle_to(0)
  • cargo test -p xtask --locked: 9/9 passed
  • cargo clippy -p victory-gpu --no-deps --all-targets --all-features --locked: 0 warnings in all modified files
  • cargo build --locked --profile diag -p victory --features diagnostics: clean build

(Prepared with AI assistance; compiled and tested locally on Windows 11 with an AMD Radeon RX 9070.)

**@⁠mynzjerko** on GitHub · 2026-11-26 20:03 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/319) `mynzjerko:perf/lazy-host-list-and-idle-trim` → `a-publier` · +292 −52 · 4 files · 1 commits · closed without merging Addresses the idle command-list allocator and upload-pool memory pressure noted on 32 GB / RX 9070 systems (see #298). ## Summary ### 1. Lazy `HostList` attachment across `detach` / `reset` and `thin::BACKS` (RAM + CPU) - Previously, `list::detach` and `list::detach_parts` eagerly popped or created a `fresh_list()` (each holding a D3D12 `ID3D12CommandAllocator` and optional prelude allocator) and immediately called `fresh.close()` so the idle `List` kept a live `HostList` until its next `Reset()` — where `host.reset()` then reset the empty allocator and list a second time. - Under `VICTORY_THIN=1` (default in `scripts/play.ps1`), `thin::back_list` also created a `HostList` + `close()` even though every `Recording` starts with `RESET`, and `thin::BACKS` was an unbounded pool of raw `Box<List>` shells whose parked/abandoned entries retained `HostList`s, uploads, and draw state. - Now: - `detach` / `detach_parts` simply `take()` `list.host` (leaving `None`), eliminating redundant `close()` + second `reset()` calls and preventing idle title lists and `thin::BACKS` from holding D3D12 command allocators. - `list::reset` lazily attaches an already-open, already-reset `HostList` via `fresh_list()` when `list.host` is `None` (and calls `HostList::mark_used` to preserve `LISTS[3]` accounting). - `thin::back_list` allocates an empty shell (`host: None`), `Recording::drop` calls `list::release_idle_back` to strip/recycle any unsubmitted `HostList`, `earlier` parts, uploads, and draw state before parking, and `BACKS` is bounded (`BACKS_MOST = 128`) with excess shells dropped outside the lock. ### 2. Trim idle `HostList` and `send::SPARE` upload pools under `VICTORY_RESIDENCY=1` - `list::IDLE` (previously always capped at 512 and never trimmed) now scales its limit with `residency` (512 default -> 128 on <=32 GB `limited_host_ram` -> 32 under `pressured` -> 0 under `critical_commit`) and exposes `list::trim_idle()` to drop the oldest idle `HostList`s outside the lock during the 1 Hz sweep. - `host::send::SPARE` (previously always capped at 768 MiB and dropping buffers under the mutex) now scales its budget with `residency` (768 MiB default -> 256 MiB limited -> 64 MiB pressured -> 0 critical; 256 MiB BAR unchanged), drops freed D3D12 upload buffers outside the lock, and exposes `send::trim_spare()` for the 1 Hz sweep. - Both trimmers are invoked alongside `trim_spare_chunks()` in `host.rs` when `residency::pressured() || residency::critical_commit()`. ## Verification (Windows 11, RX 9070 / 32 GB RAM) - `cargo xtask policy`: passed (269 files ok) - `cargo test -p victory-gpu --locked --lib -- --test-threads=1 list:: queue:: host::send:: residency::` (default & `--all-features`): 21/21 passed, including live D3D12 tests for lazy `detach`/`reset`, `release_idle_back`, and `trim_idle_to(0)` - `cargo test -p xtask --locked`: 9/9 passed - `cargo clippy -p victory-gpu --no-deps --all-targets --all-features --locked`: 0 warnings in all modified files - `cargo build --locked --profile diag -p victory --features diagnostics`: clean build *(Prepared with AI assistance; compiled and tested locally on Windows 11 with an AMD Radeon RX 9070.)*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:12:48 +00:00
github-bot closed this pull request 2026-11-26 20:38:42 +00:00

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.