Repository navigation
GPU: an upload buffer refused for want of memory is asked again once the spare scratch chunks are freed (#944) - #953
Conversation
…1-coder#923 trustno1-coder#890 trustno1-coder#1008 trustno1-coder#1005 trustno1-coder#801, and trustno1-coder#953 by hand Merged from trustno1-coder/VIctory-NVIDIA, all aimed at the 8 GB card / 32 GB RAM class of machine this fork targets: trustno1-coder#784 empty texture blocks kept in proportion to the card's budget (VICTORY_SPARE_SCALE=1) trustno1-coder#986 texture staging retried in smaller blocks after out-of-memory trustno1-coder#923 lists' upload buffers kept and used again, not made for each copy trustno1-coder#890 VICTORY_CARD_BUFFERS_MIN_KB, an 8 GB card's floor trustno1-coder#1008 fault-page bound raised to 16,384, <4 GiB strays skipped trustno1-coder#1005 >65,535-group indirect dispatches enabled on NVIDIA trustno1-coder#801 stall-free per-draw zero-alloc and COM fast paths trustno1-coder#953 (an upload buffer refused for want of memory is asked again once the spare scratch chunks are freed) conflicted with the tree's own try_upload_buffer split; ported by hand with the same semantics and the same log line. Not taken: trustno1-coder#991, trustno1-coder#1014, trustno1-coder#722 - they conflict in pool.rs / draw.rs / memory.rs, which trustno1-coder#784, trustno1-coder#801 and trustno1-coder#1008 already changed here.
… once Same treatment trustno1-coder#953 gave upload buffers, extended to the two other buffers the host makes while a world loads: the spare scratch chunks no list holds are freed first, then the buffer is asked for once more. On a 32 GB host whose pagefile is system-managed, the whole box can be out of commit for a moment at world load (0x8007000E on a 4 MiB shared buffer, with 0.6 GB of commit left), and the refusal poisons a command list that then fails to close.
|
Tested on a machine close to #944's: RTX 5060 Ti 8 GB (DXGI local budget ~7.0 GB), 16 GB RAM, Windows 11 26300. Base Runs with this PR (4 starts, same switches, same save)
So 1 of 4 still died, about the same rate as without the PR (#944 had 1 of 3). What the failing run shows
Take-awayThe change looks correct and harmless: no regressions in the 3 good runs, and the retry rule only acts on Logs are available if useful (they contain only the emulator's own lines). |
|
Thank you, that is the test this needed, and it answers it. The retry fires, but by then there is nothing spare to free (0 to 3 MB), and the refusals start with an ordinary 2.2 MB upload buffer and an 8 MB shared buffer while the card's own memory is over its line. So on an 8 GB / 16 GB PC the spare chunks are not the reservoir that runs dry, and this change does not prevent that crash. I put your runs and that conclusion in the description, so nobody takes it for the fix of #944. I'll keep it open as a small, harmless hardening for a spike while chunks are spare, unless the maintainer prefers to drop it. I'll look at what moves into that budget while the card is full, and wait for your #991 numbers before touching the same paths. |
…the spares are freed (trustno1-coder#944) Rebuilt on main, which now pools copy sources (UPLOAD_SPARE) and keeps some spares under pressure while plenty of the PC's memory is free. The sweep's rules are unchanged. When CreateCommittedResource refuses an upload buffer with E_OUTOFMEMORY, free_all_spares now frees every spare no list holds: the scratch chunks and the pooled copy sources, whatever keeps_under_pressure would keep. The buffer is then asked for once more. They are upload and shared buffers in the same budget, which can run out while the PC still has memory free. With 15.7 GB of RAM, 368 buffers of 256 KiB were refused in 4 s at world load and the run ended there (trustno1-coder#944). Any other refusal fails as before. A buffer made on the second try is logged the first time and at each power of two. Test: an_out_of_memory_refusal_is_tried_again_once_memory_is_given_back.
f87534e to
d8ae70b
Compare
Rebuilt on main
32ecacf(force-pushed). Main now pools copy sources (UPLOAD_SPARE, up to 1 GiB of each kind, from 924911f), and its sweep keeps some spares under pressure while plenty of the PC's memory is free. This change leaves that sweep alone. On anE_OUTOFMEMORYrefusal it now frees every spare no list holds, the scratch chunks and the pooled copy sources, throughfree_all_spares, then asks once more. With the pool, a refusal now has much more to free than in Exopus-0x65f7ad0's run below, where the scratch chunks were already gone.cargo test -p victory-gpu --lib --lockedon the rebuilt branch: 478 passed, 37 ignored. Clippy is clean in both builds, with main's ownmanual_is_multiple_ofallowed.What happens
An upload buffer comes out of the PC's memory the card may use: D3D12's non-local budget, about half the RAM. That budget can run out while the PC itself still has memory free.
#944 shows it: an RTX 4060 Laptop with 15.7 GB of RAM, and three runs with the same switches.
0x8007000E. That size isSCRATCH_FIRST, a list's first scratch chunk. Thena host state prelude did not record (0x8007000E), and the run ended there.Meanwhile the spare scratch chunks, the ones no list holds, are upload buffers in that same budget: up to 128 MiB of them on a PC with 32 GB or less (
SPARE_MOST). Only the once-a-second sweep frees them, and only whileresidency::pressured()holds. That is decided by the PC's free physical memory and commit, not by this budget. So they stayed kept while new ones were refused. The 368 refused buffers came to about 92 MiB.The change
crates/victory-gpu/src/host.rs:Host::upload_bufferasks once more when a buffer is refused withE_OUTOFMEMORY, aftertrim_spare_chunksfreed the spare chunks.trim_spare_chunksnow returns the bytes it freed. It frees them as the sweep does: no list holds them, and their submissions have run.make_or_free_and_retry, which can be tested without running out of memory:no upload buffer,residency::allocation_error).This keeps a run going through a spike while chunks are spare. It does not make room the title or the texture queue have already taken. #944's failing run also had its texture queue fall far behind first.
Tests
host::spare::an_out_of_memory_refusal_is_tried_again_once_memory_is_given_back:cargo test -p victory-gpu --lib --locked: 454 passed, 36 ignored.-D warnings, default and--all-features): nothing in the changed lines. It stops onmain's ownmanual_is_multiple_of(fixed in CI: the rest of main's clippy findings, so that with #1517 and #1459 both builds are clean #665). With that lint allowed, both builds are clean.trim_spare_chunkstakes the spare pool's lock, and no caller ofupload_bufferholds it.take_chunklets it go before it makes a new chunk.Not run with the game. On a PC like #944's, a log with this change would show
was made once the spare scratch chunks were freedwhereno upload bufferwas before. Read-back and shared buffers fail the same way under that budget (#804 counts both), and could take the same step if a log shows them refused while chunks are spare.Seen by others (#944)
host memory pressure. There was not one0x8007000Eorno upload buffer. That fits a budget of the PC's memory running out on 15.7 GB, rather than the card's own.Tested by Exopus-0x65f7ad0 (RTX 5060 Ti 8 GB, 16 GB, Windows 11 26300)
Four starts with this change and the switches that had failed there that morning, on the same save. Three ran through with no refusal at all. One still died, about the rate seen without it (#944: 1 in 3).
7032 MB against a line of 6325 MB).a host command list did not close (0x8007000E).So on that machine the spare chunks are not what runs dry. The whole budget outside the card's memory was used up while the card's own memory was full. This change is harmless there (it only acts on
E_OUTOFMEMORY), but it does not prevent that failure. What fills the budget during world load is the lead: texture staging, and copies moved out of the card's memory. #986 and #991 work on that side.No game files, dumps or extracted data are included.