fix(memory): give commit back near Windows' commit limit instead of crashing #77
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
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!77
Loading…
Reference in a new issue
No description provided.
Delete branch "HumanBean/Longshot:fix/commit-limit"
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
On Windows a PC with a small page file can hit the commit limit while an area loads, and the game crashes (
Windows is out of memory, then an access violation onARes Loading 1). This gives commit back before the limit, and waits at the limit instead of crashing.Port of NotRexed/Hookshot#2972 by NotRexed, who wrote it and is kept as the commit's author. The patch applied as is once the comment tags were renamed (hookshot → longshot). The only addition is the docs row for the new switch.
What changed
texture_frame()ingpu/vk/vk_texture.cpp, beside the driver's-limit rules (commit_reserve(),commit_headroom()). When commit headroom (GlobalMemoryStatusEx'sullAvailPageFile, Windows only) drops belowRX_VK_COMMIT_RESERVE_MB, the shortfall comes off the textures' budget, and eviction and compaction give the blocks back. While it is active it logsvk: commit limit near:at most every 600 frames.hos_commitand the first-touch handler inhost/mkw_glue.cwait up to 5 s at the commit limit (error 1455), retrying every 50 ms, before giving up. Before, the failed commit left the pages reserved and the game's next write crashed. The failure log and the out-of-memory notice now live in one place,commit_refused.tests/test_commit_limit.pychecks the rule, the wait, and that the first-touch handler doesn't wait twice.RX_VK_COMMIT_RESERVE_MBindocs/development.md, "Switches for testing and debugging".Flags and settings
RX_VK_COMMIT_RESERVE_MB=<MB>0turns the rule offMeasurements
NotRexed's in-game results, posted on the original PR after it was opened. They were measured on Hookshot, where this is the same code (the only difference is the hookshot → longshot comment tags). These numbers were not taken again on Longshot.
main: e0e60920 (Hookshot main, 2026-11-12; Longshot main here:
ef8b784f)this PR: fix/commit-limit @ 905cb5e1 (Hookshot;
87a5e424here)Baseline: Hookshot main @ e0e60920 (the base of NotRexed/Hookshot#2972); this PR's code is its head 905cb5e1, here as
87a5e424on Longshot mainef8b784f. Longshot main wasn't measured separately because the code under test didn't change in the port.Hardware: RTX 4060 Ti, 31 GB RAM, 115 GB commit limit, Windows
Scene: the route run (Kokiri, Hyrule Field, Kakariko), 3440x1440, muted
Method: main and this branch alternated, 2 runs each with the rule idle (this PC never gets near its limit); then a run with the rule forced (
RX_VK_COMMIT_RESERVE_MB=38397, about 25 GB of the game's commit before it kicks in) against the run before it, where the rule never fired. Median fps, p99 frame time, private commit, VRAM blocks, and thevk: commit limit near:lines from the log.How to reproduce: on Windows, run the route once on main and once on this PR, twice each, alternating; then set
RX_VK_COMMIT_RESERVE_MBto about your free commit less 25 GB and run it again.Rule idle (the default on a PC far from its limit):
commit limit nearlinesThe rule never fired on this branch's runs, so the fps and commit differences are run-to-run variation, not the change. What these runs show is that it costs nothing when idle.
Rule forced (
RX_VK_COMMIT_RESERVE_MB=38397):RX_VK_COMMIT_RESERVE_MB=38397commit limit nearlinesWith the rule forced, the texture budget came down by the shortfall each time (for example 3661 → 2812 MB), and headroom stayed between 37.4 and 38.4 GB, within about 1 GB of the reserve. The compaction gave blocks back. No flashes in the earlier forced attempt's flash check, but its Kokiri walk never reached the reserve, so that check doesn't show the trim active.
Why the fix is needed (Hookshot main, a route run on the RTX 4060 Ti, and the crash report from a 16 GB PC with a fixed 32 GB page file, 47.9 GB commit limit): private commit went from 19.3 GB at the start to 35.4 GB in Hyrule Field, while the VRAM blocks grew from 2.7 to 13.3 GB. Private commit less the blocks stayed flat at ~21 GB, and the working set at ~11 GB. The 16 GB PC crashed at 33.9 GB of its own commit:
Testing
Tested: in the game by NotRexed on Hookshot (same code), RTX 4060 Ti, 31 GB RAM, Windows, on the route run (Kokiri, Hyrule Field, Kakariko): 2 interleaved runs each of main and this branch with the rule idle, and a run with the rule forced, which logged 52
commit limit nearlines and lowered both peak commit and VRAM blocks (see Measurements). Game-free on Linux for this port:test_commit_limit.py,test_texture_squeeze.py,test_blocks_at_start.pyandtest_patch_hooks_defined.pypass.tests/run_all.pygives 454 passed, 7 failed, 71 skipped, rebased on main @ef8b784f. All 7 also fail on main without this change: test_bake_portability, test_builder_log_read_only, test_program_cache_cleanup, test_program_cache_one_variant, test_control, test_longshot_ctl, test_vram_budget_row.Not tested: the 5 s wait at the commit limit itself (reaching it means really filling a PC's commit;
tests/test_commit_limit.pycovers it), and a PC that actually reaches its limit in play, like the 16 GB one with the fixed page file from the crash report. Nobody has run the Longshot build of this in the game.Needs other testers:
vk: commit limit near:lines near the limit and no out-of-memory crash while an area loads (no request opened; anyone with such a PC is welcome)Screenshots
Nothing on screen.
Risk and rollback
With headroom under the reserve, textures could be evicted more often (more streaming and pop-in) on a PC close to its commit limit.
RX_VK_COMMIT_RESERVE_MB=0turns the rule off. The 5 s wait at the limit only happens where the game would have crashed. Reverting the commit is enough.Reviewer notes
The new block in
texture_frame()is the core. It reuses the driver's-limit rule'soverarithmetic. The related upstream lazy-heap draft (HOS_HEAP_LAZY), which goes after the guest heap committed whole up front, is not part of this.Issues
None.
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
Assisted-by:/Co-Authored-By:trailers.docs/tested-configurations.mdfor each measured run.MKWVK_API_VERSIONbumped (gpu/vk/vk_api.h'sMkwVkHostorMkwVkRendererchanged). (n/a)mainand passing here.tests/that reads changed source updated in this PR, not weakened. (n/a)🤖 Generated with Claude Code
0bc76e407ato1533bbd9d01533bbd9d0to87a5e4247aWIP: fix(memory): give commit back near Windows' commit limit instead of crashingto fix(memory): give commit back near Windows' commit limit instead of crashingllun referenced this pull request2026-11-13 03:02:42 +00:00