perf(resource): release settled peak render-target reserve after 20s stability window #3944

Open
qlfu wants to merge 1 commit from upstream-pr/3944 into main
qlfu commented 2026-11-30 12:36:39 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by qlfu on 2026-11-30T12:36:39Z.


Summary

  • In targets_room_kept (crates/victory-gpu/src/resource.rs), the default peak-based path already computes the GREW / settle (VICTORY_CARD_ROOM_FOR_TARGETS_SETTLE_MS, default 20 s) stability window on every call, but targets_kept_from_peak ignored it and held the 1.5x peak reserve indefinitely instead of releasing it once targets settle.
  • Adds targets_kept_from_peak_settled(most, targets, peak, still_ms, settle): once settle > 0 && targets >= 256 MiB && still_ms >= settle, returns 0 (matching the flat-reserve path's targets_kept), freeing ~850 MiB of texture headroom on 12 GiB cards in steady-state gameplay while keeping the full reserve during startup/scene transitions and when settle == 0.

Verification

  • Added unit tests in crates/victory-gpu/src/resource.rs covering pre-settle, settled, settle == 0, and below-256-MiB cases.
  • cargo test -p victory-gpu --lib --locked -- resource:: --test-threads=1: passed (0 failed).
  • cargo check -p victory-gpu --all-targets --all-features --locked: exit 0.
  • git merge-tree --write-tree 41adb551 HEAD: clean merge.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5565412656 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3944). Originally posted by [qlfu](https://github.com/qlfu) on 2026-11-30T12:36:39Z. --- ## Summary - In `targets_room_kept` (`crates/victory-gpu/src/resource.rs`), the default peak-based path already computes the `GREW` / `settle` (`VICTORY_CARD_ROOM_FOR_TARGETS_SETTLE_MS`, default 20 s) stability window on every call, but `targets_kept_from_peak` ignored it and held the 1.5x peak reserve indefinitely instead of releasing it once targets settle. - Adds `targets_kept_from_peak_settled(most, targets, peak, still_ms, settle)`: once `settle > 0 && targets >= 256 MiB && still_ms >= settle`, returns `0` (matching the flat-reserve path's `targets_kept`), freeing ~850 MiB of texture headroom on 12 GiB cards in steady-state gameplay while keeping the full reserve during startup/scene transitions and when `settle == 0`. ## Verification - Added unit tests in `crates/victory-gpu/src/resource.rs` covering pre-settle, settled, `settle == 0`, and below-256-MiB cases. - `cargo test -p victory-gpu --lib --locked -- resource:: --test-threads=1`: passed (0 failed). - `cargo check -p victory-gpu --all-targets --all-features --locked`: exit 0. - `git merge-tree --write-tree 41adb551 HEAD`: clean merge.
tyr0nsur commented 2026-11-30 13:16:30 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by tyr0nsur on 2026-11-30T13:16:30Z.


I reproduced a scene-transition case at aa0b9cc. After targets have settled, a sharp drop updates last in targets_seen but leaves the last growth timestamp unchanged. The automatic reserve can stay at zero while a prior target set has gone away and its replacements have not yet been made.

The companion patch restarts the automatic stability timer after a 64 MiB or larger move in either direction. During replacement it holds only the gap to the preceding footprint, capped by the existing maximum. The explicit flat setting still uses the growth-only timer, and settle=0 retains the original peak calculation. The footprint and timer are sampled together so a competing reader cannot store an old timer value.

In a synthetic trace for the 2,560 MiB small-card cap, the original PR kept zero after a settled 1,712 MiB footprint dropped to 390 MiB. The patch keeps 1,322 MiB of admission headroom at that point, 812 MiB after the replacement footprint reaches 900 MiB, and zero after 20 seconds at 900 MiB. These are policy outputs. No title run or VRAM-usage claim. The focused resource suite passed 46 tests on an RTX 4060 and under WARP.

Companion commit

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7279606928 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3944#issuecomment-7279606928). Originally posted by [tyr0nsur](https://github.com/tyr0nsur) on 2026-11-30T13:16:30Z. --- I reproduced a scene-transition case at `aa0b9cc`. After targets have settled, a sharp drop updates `last` in `targets_seen` but leaves the last growth timestamp unchanged. The automatic reserve can stay at zero while a prior target set has gone away and its replacements have not yet been made. The companion patch restarts the automatic stability timer after a 64 MiB or larger move in either direction. During replacement it holds only the gap to the preceding footprint, capped by the existing maximum. The explicit flat setting still uses the growth-only timer, and settle=0 retains the original peak calculation. The footprint and timer are sampled together so a competing reader cannot store an old timer value. In a synthetic trace for the 2,560 MiB small-card cap, the original PR kept zero after a settled 1,712 MiB footprint dropped to 390 MiB. The patch keeps 1,322 MiB of admission headroom at that point, 812 MiB after the replacement footprint reaches 900 MiB, and zero after 20 seconds at 900 MiB. These are policy outputs. No title run or VRAM-usage claim. The focused resource suite passed 46 tests on an RTX 4060 and under WARP. [Companion commit](https://github.com/tyr0nsur/VIctory-NVIDIA/commit/60108e2b3087db0f0fd538913617c738074e5989)
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3944:upstream-pr/3944'
git switch 'upstream-pr/3944'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3944'
git switch 'upstream-pr/3944'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3944'
git switch 'upstream-pr/3944'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3944'
git switch 'main'
git merge --squash 'upstream-pr/3944'
git switch 'main'
git merge --ff-only 'upstream-pr/3944'
git switch 'main'
git merge 'upstream-pr/3944'
git push origin 'main'
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
trustno1-coder/VIctory-NVIDIA!3944
No description provided.