perf(xmem): physical pages from sections of at most VICTORY_SECTION_MB MiB (off by default) #4988
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!4988
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-4987"
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?
@CLHelper on GitHub · 2026-12-01 16:34 UTC · original
CLHelper:pr/section-mb-3→main· +509 −59 · 3 files · 3 commits · openReplaces #44, rebased on the current main (
5fabb46ea) as asked there.What it changes
XMemAllocatePhysicalPagesmakes one section per request. The title asks for its 6.1 GiB of physical pages in one call and then maps them a 64 KiB view at a time, so one section ends up with views by the hundred thousand. Windows' large-page rebuild worker walks a section's views under that section's lock, and every map and unmap of the title's pages waits behind it. That shows up as stalls when the camera turns or the player moves.VICTORY_SECTION_MB=<n>backs each request with sections of at most n MiB (2 is the measured value). The pages are still numbered as one request. Unset,0or not a number keeps one section per request: same calls, same numbers. Off by default. (Census lines group alike sections either way.)xmem/section_mb.rs(new): the switch;sections(n, per, dir), which makes the request's sections withSection::new(pagefile-backed, or under Wine with page files one sparse file each);enter(), which reports each section to the GPU side (title_memory_section,procmem::section_made) and numbers the pages as one request fromPages::take. Each section keeps its own window and is closed (title_memory_section_gone) when its last page goes, as before.xmem.rs:XMemAllocatePhysicalPagescalls them. Its two failure paths (the host refuses a section; out of page numbers) and its log lines are as on main. A mapping or a write already ends a run at a section's end, and a DirectStorage destination that crosses a bound gets no window and goes throughwrite_physical, run by run.inplace.rs: sections (bytes, importable, generation) and our whole views of them are kept in maps by handle instead of vectors scanned on every lookup (with the switch on, a request is about 3,100 sections). The generation rule for a recycled handle is unchanged, and a new test pins it (below). Census lines group alike sections; a section that is one of a kind prints as before.Not for use together with
VICTORY_PORT_CONSTANTS=1(off unless set on this main): port 1 needs the 32-bit heap's pages in one section. WithVICTORY_SECTION_MBset,arrange()logs its "not of one section as big as it" warning and leaves the pages where they are, so that heap stays on the copy path.How it was tested
6a31e431e). On5fabb46eait is built and unit-tested only, not run in the game.No device removals or exceptions in any of the four runs. One run per arm; pair b ran hands-off, in pair a the player moved in the 2 MiB run only, so pair a's frame times are not a clean A/B (the mapping and lock numbers are the point there).
cargo testpassed for the crates it touches: yes for this change; victory-gpu's lib has two failures that main has too (below). Run oncdc96ead8(5fabb46ea+ these commits), Rust 1.98.1, offline,--test-threads=1, Windows 11:cargo test -p victory-hle --lib section_mb: 5 passed, 1 ignored (the bench), with the switch unset and withVICTORY_SECTION_MB=2. The tests: the switch's values; 33 pages whole vs 32+1 (numbering, window and write over the bound, one call mapping two views); 70 pages in 32/32/6, every section closed after free; five pages in sections of two mapped, written, partly unmapped and page-mapping-copied over the bounds; the title call stays one section by default.cargo test -p victory-gpu --features diagnostics --lib inplace: 16 passed, among them the newan_eligible_handle_given_again_does_not_take_the_earlier_views. The existingnative_import_requires_the_current_eligible_section_generationstill passes with the generation comparison removed from the lookup, because its earlier generation is not eligible; in the new one both generations are, so only the generation can refuse the earlier views.inplace(the new test fails).cargo test -p victory-hle --lib: 474 passed, 14 ignored.cargo test -p victory-gpu --features diagnostics --lib: 1167 passed, 2 failed, 69 ignored. The two arecompose::tests::bgrx_plane_selects_a_typed_view(format 88 where 93 is expected) andhost::bury_tests::bury_drops_retired_objects_asynchronously; main5fabb46eawithout these commits fails the same two the same way (1166 passed, 2 failed, 69 ignored). This change adds one test there, and five plus the ignored bench to victory-hle (main: 469 passed, 13 ignored).cargo check -p victory-hle -p victory-gpu(no features): no warnings.physical_remap_bench(#[ignore = "benchmark"], title-free): remaps single pages of a 4 GiB request while another thread makes and frees 2 GiB, one section vs 2 MiB sections. Test code only.Checked for overlap
SECTION_MB, and main5fabb46ea: no other change splits a request's section. Related, same files, other topics: #4874 (the 32-bit graphics heap as private memory), #4611 (what the title is told about memory), #2776, #3503 (opt-inSEC_COMMITviews), #4205 (procmemsection line), #2455.VICTORY_INPLACE(off by default), a window of title memory in place must be one run of one section; with this switch set, a window over a 2 MiB bound is turned down ("not one section run") and stays a copy. #2776's views of our own (VICTORY_INPLACE_VIEWS) map one view per run of one section, so the same window needs one more view per bound it crosses. Both are opt-in; they were not run together.Credit
This is a port. The finding and the cure are RyanCase94's and CuteBooty's (fxceless's fork, issue #1089, PR #1274). The code follows voidopcode/vilocity 0f44a1706. The tests follow KainanP (Skyfrye/anyXboxx-diffbase ee8b92e14) and Xeltax (Xeltax/VIcky a8c223149).
AI-assisted.
@GarethLlewelyn on GitHub · 2026-12-01 16:43 UTC · original · approved these changes
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.