Memory waits: told apart by kind and thread, mapping copies waited for together, upload buffers not waited for #630
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/630"
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 trustno1-coder/VIctory-NVIDIA. Originally posted by 0xkn0wh3r3 on 2026-11-28T02:05:19Z.
Why
A 9-minute play log (16 GB RTX card) had 52,000
MakeResidentwaits for 27.3 s, the longest 1,128 ms while a scene loaded with the card at 10 GB, and 48,000 mapping copies waited for, 7.2 s. Each was one number for every thread. That included the thread that makes buffers ahead (crate::ahead, 8,000 buffers in the first 6 s), whose waits no frame stands for, so the log could not tell stalls from background work.mapped()also held one lock for its whole GPU round trip, so a frame's thread that made a texture or a card buffer waited behind that low-priority thread.What
mapped()holds its lock only while it sends its copy. The copy comes from a ring of 8 lists, each sent again only once the card is done with it, and each thread then waits for its own copy.VICTORY_MAPPED_TOGETHER=0: one at a time, as before.Clippy: the four findings that stop CI on main: CI onmain(8fc2254) fails at clippy (Rust 1.98:let_and_return, twomanual_is_multiple_of,some_filter). Fixed with no change in behaviour, so this PR and the ones stacked on it can go green. Drop it ifmainfixes them first.mainis merged in (no conflicts), so the branch is up to date without a force-push.Before / after
cargo test --release -p victory-gpu --lib -- bench_ --ignored --nocapture, RTX card, three runs each.VICTORY_BENCH_AHEAD_KB=65536adds a thread like the one that makes buffers ahead (its name, its low priority), making 64 MiB buffers all the time, so the system pages as it does while a scene loads.VICTORY_MAPPED_TOGETHER=0)On an idle card there is no difference (both about 0.30 ms).
Correctness
buffers_made_at_once_are_mapped_and_hold_what_is_copied_in: twelve threads make card and upload buffers at once (more than the ring has lists). Every buffer holds what the card copied into it. It passes with the switch either way, and withVICTORY_D3D12_DEBUG=1in a diagnostics build it asserts the debug layer reported nothing (so a list sent again while the card still read it would fail it).waits_are_counted_by_kind_and_thread: a wait is counted once, under its kind and its thread, and taken by the 5-second line.cargo clippy --workspace --all-targets --locked -- -D warnings, the same with--all-features, andcargo test --workspace --lockedall pass.watch::tests::what_the_kernel_writes_through_is_not_guarded_for_another_viewandwhat_is_put_in_beside_the_guards_is_told_at_every_viewfail now and then; they did in 1 of 10 runs on unchangedmaintoo.Stacked on this PR: #682, #683, and on that one #684, then #685.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by CuteBooty on 2026-11-28T04:42:06Z.
In-game numbers for this PR from an 8 GB card that runs near its budget, since the description says it had not been measured in play yet.
victory.exe run, diag profile with diagnostics.63b902fe1+ this PR's four non-merge commits cherry-picked (50131e5,0cbfe4d,1dbd6eb,c3a2310) + #697 + a few unrelated local commits.VICTORY_MAPPED_TOGETHERat its default (on),VICTORY_BUFFERS_AHEAD=0(I keep the buffers made ahead off to save card memory),VICTORY_WAIT_RESIDENTunset,VICTORY_TEXTURE_POOL=1,VICTORY_TEXTURE_ROOM_PERCENT=85,VICTORY_SLOT_EVICT=1,VICTORY_CARD_ROOM_FOR_TARGETS_MB=2048,VICTORY_SOFT_VIEWS=copies.The new line, summed over the session (188 lines = 15.7 minutes): 73.7 s waited for new memory by the title's threads and ours, 0 by the ahead thread (it is off).
Two lines as logged, the busiest (cut after the third kind) and a typical one in play:
Not done: a session with
VICTORY_MAPPED_TOGETHER=0to compare against, and one with the buffers made ahead on (#682). Say which of the two is more useful and I will run it.Measurements and this report were prepared with an AI assistant (Claude Code); the run was played on my machine.
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.