perf(victory-gpu): reclaim idle host list allocators, thin backing lists, and spike indirect buffers #494

Closed
Lewandox wants to merge 3 commits from upstream-pr/494 into main
Lewandox commented 2026-11-27 12:59:28 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by Lewandox on 2026-11-27T12:59:28Z.


Summary

  • Add opt-in host-list allocator and scratch reclamation gated behind VICTORY_RECLAIM_LISTS=1 (off by default, preserving existing default behaviour until A/B-measured in-game):
    • Pressure-scaled idle host-list pool caps (idle_cap: 512 / 256 / 64 / 0) and periodic idle eviction via list::let_go_idle() hooked into host::sweep().
    • Reuse pooled host lists in list::boxed() when VICTORY_RECLAIM_LISTS=1 is set.
    • Cap and sweep idle thin backing lists (list/thin.rs) and word buffers under host RAM pressure; evicted backing lists are dropped directly via Box::from_raw (since backing lists never go through object::hand_out and have refs == 0, so object::release_boxed::<List> would be a no-op and leak them), and impl Drop for List purges any stale VALUE_WAITS entries.
    • Trim spike-grown indirect argument buffers above indirect_keep_limit (1 MiB, 256 KiB under pressure), overflow batch buffers, and oversized states/twins maps on HostList::reset() when VICTORY_RECLAIM_LISTS=1.
  • Add unit tests covering evict_idle, idle_cap, backs_cap, indirect_keep_limit, release_back_drops_unreferenced_backing_list, and host_list_reset_trims_oversized_indirect_buffer_when_reclaim_enabled.

Verification

  • cargo +stable-x86_64-pc-windows-gnu test -p victory-gpu host_list_reset_trims_oversized_indirect_buffer_when_reclaim_enabled -- --nocapture
  • cargo +stable-x86_64-pc-windows-gnu test -p victory-gpu list:: -- --nocapture
  • cargo +stable-x86_64-pc-windows-gnu run -p xtask -- policy -> asset policy: 295 files ok.
  • Note: Verified with unit tests and static analysis; no live title private-RAM / frame-time capture was run in this environment (hence gated behind VICTORY_RECLAIM_LISTS=1).

Checklist

  • The PR covers a single reviewable behaviour.
  • Tests cover the new behaviour and pass with this change.
  • The commands and results of each check are given above.
  • An unimplemented function returns an error (E_NOTIMPL), never a fake success.
  • README: unchanged.
  • No game, console or SDK file, no key, no dump, no download link.
  • Findings drawn from a title: none used here.
  • Code taken from another project: none.
  • AI assistance: implemented and verified with AI coding assistance.
