perf(gpu): offload D3D12 retirement and pool trims to bounded zero-box reaper #4138

Closed
github-bot wants to merge 1 commit from github-bot/gh-4138 into main AGit
Owner

@⁠steven-seagull27 on GitHub · 2026-11-30 16:38 UTC · original
steven-seagull27:perf/async-sweep-and-d3d12-reaper → main · +447 −107 · 5 files · 1 commits · closed without merging

What it changes

Synchronous D3D12 COM Release() and WDDM dxgkrnl unmap/decommit calls during command-list resets, pool evictions, and 1-Hz trims can stall the submitting and recording threads or extend pool/staging mutex hold times:

  • Unpooled list uploads, staging evictions, and pool trims previously released D3D12 allocations synchronously on the caller thread: While fenced bury() batches had "victory-bury" (MAX_PENDING_BATCHES = 64) and send::let_go had "victory-send-free", Deferred unpooled uploads / prelude_uploads / placed_cbv on command-list reset/drop, texture::let_go_staging evictions (which previously ran Release() while holding the STAGING mutex), texture::trim_spare_linear, list::trim_idle / recycle command-allocator destruction, texback readback trims, uav_pool evictions/trims, and give_chunks_to / give_uploads / trim_spare_uploads / 1-Hz sweep_spare_chunks still dropped D3D12 allocations synchronously on the caller thread.

Solution

Narrowed per review feedback strictly to the bounded, normal-priority, zero-box background D3D12 reaper (VICTORY_REAPER=0 opt-out), leaving synchronous sweep(), VICTORY_SWEEP_AHEAD (default off), keeps_under_pressure() (8 GiB), and send::let_go untouched:

  • Bounded "victory-reaper" worker at normal thread priority (MAX_PENDING_REAP = 64):
    • Replaces bury_pool ("victory-bury") with std::sync::mpsc::sync_channel::<ReapItem>(64) drained by a normal-priority "victory-reaper" thread (VICTORY_REAPER=0 opt-out).
    • On TrySendError::Full or TrySendError::Disconnected, drops the item inline on the caller thread — preserving bury()'s exact 64-batch backpressure bound so saturated CPUs (e.g. 6-core hosts paired with 12 GB GPUs near VRAM budget) never accumulate unbounded released resources in a background queue.
    • Thread-local ON_REAPER detection runs any nested reap_* calls triggered inside Drop implementations inline on "victory-reaper" without consuming extra channel slots.
  • Concrete ReapItem enum with zero per-resource boxing & inline bury_lag() == 0 path:
    • ReapItem::{Resource(ID3D12Resource), Resources(Vec<ID3D12Resource>), Retired(Vec<Retired>), Boxed(Box<dyn Send>)} moves single resources, Vec<ID3D12Resource> batches, and fenced Vec<Retired> (Retired::Resource unboxed) across the channel without per-resource Box allocations; reap_batch<T>(Vec<T>) returns early when empty and uses at most a single box for an entire coarse trim Vec<T>.
    • retire() and retire_resource() keep their immediate inline drop when bury_lag() == 0 and no submission is in flight.
  • Safe non-OOM-retry D3D12 release routing:
    • Deferred::clear() and Drop for Deferred: runs self.held.clear() synchronously first so completion guards execute before scratch chunks recycle, then sends non-empty uploads (reap_resources), prelude_uploads (reap_batch), and placed_cbv (reap_resource) to "victory-reaper".
    • Pool trims and evictions outside locks: give_chunks_to, give_uploads, 1-Hz sweep_spare_chunks, uav_pool::give_uavs, and texture::trim_spare_linear via reap_resources; trim_spare_uploads, uav_pool trims, list::trim_idle / recycle, texback trims, and texture::let_go_staging (cloned out before releasing the STAGING mutex) via reap_batch.
    • Synchronous OOM-retry paths (pub fn trim_spare_chunks() for VirtualAlloc(MEM_COMMIT) / hard-flush callers and free_all_spares() for E_OUTOFMEMORY upload retries) continue dropping synchronously so retried allocations immediately observe freed pages.

