World load: send memory and preludes made ahead of the world's first frame, and a line saying what that frame made (VICTORY_SEND_AHEAD_MB, VICTORY_PRELUDES_AHEAD; off) #4335
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!4335
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-4334"
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?
@kMagic142 on GitHub · 2026-11-30 18:59 UTC · original
kMagic142:pr-world-load→main· +1400 −841 · 34 files · 11 commits · closed without mergingWhat it changes
When the playable world first appears, one frame takes 750 to 1,900 ms. Before it, the loading screen runs for about a minute with 4 to 50 draws a frame, and the threads are mostly idle. That frame makes two kinds of objects where it needs them, on the threads it waits for:
host/send.rs,VICTORY_SEND_OWN). A submission whose bytes no spare holds gets a new upload buffer, made, made resident and mapped on the thread that takes the bytes. The world's first frame sends far more than any frame before it, so the spares the loading screen left hold none of it. In our runs that frame made 4 to 9 such buffers (1,351 to 1,518 MB) in 127 to 568 ms. The largest was 1 GiB; in one run itsMakeResidentalone took 154 ms.Host::make_prelude: a command allocator and a closed list). A list takes one from the pool at its first submission that needs one, and the loading screen's small lists leave few in the pool. That frame made 63 to 75 of them in 82 to 117 ms.This PR adds a thread,
victory-worldahead, that makes both while the title loads: from the title's first present until the world's first frame. It also adds one log line for that frame. Both switches are off by default.VICTORY_SEND_AHEAD_MB=<n>(unset or0: nothing is made). The thread makes one buffer of n MiB for the frame's largest send. It also makes one buffer of each power of two below n, from 256 MiB down to 8 MiB, for the sends in the air beside it. For 1024 that is 1024, 256, 128, 64, 32, 16 and 8 MiB (1,528 MiB). n is capped at 4095, because one upload buffer of 4 GiB is refused (#3729). Each buffer is made by the same call and at the same size assend::memorywould make it.AHEAD), so neithergive_back's cap nortrim's line (#3994) counts them.send::memorytakes a spare first, as before. Only when no spare holds the send does it take the least buffer made ahead that holds it. A send made at 256 MiB or less never takes one past 256 MiB: that buffer would be let go after this one use and would be missing for the large send it was made for.send::trimlets the buffers go at once.kept(), past it let go, as main lets go of large send memory after one use.VICTORY_SEND_OWN=0, which never takes it, or withVICTORY_SEND_BAR=1, whose memory is the card's.VICTORY_PRELUDES_AHEAD=<n>(unset or0: none; at most the pool's 256). The thread makes preludes until those it made and the pool together hold n, 32 at a time, under the same memory conditions. Each costs the driver about 3 MB.HostList::record_preludetakes from the pool first, as before. If the pool is empty, it takes one made ahead before it makes one.VICTORY_ALLOCATOR_TRIM(on invictory play, a new allocator past 30 s) starts there. Otherwise a prelude made at the start of loading would get a new allocator in the very frame it was made for.give_prelude).Nothing that reaches the card changes. A submission writes the bytes its copies read into its send memory, as into any spare, and a prelude is reset before it records.
The line of the world's first frame (always on, once a run). The meter counts each present's draws (
crate::draw::drawn). The first frame with 2,000 draws or more gets one line at info:the world's first frame (the first of 2000 draws or more): <ms> ms; .... The loading screen draws 4 to 50 a frame and the world about 5,000. The line gives that frame's gains of:MakeResident(times, ms) and waits until new memory is mapped (times, ms), on all threads;wait_sent, withVICTORY_SUBMIT_SPLIT);"The largest" is the value to set
VICTORY_SEND_AHEAD_MBfrom. In our fork the largest single send in that frame was under 1 GiB. #3729 saw one world-load submission send from 1 GB to just past 2 GiB on main's code, on an RTX 5090.The cost when nothing is made ahead, until the world's first frame: at each present, about 18 relaxed loads, one swap and an uncontended lock. After that frame: one relaxed load per present.
make_preludegains a clock read.send::memorygains one only where it makes memory, andwait_senttwo atomic adds only where it waited.Why off by default: this branch has not run in the game. The measurements below come from our fork. With n=1024 the memory made ahead is 1,528 MiB of the PC's memory during loading. A world-load send just past 2 GiB (#3729) would need n of about 2200, 2,704 MiB in all. On PCs that are short of memory, that conflicts with what #1520 and #3994 keep free.
How it was tested
GPU and profile: RTX 5090, Core Ultra 9 285K; Series X profile, DLSS Quality.
Where the numbers come from: all of them come from our fork, which is based on v2026.11.28.03 with many local changes. That tree is not main. This branch itself was not run in the game. The fork's versions of these two parts differ from this PR. The fork makes its send memory by doubles from 8 MiB; main makes it in 64 MiB steps up to 256 MiB and past that at its own size, and this PR follows main. The fork's reserve was 1024, 512, 256, 128, 64, 32, 16, 8 and 8 MiB, kept among the spares for good.
Before (six runs of our fork on 2026-11-30, nothing made ahead): the world's first frame took 1,254.9, 1,099.8, 754.8, 850.3, 754.2 and 716.8 ms. In it:
After (one run of our fork): 461.7 ms. That run had both parts on (send memory with a 1 GiB top, 2,048 MiB in all; 192 preludes), and with them other fork changes that this PR does not carry:
EnqueueMakeResidenton the thread that makes them.In that frame: send memory made 0, preludes made 10 (3.2 ms), new memory made resident 433 times in 204.5 ms (the longest 9.1 ms). Made ahead during loading: 9 buffers (2,147.5 MB) in 110.5 ms, 191 preludes in 79.5 ms.
Which part does the work: a confirmation job repeated these runs on our fork, same build and scene, no warm-up between runs. The world's first frame took:
So the two parts here take that frame from about 950 ms to about 534 ms in our fork. The rest of the gain comes from the copies kept up to date ahead, which this PR does not carry: main lacks the fork's first copies made ahead that they build on. Frame times after the world appears did not change (17.95 to 18.48 ms median across those runs, against 17.95 to 18.17 without).
For shader changes, the wave sizes tested: not a shader change.
cargo testpassed for the crates it touches: yes, on main with this branch applied, for the Windows target.cargo check -p victoryis clean, andcargo test -p victory-gpu --lib aheadpassed 22 tests. Three of them are new:send::tests::a_send_takes_the_least_memory_made_ahead_and_one_of_256_mib_or_less_never_one_past_it: which buffer a send takes, and that a 200 MiB send never takes the 1 GiB;worldahead::tests::send_memory_made_ahead_is_the_largest_then_powers_of_two_from_256_mib_down: the sizes for 1024, 2112, 256, 100, 8 and under 8;worldahead::tests::the_world_frames_gains_are_its_own_and_its_largest_send_is_not_a_gain.Clippy was not run.
Checked for overlap
8b801739(made_for), and this PR builds on it: memory made ahead past 256 MiB is used once and let go like any other. #3729's note that one world-load submission sends up to just past 2 GiB is why the largest size is a switch. #3729 no longer applies to main.send::memory's spare lookup, next to this PR's change there. Neither applies to main as it is now.host.rsandsend.rs. Each applies to main on top of this branch, and this branch on top of each (checked withgit apply).let_go), and send memory made ahead that goes under pressure goes the same way.MakeResidentand mapped waits among its parts. This PR's line comes once a run and names what this PR changes: the send memory and preludes the world's first frame made. #3703 does not apply to main as it is now.9e8bb5b3) and still listed as open. This PR changes only which preluderecord_preludetakes when the pool is empty, not how preludes are recorded.@trustno1-coder on GitHub · 2026-12-01 18:42 UTC · original
Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.
@trustno1-coder on GitHub · 2026-12-01 18:44 UTC · original
Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.
Pull request closed