Lists' upload buffers are kept and used again, not made for each copy #923
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/923"
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-28T09:09:11Z.
Why
The upload buffer of a list's copy (
HostList::upload: the texels a title copy takes from a buffer, and the zeros of a texture's new levels) was memory of its own, made on the thread translating the list for every such copy and let go when the list was reset. Making one is aCreateCommittedResourcewithCREATE_NOT_RESIDENTand aMakeResident. WithVICTORY_CARD_STEPS=2(memory the card may write, so a shared buffer) it is also waited for until mapped, a copy queue's round trip.In a play log on an RTX 5070 Ti (16 GB) with
VICTORY_CARD_STEPS=2, new memory was waited for 28,000 times for 22.7 s (the longest 1.8 s, with the card's memory near its budget), and until mapped 25,000 times for 19.4 s. Those lines do not say which memory was waited for, and #630 adds the line that will. These buffers are among the few made that often. The scratch chunks next to them were pooled for the same reason (VICTORY_SCRATCH_POOL); these never were (the code said "shortcut: one buffer per copy; pool them once uploads are frequent").What
HostList::reset), the same rule the scratch chunks rest on. Every caller writes the bytes it uses before the copy.VICTORY_KEEP_FREED, unless the PC's memory is limited), apart for upload memory and shared memory. They are all let go when the PC's memory is pressured.VICTORY_UPLOAD_POOL=0: one made for each copy, as before.Before / after
cargo test --release -p victory-gpu --lib -- bench_list_upload_buffers --ignored --nocapture, RTX 5070 Ti, the time the recording thread spends getting the buffer:200 buffers each. "Kept" takes a buffer from the pool and gives it back, so only its first take makes one; that first one is all of its mean.
CARD_STEPS=2)With
VICTORY_BENCH_BUSY=1(a thread beside it making 64 MiB upload buffers all the time, so the system pages as it does while a scene loads), making one took 24–43 ms on average (99th percentile 39–95 ms), and a kept one 0 µs at the median. That thread makes far more memory than a title does, so take those numbers as an upper bound.The machine was running another branch's test suite at the same time; both columns ran in the same process, one after the other, so they saw the same load.
Correctness
the_next_list_gets_the_upload_buffers_a_list_gave_back(needs a GPU): a buffer a dropped list gave back goes to the next list asking for that size class, mapped and writable, and a second request from the list holding it gets another buffer.kept_upload_buffers_come_in_powers_of_two: the size classes.cargo test -p victory-gpu --lib --locked: 455 passed, 0 failed.cargo clippy --workspace --all-targets --locked -- -D warningsstops at two findings that fail onmainalready (shadow.rs:1708,victory-shader/src/emit/mod.rs:2768; #630 fixes them) and reports nothing inhost.rs.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Dukestar69 on 2026-11-28T09:19:58Z.
Review: APPROVED
Tested locally merged onto
main(63b902f).cargo xtask policypassed (294 files ok).cargo test -p victory-gpu --lib uploadpassed (10 passed; 0 failed; 1 ignored, including the newhost::upload_pool_tests::kept_upload_buffers_come_in_powers_of_twoandthe_next_list_gets_the_upload_buffers_a_list_gave_back).cargo test -p victory-gpu --lib list::passed (7 passed; 0 failed).cargo test -p victory-gpu --lib host::card_steps::passed (9 passed; 0 failed; 1 ignored).Clean power-of-two upload-buffer pooling and reuse across command lists. LGTM.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-11-28T19:28:34Z.
Thanks for this. I'm closing it because main already pools list upload buffers by size class (
take_upload/give_uploadsin host.rs, withVICTORY_UPLOAD_POOL_MB), and the two conflict. If yours does something main's pool doesn't, please rebase it on the current main and open a new pull request with a comparison.Pull request closed