How it was tested

  • Synthetic unit tests (victory-gpu --lib):
    • host::batch::reap_helpers_drop_asynchronously_and_honor_opt_out — verifies "victory-reaper" asynchronous drops for reap_batch and reap_retired (plus reap_resource / reap_resources when a D3D12 device is present), inline nested drops via ON_REAPER, synchronous Deferred::held guard execution on both clear() and Drop, and VICTORY_REAPER=0 synchronous opt-out.
    • host::batch::reap_backpressure_bound_falls_back_to_inline_drop_without_leaking — verifies filling a sync_channel::<ReapItem>(MAX_PENDING_REAP) (64) enqueues the first 64 items and falls back cleanly to inline drop past 64 (as well as on disconnected/unavailable channels) without blocking or leaking items.
    • Existing host::bury_tests::bury_drops_retired_objects_asynchronously, plus module suites (host::, list::, texture::, texback::), cargo clippy -p victory-gpu --lib --tests, and cargo run -p xtask -- policy --staged.
  • cargo test passed for the crates it touches: yes

Checked for overlap

  • Narrowed strictly to the bounded D3D12 reaper per review feedback: async sweep (VICTORY_ASYNC_SWEEP), VICTORY_SWEEP_AHEAD, keeps_under_pressure(), and send::let_go (697590ad) are untouched, avoiding any overlap with #4226.
