fix(vk): the page files' room to grow counts before the commit rule cuts the textures #346
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/upscaling
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
testing wanted
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!346
Loading…
Reference in a new issue
No description provided.
Delete branch "jarynclouatre/Longshot:fix/commit-room-growing-page-file"
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?
Why
Issue 336: "Sometimes when I open my inventory menu or open the list to switch my items the game freezes for a second and the textures go black. It then goes back to normal." (RTX 5070 Ti, Ryzen 7 9800X3D, 32 GB, Windows, v3.0.0-rc.3.)
The issue's log shows the commit rule of #77 cutting the texture cache for about 90 minutes on a PC that was never at Windows' commit limit:
boot: 31849 MB of memory, 2048 MB of swap: a commit limit of 33.9 GB at the start.vk: commit limit near:lines (one every 600 frames at most) between presents 98,400 and 422,280, with 308 to 2,556 MB of commit left.privatein thevk: memory:line) plus the commit left rose from 24.3 GB to 36.1 GB over those lines. That is above the 33.9 GB limit of the start with every other program counted as nothing, so the limit itself grew. Nomem: commit ... at the commit limitline in the log: Windows refused no commit.budgetcount of thetextures retiredlines adds up to 292,526 textures. 473 of the 707VRAM:lines show the textures' budget cut, to between 0 and 4,180 MB (11,000 MB otherwise), with 6.8 to 10.7 GB used of 15.2 GB allowed. After present 246,720 three evictions in a row (416, 361 and 56 textures) took the cache from 2,378 MB to 502 MB.The rule reads
GlobalMemoryStatusEx'sullAvailPageFile: what is left under the limit as it is now, RAM plus the page files at their size of the moment. A page file Windows manages (the default, and what the game's own low-memory notice asks for: "let it manage the page file's size") grows when the commit nears the limit, and the limit with it. So on such a PC the reading stays small for as long as the game's commit grows, and the rule takes textures away that are then made again.What changed
gpu/vk/commit_room.h, new;gpu/vk/vk_texture.cpp,commit_headroom): below the reserve, the headroom is what is left under the limit now plus what the page files can still grow by. Each file counts up to its maximum, and the files of one drive together no further than the drive has free. The sizes and maximums come fromNtQuerySystemInformation'sSystemPageFileInformationEx(0x90), the free space fromGetDiskFreeSpaceExW; both are read at most once a second, and only while the commit left is below the reserve.vk: commit: N MB left under Windows' limit as it is now, and the page files can grow by N MB more: counted as roomat most every 3600 frames while the growth is being counted.RX_VK_COMMIT_GROWTH=0indocs/development.md's switch reference, and theRX_VK_COMMIT_RESERVE_MBrow names it.tests/test_commit_room.py(new, withtests/test_commit_room.cpp) compiles and runs the rule: one file's growth, two files sharing a drive, a full drive, a file at or above its maximum, an unknown drive, the issue's numbers with and without the growth, and the reading of the query's records (a cut buffer, a name outside the buffer, a next offset that points back or past the end). It also checks thatvk_texture.cppuses the rule.Flags and settings
RX_VK_COMMIT_GROWTH=0mainMeasurements
main:
cf605c85(2026-11-14)this PR: fix/commit-room-growing-page-file @
24c64183Hardware: Windows 11, RTX 4070 Ti SUPER, Ryzen 7 9800X3D, 32 GB; the page file set to "Windows manages the size" for the runs (9,216 MB, a commit limit of 41,381 MB, 188 GB free on its drive)
Scene: Castle Town's gate and the guard house, by scripted input with one debug teleport, 22,200 presents a run, 1024x768
Method: the same exe (built from main), main's
longshot_vk.dllagainst this PR's, four runs interleaved (main, PR, main, PR), each after a shader preparation of its own. The route does not reach the commit limit by itself (the game's own commit ends at 19 to 24 GB), so the rule was forced on all four runs as #77's test did:RX_VK_COMMIT_RESERVE_MB=21061, which is the commit left under the limit with the PC idle (36,061 MB) less 15,000 MB, so the rule acts once the game's commit passes about 15 GB. Both runs of a side are given, not a median.How to reproduce: the two DLLs, a page file Windows manages,
RX_VK_COMMIT_RESERVE_MBinlongshot_env.txtset to the idle "left under the limit" less 15000, any route of a few minutescf605c85(run 1, run 2)24c64183(run 1, run 2)vk: commit limit near:linesvk: commit:linevk: commit:lines ("the page files can grow by 89088 MB more")VRAM:lines with the textures' budget cut (of 37)mem: commitlines)The 30 to 40 ms intervals: on both sides every 300 presents have 3 to 6 of them from the start of the run. On main they stop (0 to 2 in 300) from the point where the rule has cut the cache to a few hundred MB; on this PR they go on as before that point. So this PR's count is what main does while the rule is off, and what they are is not looked at here.
What the query gives for the page file on this PC, from a probe that uses the same header and calls (
total,min,maxin pages of 4 KB):The game-free suite,
python3 -I -B tests/run_all.py --jobs 4 --timeout 120on a Linux x86-64 PC (gcc 15.2, Python 3.14.4), two runs each, interleaved:cf605c8524c64183tests/run_all.py(run 1, run 2)test_bake_portability.py,test_menu_keys.py,test_module_ids.py,test_pad_layout.pytests/test_commit_room.pyvk_texture.cpp no longer has: #include "commit_room.h"test_bake_portability.pyfails here for a missing Python module (zstandard).test_menu_keys.pydoesn't build with g++ andtest_pad_layout.py's fixture lackshost/hold_toggle.h, both on main since #137 (#331 and #338 fix them).test_module_ids.pylooks for a source marker that main no longer has.Testing
Tested: the game on Windows 11 with a page file Windows manages, main's DLL against this PR's, two runs each, as in Measurements: with the rule forced, main cuts the textures' budget to 0 and retires about 9,200 textures for it in six minutes; this PR counts the 89,088 MB the page file can grow by, leaves the budget alone and retires none for it. The query on the same PC with the page file managed (a maximum of 98,304 MB, three times the RAM) and fixed (maximum = size, growth 0). The game-free suite on a Linux PC.
longshot_vk.dllbuilds with llvm-mingw 20261104 (nx2/build.py --standalone,RX_VK_ONLY=1), no warning in the changed files.Not tested: Windows growing the page file in play: the route stays far below the limit of the moment (the file stayed at its starting size), so the runs show the rule's reading, not the growth itself. For the growth there is issue 336's log, where the limit rose by more than 12 GB in play with no refused commit. A PC with 16 GB, two page files, and a drive that is nearly full, outside the game-free test.
Needs other testers: None.
Screenshots
Nothing on screen.
Risk and rollback
With the growth counted, a PC whose page file can still grow keeps its textures until Windows has grown the file to its maximum or the drive is full; from there the rule acts as on
main. If Windows cannot grow the file as fast as the game commits, a commit can be refused for a moment:hos_commitand the first-touch handler already wait up to 5 s for that (#77), and the issue's log, where Windows grew the limit by more than 12 GB in play, has no refused commit.RX_VK_COMMIT_GROWTH=0turns the change off; reverting the commit removes it.Reviewer notes
SystemPageFileInformationExis not in Microsoft's documentation (the record's layout is in phnt'sntexapi.h). The call is looked up inntdll.dllat run time and its result is read inside the buffer only; if it fails, the headroom isullAvailPageFilealone.memory_noticeinhost/hos_main.calso reads the limit of the moment (ullTotalPageFile) for its low-memory notice at the start. Not changed here.Issues
For #336
Checklist
For everyone
type(scope): description).main.python -I -B tests/run_all.pyrun and passing (any failure that also fails onmainis named above).third_party/untouched (a new folder with aPROVENANCE.mdinstead).If applicable
mainand passing here.tests/that reads changed source updated in this PR, not weakened.WIP: fix(vk): the page files' room to grow counts before the commit rule cuts the texturesto fix(vk): the page files' room to grow counts before the commit rule cuts the texturesWindows compile and game-free checks for head
24c64183:longshot_vk.dllbuilt with the pinned llvm-mingw 20261104 (RX_VK_ONLY=1 RX_RELEASE=1 RX_TARGET=windows,--jobs 6): 0 failed, linked.tests/test_commit_limit.pyandtests/test_commit_room.py: pass.No game run here, so the inventory freeze on a real Windows GPU still needs the scene from issue 336. The build and the two checks are clean on Windows.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.