Physical page allocations come from sections of up to 2 MiB (VICTORY_SECTION_MB, off by default; #1089) #1274
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!1274
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1274"
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?
@CuteBooty on GitHub · 2026-11-26 09:08 UTC · original
CuteBooty:sections-2mib→main· +250 −56 · 3 files · 2 commits · openAt
46bf5351, each physical-page request creates one Windows section. Fork run 307 measured 45 ms per usual frame and 197 ms per streaming frame in remapping, mostly in the system's own calls; run 308 found no redundant mapping among 103,024 pages. This ports RyanCase94's idea and first patch from #1089: a request is backed by sections of at most 2 MiB, so a remap touches small sections.Switch.
VICTORY_SECTION_MB=2turns it on. Unset or0keeps one section per request, as now. It is off by default here on purpose: with it on, a large request has several section handles, which matters to code that opens a whole allocation as one heap, and it has not been run under Wine. In my own tree it has been on by default for about fifteen runs.Measured (my tree, not this tip: Ryzen 5 3600, RTX 3070 8 GB, Windows 11, Series S; 5-second log lines):
The lower waits held in every run since. Frame time itself did not get shorter. In play, the half-second freezes while driving were gone.
What changed.
xmem.rs:XMemAllocatePhysicalPagesandSection::drop(the cap and the cleanup).inplace.rs:title_memory_section,title_memory_section_closed,write_own,census_oftrack individual sections. One test checks page numbering and a two-byte write across the 2 MiB boundary, with the switch off and on.State. Ported by hand onto this tip.
cargo clippy --workspace --all-targets -- -D warningsis clean,cargo test --workspacepasses (617), the asset policy passes. Not yet run in the game on this tip; the numbers above are from my tree (CuteBooty/victory-8gb), where the same change isVICTORY_SECTION_MB, default 2.Credit: RyanCase94 (#1089) for the idea and the first patch.
🤖 Generated with Claude Code
@HLVM04 on GitHub · 2026-11-26 09:26 UTC · original
An in-game data point on NVIDIA for the same idea, though not this PR's port: we applied the original 2 MiB section patch from #1089 alone on our fork-based stack (RTX 5070 Ti 16 GB, Ryzen 7 9800X3D, Windows 11 build 26200, Series S).
Like your 3070 table, the clear change was in the long frames. This is from a few runs, so scene variance is possible, and it was on Windows only.
@Garu667 on GitHub · 2026-11-26 09:38 UTC · original
Data point from an RTX 3080 10 GB (Series X,
f6a09d3+ this PR, merged with no conflict), same route twice (boat mission, 30 s standing then ~3 min driving), README set +CARD_SYNC_BATCH=1 CARD_HASH_WIDE=1:SECTION_MBunsetSECTION_MB=2So the remapping cost drops about 8x here too, but on this tree and card the long freezes while driving stay: the texture refresh's "waiting for title memory to hold still" reads 0 ms with or without the switch, and
VICTORY_FRAME_WHY2(#1275) shows the submit worker idle through the longest frames, so they come from somewhere else. No device loss, picture unchanged. One run each.@CuteBooty on GitHub · 2026-11-26 10:17 UTC · original
Thank you both for running it, and on the fork's own code, which I had not done.
It is the same shape as on the 3070: the remapping cost drops by a large factor and the frame rate by itself does not move. What went away here were the 0.3-0.8 s stalls while driving, which on my tree were the texture refresh waiting for the title's remaps; on a tree where that wait already reads 0 ms, as in the RTX 3080 run, there is nothing for it to remove, and the long frames there have another cause. I would leave the switch off by default as proposed.
@KainanP on GitHub · 2026-11-26 11:23 UTC · original
A synthetic reproduction of #1089's stall, without the game. It shows the same effect, and it can be rerun on any machine.
The method is what the title does to its physical pages. A 4 GiB pagefile-backed section (
SEC_RESERVE) is mapped one 64 KiB view per page into placeholders, the views are committed, and every page is touched. Then, for 10 s, a random page is remapped at a random address (unmap,MapViewOfFile3into the placeholder, commit). A second thread meanwhile makes, touches and frees 2 GiB, the kind of memory churn that wakes the large-page rebuild worker. The run alternates one section with 2 MiB sections over 5 rounds in one process.i7-14650HX, 32 GB, Windows 11 26200, release build, median of 5 rounds, going through VIctory's own
XMemAllocatePhysicalPages/XMemMapPhysicalPages:K32EmptyWorkingSet, no allocations) produces no stall in either mode. The trigger is memory being made and freed elsewhere, which a streaming title does all the time.The same change with the benchmark is up for upstream as Marvisak/VIctory#3177 (on by default there, since main has no in-place heap census), and for AnyXboxX as LooperSalty/AnyXboxX#352 (off by default, like here). For this PR, @CuteBooty: the benchmark is a self-contained
#[ignore]test inxmem.rs(physical_remap_bench) and should port as is, if you want the numbers reproducible here.AI use: Claude Code (Claude Opus 5.5) wrote the benchmark and ran it on my machine. No game files or game data.
@CuteBooty on GitHub · 2026-11-26 13:50 UTC · original
@KainanP thank you for the benchmark. I have ported the test to this branch (
99cd7e1b), credited to you with the reference to Marvisak/VIctory PR 3177, adapted toVICTORY_SECTION_MB: it picks one section or 2 MiB sections per run through a test-only override, so the switch's value does not matter. It is#[ignore]d (4 GiB mapped, about 90 s, roughly 6 GiB of memory at the peak):One change from yours: a drop guard stops the pressure thread, so a failed assertion in the timed loop cannot leave the test hanging.
One run here (Ryzen 5 3600, 32 GB, Windows 11; the machine was not quiet, so read it as shape, not as numbers):
Medians of 3 rounds. In one of the three rounds the one-section case was as fast as the 2 MiB one, so the stall comes and goes, as it does in the game.
AI-assisted (Claude Code).
@Proudnoob4 on GitHub · 2026-11-26 15:13 UTC · original
RTX 4080 / i5-13600K (Win10) 10-minute verification — 66× smaller worst frame stall (
7,408 ms -> 112 ms)!Ported
#1274(VICTORY_SECTION_MB=2) onto ourtrustno1-coder/VIctory-NVIDIA-based branch (989e5c6, adaptinginplace.rsso bothViews::sectionsandViews::wholeuseBTreeMapand clean up intitle_memory_section_gone) and ran both unit tests and a full 10-minute live GTA 6 prologue pass (--console series-s,render_scale=0.6667, RT skipped, warm shader cache):physical_page_numbers_and_writes_continue_across_sectionspassed withVICTORY_SECTION_MBunset and=2.n=104/105settled frames):VICTORY_SECTION_MB=0): worst frame7,408.4 ms,6frames>55 ms,0.0 mssteady-state remap waitVICTORY_SECTION_MB=2): worst frame112.4 ms(-98.5% / 66× reduction),2frames>55 ms(0in tail-40),0.0 msremap waitt=140..600s):0/230black frames,60/60clean consecutive tail burst frames, full4,582draws/frame, zero crashes or handle leaks.(Note: Pass 16 also had
#1184VICTORY_HOIST_CLAMPS=1enabled in the same run, which shifted steady-state FPS from32.00to30.70due to list-splitting overhead on top ofVICTORY_INDIRECT_BATCH=1;#1274itself is a clear streaming/stall win and we're keepingVICTORY_SECTION_MB=2enabled by default in our launcher.)@CuteBooty on GitHub · 2026-11-26 16:07 UTC · original
Summary of the confirmations so far: the remapping cost drops on every machine that tried it; the stalls go away where the remaps were their cause
@Proudnoob4 thank you for the 10-minute pass and for porting it to a different tree, and thanks again to everyone who ran it. Collected in one place, as reported by each tester (their trees and scenes differ, so the rows do not compare with each other):
VICTORY_SECTION_MB=2What I read from it:
Limits, as the testers stated them: mostly one run each; Proudnoob4's pass with the switch also had
VICTORY_HOIST_CLAMPS=1on; the stall comes and goes between runs, so a single run can miss it in either direction.On the default: I proposed leaving it off. With these reports I would be equally comfortable with it on by default if you prefer that, @fxceless; that is your call. The ignored benchmark on the branch (
physical_remap_bench) lets anyone check a machine in about 90 seconds.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.