<!-- greyfinch-sync:LooperSalty/AnyXboxX:issue:5527043524 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/494). Originally posted by [Lewandox](https://github.com/Lewandox) on 2026-11-27T12:59:28Z. --- ## Summary - Add opt-in host-list allocator and scratch reclamation gated behind `VICTORY_RECLAIM_LISTS=1` (off by default, preserving existing default behaviour until A/B-measured in-game): - Pressure-scaled idle host-list pool caps (`idle_cap`: 512 / 256 / 64 / 0) and periodic idle eviction via `list::let_go_idle()` hooked into `host::sweep()`. - Reuse pooled host lists in `list::boxed()` when `VICTORY_RECLAIM_LISTS=1` is set. - Cap and sweep idle thin backing lists (`list/thin.rs`) and word buffers under host RAM pressure; evicted backing lists are dropped directly via `Box::from_raw` (since backing lists never go through `object::hand_out` and have `refs == 0`, so `object::release_boxed::<List>` would be a no-op and leak them), and `impl Drop for List` purges any stale `VALUE_WAITS` entries. - Trim spike-grown indirect argument buffers above `indirect_keep_limit` (1 MiB, 256 KiB under pressure), overflow batch buffers, and oversized `states`/`twins` maps on `HostList::reset()` when `VICTORY_RECLAIM_LISTS=1`. - Add unit tests covering `evict_idle`, `idle_cap`, `backs_cap`, `indirect_keep_limit`, `release_back_drops_unreferenced_backing_list`, and `host_list_reset_trims_oversized_indirect_buffer_when_reclaim_enabled`. ## Verification - `cargo +stable-x86_64-pc-windows-gnu test -p victory-gpu host_list_reset_trims_oversized_indirect_buffer_when_reclaim_enabled -- --nocapture` - `cargo +stable-x86_64-pc-windows-gnu test -p victory-gpu list:: -- --nocapture` - `cargo +stable-x86_64-pc-windows-gnu run -p xtask -- policy` -> `asset policy: 295 files ok`. - Note: Verified with unit tests and static analysis; no live title private-RAM / frame-time capture was run in this environment (hence gated behind `VICTORY_RECLAIM_LISTS=1`). ## Checklist - [x] The PR covers a single reviewable behaviour. - [x] Tests cover the new behaviour and pass with this change. - [x] The commands and results of each check are given above. - [x] An unimplemented function returns an error (`E_NOTIMPL`), never a fake success. - [x] README: unchanged. - [x] No game, console or SDK file, no key, no dump, no download link. - [x] Findings drawn from a title: none used here. - [x] Code taken from another project: none. - AI assistance: implemented and verified with AI coding assistance.
LooperSalty commented 2026-11-27 15:49:10 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by LooperSalty on 2026-11-27T15:49:10Z.


Thanks for going after the allocator RAM. I found no reuse of an allocator still in flight (recycle only sees lists list::ran reported, and let_go_idle only evicts lists already reset). Before merge:

  1. Default behaviour changes with no switch. The pool cap now follows RAM pressure (512/256/64/0), a periodic sweep evicts idle lists, boxed() now takes pooled lists, and HostList::reset() drops indirect buffers above 1 MiB (256 KiB under pressure) on every reset. The last one can cost frame time: a pass that needs a >1 MiB indirect buffer every frame (cutscenes, chases) will now free and recreate a UAV buffer each frame. Please either put the new reclamation behind an env switch, or give before/after numbers for both the lists' allocators private RAM and fps on such a scene, and say in the description which defaults change.
  2. Tests. Only the pure helpers are tested (evict_idle, the caps, indirect_keep_limit, release_back). Reverting the reset() drops or the sweep would not fail any test. A test that grows a list's indirect buffer past the limit, resets it and checks that it is gone (and kept below the limit) would cover the new path.
  3. Stale description. The body says overflow backing lists go through object::release_boxed::<List>, but the code (list/thin.rs, release_back) uses Box::from_raw, and your own test explains why release_boxed would leak. Please update the text.

We will also run it in game on our side.

<!-- greyfinch-sync:LooperSalty/AnyXboxX:comment:7222519822 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/494#issuecomment-7222519822). Originally posted by [LooperSalty](https://github.com/LooperSalty) on 2026-11-27T15:49:10Z. --- Thanks for going after the allocator RAM. I found no reuse of an allocator still in flight (`recycle` only sees lists `list::ran` reported, and `let_go_idle` only evicts lists already reset). Before merge: 1. **Default behaviour changes with no switch.** The pool cap now follows RAM pressure (512/256/64/0), a periodic sweep evicts idle lists, `boxed()` now takes pooled lists, and `HostList::reset()` drops indirect buffers above 1 MiB (256 KiB under pressure) on every reset. The last one can cost frame time: a pass that needs a >1 MiB indirect buffer every frame (cutscenes, chases) will now free and recreate a UAV buffer each frame. Please either put the new reclamation behind an env switch, or give before/after numbers for both the `lists' allocators` private RAM and fps on such a scene, and say in the description which defaults change. 2. **Tests.** Only the pure helpers are tested (`evict_idle`, the caps, `indirect_keep_limit`, `release_back`). Reverting the `reset()` drops or the sweep would not fail any test. A test that grows a list's indirect buffer past the limit, resets it and checks that it is gone (and kept below the limit) would cover the new path. 3. **Stale description.** The body says overflow backing lists go through `object::release_boxed::<List>`, but the code (`list/thin.rs`, `release_back`) uses `Box::from_raw`, and your own test explains why `release_boxed` would leak. Please update the text. We will also run it in game on our side.
Lewandox commented 2026-11-27 16:25:13 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by Lewandox on 2026-11-27T16:25:13Z.


Addressed all 3 points:

  1. Gated all new reclamation (pressure-scaled pool caps, \list::let_go_idle()\ sweep, pooled \oxed()\ reuse, thin backing-list caps, and \HostList::reset()\ indirect/batch/map trimming) behind opt-in \VICTORY_RECLAIM_LISTS=1\ (off by default, preserving existing behaviour until A/B-measured).
  2. Added \host::batch::host_list_reset_trims_oversized_indirect_buffer_when_reclaim_enabled\ exercising a real \HostList: verifies a 256 KiB indirect buffer stays on reset, a 2 MiB buffer stays when reclaim is off, and is dropped on reset when reclaim is on.
  3. Updated the PR description to reflect \Box::from_raw\ (instead of
    elease_boxed) and document \VICTORY_RECLAIM_LISTS=1.

Re-verified \host_list_reset_trims_oversized_indirect_buffer_when_reclaim_enabled, \list::\ (11 passed), and \xtask policy.

<!-- greyfinch-sync:LooperSalty/AnyXboxX:comment:7223239566 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/494#issuecomment-7223239566). Originally posted by [Lewandox](https://github.com/Lewandox) on 2026-11-27T16:25:13Z. --- Addressed all 3 points: 1. Gated all new reclamation (pressure-scaled pool caps, \list::let_go_idle()\ sweep, pooled \oxed()\ reuse, thin backing-list caps, and \HostList::reset()\ indirect/batch/map trimming) behind opt-in \VICTORY_RECLAIM_LISTS=1\ (off by default, preserving existing behaviour until A/B-measured). 2. Added \host::batch::host_list_reset_trims_oversized_indirect_buffer_when_reclaim_enabled\ exercising a real \HostList\: verifies a 256 KiB indirect buffer stays on reset, a 2 MiB buffer stays when reclaim is off, and is dropped on reset when reclaim is on. 3. Updated the PR description to reflect \Box::from_raw\ (instead of \ elease_boxed\) and document \VICTORY_RECLAIM_LISTS=1\. Re-verified \host_list_reset_trims_oversized_indirect_buffer_when_reclaim_enabled\, \list::\ (11 passed), and \xtask policy\.
LooperSalty commented 2026-11-28 00:15:28 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by LooperSalty on 2026-11-28T00:15:28Z.


Main just took #563 (the VIctory copy moved to Vice-Tay 4f15f09e) and #564 (memory stack), and this PR now conflicts in third_party/victory/crates/victory-gpu/src/host.rs, third_party/victory/crates/victory-gpu/src/list.rs. Please rebase on current main, rerun the tests for the files you touch, and force-push.

<!-- greyfinch-sync:LooperSalty/AnyXboxX:comment:7230770819 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/494#issuecomment-7230770819). Originally posted by [LooperSalty](https://github.com/LooperSalty) on 2026-11-28T00:15:28Z. --- Main just took #563 (the VIctory copy moved to Vice-Tay `4f15f09e`) and #564 (memory stack), and this PR now conflicts in `third_party/victory/crates/victory-gpu/src/host.rs`, `third_party/victory/crates/victory-gpu/src/list.rs`. Please rebase on current main, rerun the tests for the files you touch, and force-push.
Lewandox commented 2026-11-28 08:19:38 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by Lewandox on 2026-11-28T08:19:38Z.


Rebased onto main (132da61), resolving conflicts in host.rs and list.rs while preserving both #564's idle_trim_seconds / texture_backs / close_open_lists changes and this PR's VICTORY_RECLAIM_LISTS=1-gated reclamation.

Verified locally:

  • cargo test -p victory-gpu host_list_reset_trims_oversized_indirect_buffer_when_reclaim_enabled: 1 passed, 0 failed
  • cargo test -p victory-gpu list::: 15 passed, 0 failed
  • cargo run -p xtask -- policy: asset policy: 377 files ok
<!-- greyfinch-sync:LooperSalty/AnyXboxX:comment:7236510247 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/494#issuecomment-7236510247). Originally posted by [Lewandox](https://github.com/Lewandox) on 2026-11-28T08:19:38Z. --- Rebased onto `main` (`132da61`), resolving conflicts in `host.rs` and `list.rs` while preserving both `#564`'s `idle_trim_seconds` / `texture_backs` / `close_open_lists` changes and this PR's `VICTORY_RECLAIM_LISTS=1`-gated reclamation. Verified locally: - `cargo test -p victory-gpu host_list_reset_trims_oversized_indirect_buffer_when_reclaim_enabled`: 1 passed, 0 failed - `cargo test -p victory-gpu list::`: 15 passed, 0 failed - `cargo run -p xtask -- policy`: `asset policy: 377 files ok`
Lewandox commented 2026-11-30 00:57:02 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by Lewandox on 2026-11-30T00:57:02Z.


Closing since the upstream project has been discontinued. Thanks for everything!

<!-- greyfinch-sync:LooperSalty/AnyXboxX:comment:7265714902 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/494#issuecomment-7265714902). Originally posted by [Lewandox](https://github.com/Lewandox) on 2026-11-30T00:57:02Z. --- Closing since the upstream project has been discontinued. Thanks for everything!

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
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.

Reference
LooperSalty/AnyXboxX!494
No description provided.