GPU: grow the write snapshot in place, and cap idle pool memory #472
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/472"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by SaymonMaster14 on 2026-11-24T03:49:16Z.
Four leaks in the copy bridge, found while measuring #471. Each one is small on
its own; together they cost the peak exactly where commit is tight.
shadow.rs,Shadow::writing: the snapshot grown to span a submission'sdeclared ranges allocated a second buffer of the new size, copied the old
into it and only then returned the old to the pool. At the largest growth that
holds both, and the world's heap is 174 MB — the peak doubles there. It is now
grown in place:
reserve_exactfor exactly the growth (the amortized doublingof a buffer this size would double the capacity, and a copying realloc its
peak), then extend on either side.
shadow.rs,give_back: the pool kept its eight largest buffers whatevertheir size, so one world load left eight 174 MB snapshots — about 1.4 GB idle,
never shrunk. The largest is now always kept (its reuse is what saves the
millions of page faults the 64 KiB pages were chosen for) and further buffers
only while they add up to 256 MiB, still at most eight.
texture.rs: everyStagingkept aVecof the whole texture for good, so theresident cost was the sum of every texture that had been refreshed. One shared
SCRATCH, kept and already touched, makes it the largest texture instead. Thehash path does not use the buffer (it hashes the mapping directly), and the
staging mapping is written only at submission, so the lock costs nothing there.
dstorage.rs,staging_bytes: a zlib-then-BCPack request inflates into anintermediate buffer that counted against no limit. It now counts against the
32 MiB staging cap, so the cap bounds what is really held. Requests of that
shape serialize more when one is large; no throughput was measured either way.
What is in it: those four, and nothing else. No interface change.
Tested:
cargo build --release -p victory,cargo test -p victory-gpu -p victory-hle— 130 passed, 1 ignored, 0 failed. Live, release, world load, 16 GBmachine: the process reached 18.0 GB private and died at
memory allocation of 70426816 bytes failed, system commit 48.8 GB of 49.0 GB. It still dies — thesereduce the slope, they do not remove the ceiling.
Not tested: the headroom case. The earlier runs measured the page file, not
PrivateMemorySize64, and there are no per-component counters, so "the peakwent down" cannot be claimed from the two side by side; #471 has the samples
and the counters that would settle it. Also unmeasured: whether the 256 MiB cap
is the right number (it keeps ~1.5 world heap snapshots; 192 MiB or 384 MiB are
as arguable), and the DStorage serialization cost.
Not a #407 fix. This is bridge work, which #407 proposes to delete. It holds
until stage 2 there — xmem asking a GPU-visible arena first — replaces the
copies. Worth merging only as the stopgap it is.
Fixes #471.
AI use: Claude (Sonnet 5.5) in a Maestri terminal drove the code reading, the
edits, the build and the test run; the memory sampling and the reproduction
were set up outside it.
Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T05:47:20Z.
Review: APPROVED
Tested
f200a2aon Windows 11, RTX 5070, MSVC:cargo test --workspace --no-fail-fastpasses (264 passed, 0 failed). I could not measure the memory peaks without a game package.Shadow::writing: the in-place growth is correct.reserve_exactreserves exactly the new span.splice(0..0, host(start, at).iter().copied())uses an exact-size iterator, so the tail moves once. The upper extend starts atold_end. One note on the comment:reserve_exactcan still be a copying realloc when the heap cannot grow the block in place, and for blocks this size that is likely. The peak can still be old + new for that one step. It no longer goes through the pool, though, which is a clear improvement over before.give_back(nit):keptadds every buffer after the largest, including onesretainrejects. Once one oversized buffer is rejected, smaller ones that would fit inPOOL_BYTESare rejected too. Adding only kept buffers (if n <= 8 && kept + cap <= POOL_BYTES { kept += cap; true } else { false }) would match the doc comment.texture.rs: the sharedSCRATCHserialises the detile path of watched textures. Refreshes run in the submission's prepare loop on one thread, so I see no contention today.dstorage.rs: countingintermediate_sizefor zlib+BCPack matches the extra bufferexecuteallocates.AI-assisted (Claude Code).
upstream-sync referenced this pull request2026-11-24 06:53:55 +00:00
Imported from Marvisak/VIctory. Originally posted by DaviTostes on 2026-11-24T03:51:10Z.
Verified
f200a2aon Arch Linux x86_64, Windows MSVC release build under Wine 11.22 (victory-gpu,--test-threads=1): 43 passed, 0 failed, 1 ignored (same count asmain, no new test in this head).Not covered: the snapshot growth and idle-pool cap under a real world frame (no game data here).
Imported from Marvisak/VIctory. Originally posted by erickbobd on 2026-11-24T13:08:10Z.
Companion test-only PR against your
memory/peak-during-world-loadbranch: SaymonMaster14/VIctory#1, based exactly onf200a2a.Two synthetic tests cover snapshot byte preservation/allocation reuse with spare capacity and intermediate DStorage staging for file and memory inputs. On the pure parent plus these tests: 46 victory-gpu passed / 1 ignored; 87 victory-hle passed, serial. Replacing each function with its real pre-#472 version makes its test fail; restoring both passes the full suites again. Asset policy: 151 files OK.
Tested on RTX 5070 Ti / NVIDIA 617.14, Windows 11 26200.9974, Rust 1.98.1 / MSVC x64. This verifies the regression fixtures, not live-game memory savings. AI-assisted (Codex); synthetic inputs only.
Imported from Marvisak/VIctory. Originally posted by BaggyALPHA on 2026-11-24T15:42:28Z.
I tried a Series S WARP comparison with
f200a2aapplied on top of the PresentX fix from #211 and the diagnostics from #484 and #602. For the patched build I adjusted the local #602 probe to read the new shared texture scratch buffer. Both runs used copies of the same profile, separate caches, and the same commit guard.The fresh control stopped at its time limit before opening the story archive. The patched run opened it, then reached the commit guard before a confirmed world frame. An earlier run of the same control binary and profile did open the story archive. Against that earlier control, private commit differed by less than 1% at archive open and at the 10- and 20-second marks after it. The sampled idle snapshot capacity stayed zero, and the cached upload peak was the same in those two runs.
This is a comparison of early loading only. It does not establish whether the patch lowers peak commit during world rendering or whether the snapshot-pool cap was exercised. Neither run logged an out-of-memory error or device removal before stopping.
AI-assisted testing and write-up (OpenAI Codex).
Imported from Marvisak/VIctory. Originally posted by AgneyaK on 2026-11-24T16:37:03Z.
Test report on an RTX 3050 6 GB Laptop (i7-13700H, 16 GB RAM, Windows 11 26300), diag build, title 1.0.2.1, Series X profile. Base tree:
mainffe310e+ #208 + #223 #233 #320 #439 + #452 + #579 (VICTORY_SKIP_WAVE64=mesh), from #1232. #472, #322 and #1024 merge cleanly onto it.So about 12% shorter frames, mostly copies (−36%) and copy-back (−18%). One run each, and the three were
not separated.
On this 16 GB machine much of the rest looks like paging: private bytes reach 22.9 GB and the working set is trimmed to 2-5 GB (numbers in #1232).
AI use: Claude Code (Claude Opus 5.5) merged and built the trees, ran the title on my machine and drafted this note; results are from the runs described.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:20:03Z.
Automated triage for the maintainers.
Needs rebase. This PR does not merge cleanly into current
main(ac2525d). Conflicting files:crates/victory-gpu/src/shadow.rs,crates/victory-gpu/src/texture.rs.The content has not been reviewed yet; it will be once the branch is rebased onto
main.Generated by Claude Code
upstream-sync referenced this pull request2026-11-25 02:05:58 +00:00
Imported from Marvisak/VIctory. Originally posted by desplmfao on 2026-11-25T06:21:28Z.
Your commit here now conflicts with
main, so I opened #2153 with it brought up to date. Your commit is kept with you as author, and only the conflicts are resolved. The details are in #2153:mainhas since split the snapshot into segments, so the in-place growth part no longer applies, but the pool cap and the sharedSCRATCHcarry over unchanged.Measured in Grand Theft Auto VI's world (RTX 5080, Linux): the snapshot pool held 2,040 MB on
mainand 111–214 MB with your change, with no change in frame time. If you rebase this PR yourself, I'll close #2153.upstream-sync referenced this pull request2026-11-25 12:03:45 +00:00
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.