Repository navigation
Conversation
The snapshot `Shadow::writing` keeps, to tell later what a submission's shaders wrote, is grown to span every range the submission declares. Growing it allocated a second buffer of the new size, copied the old one in, and only then returned it to the pool: at the largest growth that holds twice the buffer, and the world's heap is 174 MB, so the peak doubles right where commit is already tight. Grow the old buffer in place instead (`reserve_exact` for exactly the growth, then extend on either side). The pool that feeds the snapshot kept its eight largest buffers whatever their size, so after the world had grown once it could hold eight 174 MB buffers, about 1.4 GB idle. Keep the largest (its reuse is what saves the millions of page faults the 64 KiB pages were chosen for) and further buffers only up to 256 MiB. Measured on a 16 GB machine, world load, release build: the process reached 18.0 GB private and died at `memory allocation of 70426816 bytes failed` with the system commit at 48.8 GB of a 49.0 GB limit. It is not a fix for that limit, and not comparable to earlier runs (those measured the page file, not `PrivateMemorySize64`) — the counters to compare it against do not exist yet. Refs Marvisak#407: this is bridge work, which that issue proposes to delete. It stays valid until stage 2 there (xmem asks a GPU-visible arena first) replaces the copies.
catminou4
left a comment
There was a problem hiding this comment.
Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.
Idle snapshot pool memory capped (#472 rebased, 2 GB RAM) — memory-cap fix for long sessions; mixed gpu+hle, Windows-only.
|
Independent Windows x64 CPU-only probe on parent
|
Adapt the snapshot-pool part of Marvisak#2153 (also Marvisak#472). Do not import the unrelated texture or storage changes. Cap total idle capacity including the largest buffer, preserve the best-fitting allocation path, and limit idle entries to eight. Active snapshot correctness is unchanged. Portable pool regression and Windows all-feature workspace test source checks passed. Co-authored-by: Davi Andrei <67552001+SaymonMaster14@users.noreply.github.com>
… fails A pool miss allocated with Vec::with_capacity, which aborts the process when the allocation fails, even while the pool still holds idle buffers (too small to fit, but up to POOL_BYTES plus the largest one). Try the allocation with try_reserve_exact first; when it fails and the pool is not empty, drop the idle buffers and make one last attempt with reserve_exact, which aborts as before if that fails too. Pool hits and successful misses are unchanged. Idea from fxceless/victory-fork#360. Co-Authored-By: avt0m4t48 <56218626+avt0m4t48@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Added |
|
@yualk thanks for the independent probe. That matches the intent: the largest idle buffer is always kept, and others only up to 256 MiB more, so |
|
Automated triage for the maintainers. Verdict: merge candidate. Thanks for splitting it as suggested. The diff is now only Checked: when the first attempt succeeds the second CI: passing ( Generated by Claude Code |
The pool cap doesn't need it, and counting a zlib-then-BCPack request's intermediate buffer against the staging budget changes when the title's reads start, without evidence that the console counts it. As asked in the triage, it goes from this PR. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the triage. Done in |
… the pool at 512 MB The texture part of this PR (one shared read buffer) is superseded by main's 8f2a6f1 and is dropped here; what stays is the snapshot pool: grow a snapshot in place, free the idle pool and retry when an allocation fails, and keep the largest buffer plus at most 256 MB / 8 others instead of 512 MB in all. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merged
The 2 GB in the title was measured against |
|
The |
The previous main (old upstream base) is the first parent; the second is upstream main with the current heads of our pull requests merged in: Marvisak#2143, Marvisak#1849 (carried onto main's per-region runtime_pages), Marvisak#259, Marvisak#491, Marvisak#2153, Marvisak#2099, Marvisak#2071 (main covers it), Marvisak#2162, Marvisak#2218, Marvisak#2088, Marvisak#2389, Marvisak#177's element-type key on main's three handle maps, and the README. Marvisak#2112 (opt-in, in place) stays in the renderer branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rebased; 2 GB RAM in the world)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main now caps the idle pool at 512 MiB in all. This PR's rule (the largest buffer, plus others up to 256 MiB and at most 8) could hold more than that, so it goes. What stays: a snapshot that fails to allocate frees the idle pool and tries once more instead of aborting. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Split as suggested, in |
…'s pool cap Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…'s pool cap Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3bb37bc to
c21a054
Compare
… idle pool and tries once more
…te frees the idle pool and tries once more
…te frees the idle pool and tries once more
fuzeofficlal
left a comment
There was a problem hiding this comment.
Reviewed crates/victory-gpu/src/shadow.rs at c21a0542 (already based on origin/main 63bcca43) and verified on RTX 5090 and WARP (VICTORY_D3D12_WARP=1) with VICTORY_D3D12_DEBUG=1.
Allocation retry & state-safety audit
- In
pooled(n)(crates/victory-gpu/src/shadow.rs:102-128), when no idle buffer fits,v.try_reserve_exact(n)(shadow.rs:117) runs first:- When it succeeds, smaller idle buffers stay in
POOLand the trailingv.reserve_exact(n)(shadow.rs:124) is a no-op (no second allocation). - When it fails and
!pool.is_empty(), it logs a warning, releases the idle pool (pool.clear()atshadow.rs:122, freeing up toPOOL_BYTES= 512 MiB), and attemptsv.reserve_exact(n)once more — no retry loop, and if commit is still exhausted it aborts cleanly beforeShadow::writingmutatesself.beforesegments. - Holding
POOLacross the clear-and-retry prevents another thread from refilling the pool or racing the retry;POOLis a leaf lock never nested with other locks.
- When it succeeds, smaller idle buffers stay in
Verification
cargo run -p xtask -- policy: 191 files ok.cargo clippy -p victory-gpu --all-targets -- -D warnings(default and--all-features): clean.shadow::withVICTORY_D3D12_DEBUG=1: 10/10 passed on RTX 5090 and 10/10 passed on WARP (--features diagnostics).- Additional synthetic probe exercising
pooled(0), pool miss (verifying smaller pooled buffers remain intact whentry_reserve_exactsucceeds), and pool hit reuse (len() == 0, capacity preserved) passed cleanly.
Dukestar69
left a comment
There was a problem hiding this comment.
LGTM — verified on RTX 5090 (Windows / D3D12) against origin/main (63bcca4).
- Releasing the idle snapshot pool and retrying once when a snapshot allocation fails cleanly recovers from transient memory pressure.
cargo test -p victory-gpu --lib shadow:: -- --test-threads=1: all passed.cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
|
I resolved the The original #3384 test shared the process-wide pool. One controlled peer take between the two length checks made it see 1,998 entries when it expected 1,999. The replacement uses its own pool and keeps the best-fit, sorted order, return and successful miss checks. All 11 shadow tests, strict Clippy in both configurations and asset policy passed. Using a test-only allocator in a separate process, I rejected the first synthetic reservation. The combined code made two attempts, freed both idle buffers and returned the requested empty buffer. With a successful first reservation, there was one attempt and both idle buffers stayed. @desplmfao, the combined branch is available to check against the allocation retry before the two PRs land. If you reapply the resolution or its pool regression, please retain the Git author or add |
When a write snapshot needs a buffer and none in the idle pool fits,
pooledcallsVec::with_capacity. If that allocation fails, the process aborts, even though the idle pool may hold hundreds of MB that nothing is using.Change
crates/victory-gpu/src/shadow.rs,pooled(15 lines):try_reserve_exactfirst.snapshot allocation failed; freeing the idle pool, and reserves once more withreserve_exact. That still aborts if memory is really gone.give_backandPOOL_BYTESaremain's, unchanged.History
This PR started as #472 (by @SaymonMaster14) brought up to date with
main: an idle pool cap, a shared texture read buffer, and adstoragebuffer change.mainhas since done these its own way: a 512 MiB pool cap, and8f2a6f14for per-thread read buffers. As triage suggested, the PR is reduced to the one partmaindoesn't cover, the allocation retry. #472's commit is still in the branch history, but none of its changes are in the diff.How it was found
Reading
pooledwhile bringing #472 up to date withmain. I haven't seen this abort in a title run; it matters on hosts where commit is tight, such as 16 GiB machines under Wine.Tested
cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.shadow::tests on an RTX 5080 under Proton: 10 passed.AI-assisted (Claude Code).
🤖 Generated with Claude Code