**@⁠steven-seagull27** on GitHub · 2026-11-30 16:38 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4138) `steven-seagull27:perf/async-sweep-and-d3d12-reaper` → `main` · +447 −107 · 5 files · 1 commits · closed without merging ## What it changes Synchronous D3D12 COM `Release()` and WDDM `dxgkrnl` unmap/decommit calls during command-list resets, pool evictions, and 1-Hz trims can stall the submitting and recording threads or extend pool/staging mutex hold times: - **Unpooled list uploads, staging evictions, and pool trims previously released D3D12 allocations synchronously on the caller thread:** While fenced `bury()` batches had `"victory-bury"` (`MAX_PENDING_BATCHES = 64`) and `send::let_go` had `"victory-send-free"`, `Deferred` unpooled `uploads` / `prelude_uploads` / `placed_cbv` on command-list reset/drop, `texture::let_go_staging` evictions (which previously ran `Release()` while holding the `STAGING` mutex), `texture::trim_spare_linear`, `list::trim_idle` / `recycle` command-allocator destruction, `texback` readback trims, `uav_pool` evictions/trims, and `give_chunks_to` / `give_uploads` / `trim_spare_uploads` / 1-Hz `sweep_spare_chunks` still dropped D3D12 allocations synchronously on the caller thread. ### Solution Narrowed per review feedback strictly to the bounded, normal-priority, zero-box background D3D12 reaper (`VICTORY_REAPER=0` opt-out), leaving synchronous `sweep()`, `VICTORY_SWEEP_AHEAD` (default off), `keeps_under_pressure()` (`8 GiB`), and `send::let_go` untouched: - **Bounded `"victory-reaper"` worker at normal thread priority (`MAX_PENDING_REAP = 64`):** - Replaces `bury_pool` (`"victory-bury"`) with `std::sync::mpsc::sync_channel::<ReapItem>(64)` drained by a normal-priority `"victory-reaper"` thread (`VICTORY_REAPER=0` opt-out). - On `TrySendError::Full` or `TrySendError::Disconnected`, drops the item inline on the caller thread — preserving `bury()`'s exact 64-batch backpressure bound so saturated CPUs (e.g. 6-core hosts paired with 12 GB GPUs near VRAM budget) never accumulate unbounded released resources in a background queue. - Thread-local `ON_REAPER` detection runs any nested `reap_*` calls triggered inside `Drop` implementations inline on `"victory-reaper"` without consuming extra channel slots. - **Concrete `ReapItem` enum with zero per-resource boxing & inline `bury_lag() == 0` path:** - `ReapItem::{Resource(ID3D12Resource), Resources(Vec<ID3D12Resource>), Retired(Vec<Retired>), Boxed(Box<dyn Send>)}` moves single resources, `Vec<ID3D12Resource>` batches, and fenced `Vec<Retired>` (`Retired::Resource` unboxed) across the channel without per-resource `Box` allocations; `reap_batch<T>(Vec<T>)` returns early when empty and uses at most a single box for an entire coarse trim `Vec<T>`. - `retire()` and `retire_resource()` keep their immediate inline `drop` when `bury_lag() == 0` and no submission is in flight. - **Safe non-OOM-retry D3D12 release routing:** - `Deferred::clear()` and `Drop for Deferred`: runs `self.held.clear()` **synchronously first** so completion guards execute before scratch chunks recycle, then sends non-empty `uploads` (`reap_resources`), `prelude_uploads` (`reap_batch`), and `placed_cbv` (`reap_resource`) to `"victory-reaper"`. - Pool trims and evictions outside locks: `give_chunks_to`, `give_uploads`, 1-Hz `sweep_spare_chunks`, `uav_pool::give_uavs`, and `texture::trim_spare_linear` via `reap_resources`; `trim_spare_uploads`, `uav_pool` trims, `list::trim_idle` / `recycle`, `texback` trims, and `texture::let_go_staging` (cloned out before releasing the `STAGING` mutex) via `reap_batch`. - Synchronous OOM-retry paths (`pub fn trim_spare_chunks()` for `VirtualAlloc(MEM_COMMIT)` / hard-flush callers and `free_all_spares()` for `E_OUTOFMEMORY` upload retries) continue dropping synchronously so retried allocations immediately observe freed pages. ## How it was tested - **Synthetic unit tests (`victory-gpu --lib`):** - `host::batch::reap_helpers_drop_asynchronously_and_honor_opt_out` — verifies `"victory-reaper"` asynchronous drops for `reap_batch` and `reap_retired` (plus `reap_resource` / `reap_resources` when a D3D12 device is present), inline nested drops via `ON_REAPER`, synchronous `Deferred::held` guard execution on both `clear()` and `Drop`, and `VICTORY_REAPER=0` synchronous opt-out. - `host::batch::reap_backpressure_bound_falls_back_to_inline_drop_without_leaking` — verifies filling a `sync_channel::<ReapItem>(MAX_PENDING_REAP)` (`64`) enqueues the first 64 items and falls back cleanly to inline `drop` past 64 (as well as on disconnected/unavailable channels) without blocking or leaking items. - Existing `host::bury_tests::bury_drops_retired_objects_asynchronously`, plus module suites (`host::`, `list::`, `texture::`, `texback::`), `cargo clippy -p victory-gpu --lib --tests`, and `cargo run -p xtask -- policy --staged`. - `cargo test` passed for the crates it touches: yes ## Checked for overlap - [x] Narrowed strictly to the bounded D3D12 reaper per review feedback: async sweep (`VICTORY_ASYNC_SWEEP`), `VICTORY_SWEEP_AHEAD`, `keeps_under_pressure()`, and `send::let_go` (`697590ad`) are untouched, avoiding any overlap with `#4226`.
- Replace the partial `bury_pool` queue with a unified `"victory-reaper"` background worker (`THREAD_PRIORITY_BELOW_NORMAL`, `VICTORY_REAPER=0` opt-out, inline nested-drop detection via `ON_REAPER`) so D3D12 COM `Release()` and WDDM `dxgkrnl` unmap/unpin calls never stall submitting, relay, or sweep threads.
- Route fence-retired `bury()` batches, immediate `retire()` / `retire_resource()` drops, `Deferred` unpooled `uploads` and `prelude_uploads` (keeping `Deferred::held` completion guards synchronous ahead of `plane_uploads` recycling), spare upload/scratch/UAV/send/linear-detile pool evictions and trims, `list::trim_idle` / `recycle`, `texback` readback trims, and `texture::let_go_staging` evictions through `host::reap()`.
- Default `VICTORY_SWEEP_AHEAD` to ON (`VICTORY_SWEEP_AHEAD=0` opt-out) so `late_free_present` periodic sweeps no longer force a full GPU pipeline settle drain every `sweep_every_ms()` when `VICTORY_UPCOPY_CHECK` is off.
- Offload periodic `sweep()` and out-of-band idle texture reclaim requests onto a dedicated `"victory-sweep"` background worker (`THREAD_PRIORITY_BELOW_NORMAL`, `VICTORY_ASYNC_SWEEP=0` opt-out), preserving synchronous `sweep_sync()` for `upcheck` and settled `VICTORY_SWEEP_AHEAD=0` paths.
- Lower the default `keeps_under_pressure()` free physical RAM threshold from 8 GiB to 2 GiB (`VICTORY_SPARE_KEEP_FREE_MB`, default `2048`) so 32 GiB hosts under commit pressure retain warm spare pools up to `SPARE_MOST` instead of thrashing allocations at 1 Hz, while hosts below 2 GiB free still drop to `SPARE_FLOOR` (or `0` on critical commit).
- Add synthetic unit tests covering `reap()` thread routing, nested inline drops, synchronous `Deferred::held` guard execution, `"victory-sweep"` execution, `VICTORY_SWEEP_AHEAD` defaults/overrides, and `VICTORY_SPARE_KEEP_FREE_MB` pressure thresholds.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 16:39:49 +00:00
github-bot force-pushed github-bot/gh-4138 from e7ad054e4e to c876444b35 2026-11-30 16:52:04 +00:00 Compare
Author
Owner

