GPU: loose copies of title memory get LRU bounds and refusal #3928

Open
kotekompotek wants to merge 1 commit from upstream-pr/3928 into main
kotekompotek commented 2026-12-01 04:26:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-12-01T04:26:57Z.


Summary

  • Copies of title memory made outside buffer objects (the loose() windows used e.g. for GTA VI's allocator-owned interface vertices) were never freed: each unique aligned window pinned a permanent shared_buffer in GPU-visible system memory.
  • Measured on a 2 GB card entering story streaming: 542 loose allocations of 4 MB in under a second (~2.2 GB commit) → CreateCommittedResource/MakeResident failed 0x8007000E, the device suspended 0x887A0007 and was removed.
  • Each copy now records the presented frame it was last asked for. Past the soft bound (256 MB) loose() and the per-frame evict_loose() (run in Host::execute, on the same boundary as resource::evict_unused) retire idle copies least-recently-used first. Past the hard bound (512 MB) loose() refuses the copy instead of racing the driver to OOM — copies are regenerable from title memory and live lists/heap slots hold their own references, so correctness is preserved while the allocation storm can no longer take the device down.
  • With this applied, the run survives the exact burst that previously removed the device (story package opens, 9+ minutes streaming, zero no shared buffer errors, memory stable).

Test plan

  • cargo check -p victory-gpu --features diagnostics clean
  • cargo test -p victory-gpu --features diagnostics shadow — 11/11 pass
  • In-game: prior build crashed at the streaming burst; patched build continues past it

Generated with Devin

<!-- greyfinch-sync:Marvisak/VIctory:issue:5579008251 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3928). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-12-01T04:26:57Z. --- ## Summary - Copies of title memory made outside buffer objects (the `loose()` windows used e.g. for GTA VI's allocator-owned interface vertices) were **never freed**: each unique aligned window pinned a permanent `shared_buffer` in GPU-visible system memory. - Measured on a 2 GB card entering story streaming: **542 loose allocations of 4 MB in under a second (~2.2 GB commit)** → `CreateCommittedResource`/`MakeResident` failed `0x8007000E`, the device suspended `0x887A0007` and was removed. - Each copy now records the presented frame it was last asked for. Past the soft bound (256 MB) `loose()` and the per-frame `evict_loose()` (run in `Host::execute`, on the same boundary as `resource::evict_unused`) retire idle copies least-recently-used first. Past the hard bound (512 MB) `loose()` **refuses the copy** instead of racing the driver to OOM — copies are regenerable from title memory and live lists/heap slots hold their own references, so correctness is preserved while the allocation storm can no longer take the device down. - With this applied, the run survives the exact burst that previously removed the device (story package opens, 9+ minutes streaming, zero `no shared buffer` errors, memory stable). #### Test plan - [x] `cargo check -p victory-gpu --features diagnostics` clean - [x] `cargo test -p victory-gpu --features diagnostics shadow` — 11/11 pass - [x] In-game: prior build crashed at the streaming burst; patched build continues past it Generated with [Devin](https://devin.ai)
passerbyyhx commented 2026-12-01 12:30:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by passerbyyhx on 2026-12-01T12:30:28Z.


On ab99a148 I lowered the cache limits in a test build and kept a cold loose window alive through a recorded GPU list. At frame 300 the cache dropped that window and retained the other two. The recorded copy still read 0x11223344. After changing title memory, a fresh copy read 0x99aabbcc. Four recent windows fit and a fifth was refused.

There was one distinct failure on this head. An oversized request first trimmed four cold windows down to one, then returned None. The cache membership changed but its generation stayed at 6. The assertion that removal must advance the generation failed. The stacked commit caeb48f in #3930 already calls changed() when this allocation-time trim removes entries. The failing observation here is the generation value. The GPU readback checks above passed.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7311230235 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3928#issuecomment-7311230235). Originally posted by [passerbyyhx](https://github.com/passerbyyhx) on 2026-12-01T12:30:28Z. --- On `ab99a148` I lowered the cache limits in a test build and kept a cold loose window alive through a recorded GPU list. At frame 300 the cache dropped that window and retained the other two. The recorded copy still read `0x11223344`. After changing title memory, a fresh copy read `0x99aabbcc`. Four recent windows fit and a fifth was refused. There was one distinct failure on this head. An oversized request first trimmed four cold windows down to one, then returned `None`. The cache membership changed but its generation stayed at 6. The assertion that removal must advance the generation failed. The stacked commit `caeb48f` in #3930 already calls `changed()` when this allocation-time trim removes entries. The failing observation here is the generation value. The GPU readback checks above passed.
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/3928:upstream-pr/3928'
git switch 'upstream-pr/3928'

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/3928'
git switch 'upstream-pr/3928'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3928'
git switch 'upstream-pr/3928'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3928'
git switch 'main'
git merge --squash 'upstream-pr/3928'
git switch 'main'
git merge --ff-only 'upstream-pr/3928'
git switch 'main'
git merge 'upstream-pr/3928'
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
Marvisak/VIctory!3928
No description provided.