@⁠IRennie74 on GitHub · 2026-11-30 18:22 UTC · original · edited 2026-11-30 18:44 UTC

This bundles four independent changes. Each changes a default, and the PR has no game measurement for any of them. Concrete concerns, by part:

  1. The bury queue lost its bound. bury() used to push at most MAX_PENDING_BATCHES (64) batches to victory-bury and drop inline beyond that. reap() sends to an unbounded mpsc channel, drained by one thread at THREAD_PRIORITY_BELOW_NORMAL. On a saturated CPU that thread can fall behind, and released resources (VRAM included) pile up in the channel.

    On a Ryzen 5 5600X + RTX 3060 12 GB (Series S, DLSS Performance), the title uses about 3 cores, the list threads 1.7 and ours the rest, so below-normal threads do get starved there. On a 12 GB card running near its texture budget, late releases cost the most. Keeping a bound, and dropping inline past it, would keep the old guarantee.

  2. retire/retire_resource now box every object. The immediate path calls reap(object): a Box::new and a channel send per object. Retired::Resource exists to avoid exactly that ("20,000 a frame, without a box each"). Batching these as bury does, or keeping the inline drop for single resources, would avoid the regression.

  3. The async sweep holds hot locks at below-normal priority. run_sweep on victory-sweep runs resource::let_go_idle and texture::let_go_idle under the texture table's and STAGING's locks. #4227 measured let_go_idle at 39-75 ms on a full card. A below-normal thread holding those locks while normal-priority recording threads and the submitting thread wait for them is a priority inversion, and it gets worse the fewer cores there are.

    Also, the sweep at rest relied on "what the sweep lets go of is named by no list, and nothing runs now" (the comment above SWEPT in Host::submit). The PR should say why each let_go_idle stays safe when it overlaps the submitting thread's own preparation, not only the recording threads.

  4. Two default flips that deserve their own PRs:

    • VICTORY_SWEEP_AHEAD on: on the 5600X/3060 rig above it was within noise, 16.5-17.9 fps against 17.3-18.5 for baselines of the same runs (standing, A/B/A).
    • keeps_under_pressure 8 GiB -> 2 GiB free: the comment this replaces records why 8 GiB was chosen ("on a 16 GB PC keeping them cost some 40 ms a frame of waits for flights", PR #57). A 16 GB PC under load commonly has 2-8 GiB free, so 2 GiB brings that case back. It needs a measurement on a 16 GB PC before it changes.

Splitting this into four PRs would let the safe parts land: the reaper with a bound, the async sweep opt-in, the SWEEP_AHEAD default, and the spare threshold. #4227 already discusses how its change 2 interacts with part 3.

**@⁠IRennie74** on GitHub · 2026-11-30 18:22 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4138#issuecomment-7287767971) · edited 2026-11-30 18:44 UTC This bundles four independent changes. Each changes a default, and the PR has no game measurement for any of them. Concrete concerns, by part: 1. **The bury queue lost its bound.** `bury()` used to push at most `MAX_PENDING_BATCHES` (64) batches to `victory-bury` and drop inline beyond that. `reap()` sends to an unbounded `mpsc` channel, drained by one thread at `THREAD_PRIORITY_BELOW_NORMAL`. On a saturated CPU that thread can fall behind, and released resources (VRAM included) pile up in the channel. On a Ryzen 5 5600X + RTX 3060 12 GB (Series S, DLSS Performance), the title uses about 3 cores, the list threads 1.7 and ours the rest, so below-normal threads do get starved there. On a 12 GB card running near its texture budget, late releases cost the most. Keeping a bound, and dropping inline past it, would keep the old guarantee. 2. **`retire`/`retire_resource` now box every object.** The immediate path calls `reap(object)`: a `Box::new` and a channel send per object. `Retired::Resource` exists to avoid exactly that ("20,000 a frame, without a box each"). Batching these as `bury` does, or keeping the inline drop for single resources, would avoid the regression. 3. **The async sweep holds hot locks at below-normal priority.** `run_sweep` on `victory-sweep` runs `resource::let_go_idle` and `texture::let_go_idle` under the texture table's and `STAGING`'s locks. #4227 measured `let_go_idle` at 39-75 ms on a full card. A below-normal thread holding those locks while normal-priority recording threads and the submitting thread wait for them is a priority inversion, and it gets worse the fewer cores there are. Also, the sweep at rest relied on "what the sweep lets go of is named by no list, and nothing runs now" (the comment above `SWEPT` in `Host::submit`). The PR should say why each `let_go_idle` stays safe when it overlaps the submitting thread's own preparation, not only the recording threads. 4. **Two default flips that deserve their own PRs:** - `VICTORY_SWEEP_AHEAD` on: on the 5600X/3060 rig above it was within noise, 16.5-17.9 fps against 17.3-18.5 for baselines of the same runs (standing, A/B/A). - `keeps_under_pressure` 8 GiB -> 2 GiB free: the comment this replaces records why 8 GiB was chosen ("on a 16 GB PC keeping them cost some 40 ms a frame of waits for flights", PR #57). A 16 GB PC under load commonly has 2-8 GiB free, so 2 GiB brings that case back. It needs a measurement on a 16 GB PC before it changes. Splitting this into four PRs would let the safe parts land: the reaper with a bound, the async sweep opt-in, the SWEEP_AHEAD default, and the spare threshold. #4227 already discusses how its change 2 interacts with part 3.
Author
Owner

@⁠Zeyphers on GitHub · 2026-11-30 20:20 UTC · original

Merged onto main 84bd61e2 and benched on an RTX 2080 Super 8 GB and Ryzen 7 5800X (Series S, DLSS Quality, standing scene, 180 s): 10.0 fps median vs 9.2–9.7 baseline, so no measurable change on this CPU-bound rig. Two baseline runs differed by about 0.5 fps, so that's the noise. Only one run per PR, in a standing scene, not a walk.

**@⁠Zeyphers** on GitHub · 2026-11-30 20:20 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4138#issuecomment-7290751472) Merged onto main `84bd61e2` and benched on an RTX 2080 Super 8 GB and Ryzen 7 5800X (Series S, DLSS Quality, standing scene, 180 s): 10.0 fps median vs 9.2–9.7 baseline, so no measurable change on this CPU-bound rig. Two baseline runs differed by about 0.5 fps, so that's the noise. Only one run per PR, in a standing scene, not a walk.
Author
Owner

@⁠paales on GitHub · 2026-11-30 20:51 UTC · original

Written by 🤖:

In-game numbers for this PR. PC: RTX 5070 Ti 16 GB, Ryzen 9 5900X, 32 GB, Windows 11. Series X, 1440p, DLSS Performance, frame generation off. Each run: a new game (settings save, no story save), one A press, the first cutscene for 60 s from its first frame. On this PC the same build's submitting thread took 24 ms a frame in one run and 35 ms in another half an hour later, so only large differences count. 30 fps cap.

Base: main 84bd61e2 with #3918, #1727, #3553, #3043 and #4207 (VICTORY_FILL_AHEAD=1). One run each.

base with this PR
seconds with a frame over 50 ms 19 21
seconds with a frame over 100 ms 2 0
longest frame 430 ms 96 ms
textures picked by index, frames late on average (most) 0.53 (12) 0.53 (12)

Fewer long spikes; the rest is within this PC's spread. No crash in about 15 runs since. It is in the build I play with.

**@⁠paales** on GitHub · 2026-11-30 20:51 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4138#issuecomment-7291577275) _Written by 🤖:_ In-game numbers for this PR. PC: RTX 5070 Ti 16 GB, Ryzen 9 5900X, 32 GB, Windows 11. Series X, 1440p, DLSS Performance, frame generation off. Each run: a new game (settings save, no story save), one A press, the first cutscene for 60 s from its first frame. On this PC the same build's submitting thread took 24 ms a frame in one run and 35 ms in another half an hour later, so only large differences count. 30 fps cap. Base: `main` 84bd61e2 with #3918, #1727, #3553, #3043 and #4207 (`VICTORY_FILL_AHEAD=1`). One run each. | | base | with this PR | | --- | --- | --- | | seconds with a frame over 50 ms | 19 | 21 | | seconds with a frame over 100 ms | 2 | 0 | | longest frame | 430 ms | 96 ms | | textures picked by index, frames late on average (most) | 0.53 (12) | 0.53 (12) | Fewer long spikes; the rest is within this PC's spread. No crash in about 15 runs since. It is in the build I play with.
github-bot changed title from perf(gpu): offload D3D12 retirement and periodic sweeps to background threads to perf(gpu): offload D3D12 retirement and pool trims to bounded zero-box reaper 2026-11-30 23:08:29 +00:00
github-bot force-pushed github-bot/gh-4138 from c876444b35 to 9fb5f56acd 2026-11-30 23:08:30 +00:00 Compare
Author
Owner

@⁠steven-seagull27 on GitHub · 2026-11-30 23:04 UTC · original

Thank you @⁠IRennie74 for the thorough review and hardware analysis. I have rebased onto origin/main and narrowed this PR strictly to the bounded, zero-box background D3D12 reaper, addressing all four points:

  1. Restored the 64-item queue bound and normal thread priority: "victory-reaper" now uses std::sync::mpsc::sync_channel::<ReapItem>(64) (MAX_PENDING_REAP = 64) at normal thread priority (no THREAD_PRIORITY_BELOW_NORMAL, matching "victory-bury"). On TrySendError::Full or TrySendError::Disconnected, try_enqueue_reap drops the item inline on the caller thread so 6-core CPUs paired with 12 GB cards near VRAM budget never starve the reaper or accumulate released VRAM in the channel. Added a synthetic backpressure unit test (reap_backpressure_bound_falls_back_to_inline_drop_without_leaking) verifying exact inline fallback past 64 queued items without blocking or leaking.
  2. Eliminated per-resource Box allocations and restored inline bury_lag() == 0 drops: Replaced Box<dyn Send> per call with a concrete ReapItem enum (Resource(ID3D12Resource), Resources(Vec<ID3D12Resource>), Retired(Vec<Retired>), and Boxed(Box<dyn Send>) strictly for non-empty coarse Vec<T> trim batches via reap_batch). retire() and retire_resource() once again drop inline when bury_lag() == 0 and no submission is in flight, while fenced bury() batches move Vec<Retired> (Retired::Resource unboxed) directly through ReapItem::Retired. Also kept synchronous drops on the OOM-retry paths (pub fn trim_spare_chunks() and free_all_spares()) and left send::let_go (697590ad) untouched.
  3. Removed VICTORY_ASYNC_SWEEP from this PR: sweep() remains synchronous on main, avoiding lock priority inversion on the texture and STAGING locks and any overlap with #4226.
  4. Removed both default flips (VICTORY_SWEEP_AHEAD and keeps_under_pressure): Both remain at main's defaults (VICTORY_SWEEP_AHEAD off unless set, and keeps_under_pressure at 8 GiB free physical RAM) so any future changes there can be evaluated in separate PRs with dedicated measurements.
**@⁠steven-seagull27** on GitHub · 2026-11-30 23:04 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4138#issuecomment-7294684131) Thank you @⁠IRennie74 for the thorough review and hardware analysis. I have rebased onto `origin/main` and narrowed this PR strictly to the bounded, zero-box background D3D12 reaper, addressing all four points: 1. **Restored the 64-item queue bound and normal thread priority:** `"victory-reaper"` now uses `std::sync::mpsc::sync_channel::<ReapItem>(64)` (`MAX_PENDING_REAP = 64`) at normal thread priority (no `THREAD_PRIORITY_BELOW_NORMAL`, matching `"victory-bury"`). On `TrySendError::Full` or `TrySendError::Disconnected`, `try_enqueue_reap` drops the item inline on the caller thread so 6-core CPUs paired with 12 GB cards near VRAM budget never starve the reaper or accumulate released VRAM in the channel. Added a synthetic backpressure unit test (`reap_backpressure_bound_falls_back_to_inline_drop_without_leaking`) verifying exact inline fallback past 64 queued items without blocking or leaking. 2. **Eliminated per-resource `Box` allocations and restored inline `bury_lag() == 0` drops:** Replaced `Box<dyn Send>` per call with a concrete `ReapItem` enum (`Resource(ID3D12Resource)`, `Resources(Vec<ID3D12Resource>)`, `Retired(Vec<Retired>)`, and `Boxed(Box<dyn Send>)` strictly for non-empty coarse `Vec<T>` trim batches via `reap_batch`). `retire()` and `retire_resource()` once again drop inline when `bury_lag() == 0` and no submission is in flight, while fenced `bury()` batches move `Vec<Retired>` (`Retired::Resource` unboxed) directly through `ReapItem::Retired`. Also kept synchronous drops on the OOM-retry paths (`pub fn trim_spare_chunks()` and `free_all_spares()`) and left `send::let_go` (`697590ad`) untouched. 3. **Removed `VICTORY_ASYNC_SWEEP` from this PR:** `sweep()` remains synchronous on `main`, avoiding lock priority inversion on the texture and `STAGING` locks and any overlap with `#4226`. 4. **Removed both default flips (`VICTORY_SWEEP_AHEAD` and `keeps_under_pressure`):** Both remain at `main`'s defaults (`VICTORY_SWEEP_AHEAD` off unless set, and `keeps_under_pressure` at `8 GiB` free physical RAM) so any future changes there can be evaluated in separate PRs with dedicated measurements.
github-bot force-pushed github-bot/gh-4138 from 9fb5f56acd to 1f0d90d6ce 2026-12-01 00:52:31 +00:00 Compare
github-bot closed this pull request 2026-12-01 18:50:41 +00:00
Author
Owner

@⁠trustno1-coder on GitHub · 2026-12-01 18:46 UTC · original

Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

**@⁠trustno1-coder** on GitHub · 2026-12-01 18:46 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4138#issuecomment-7321520627) Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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/trustno1-coder--VIctory-NVIDIA!4138
No description provided.