Repository navigation
fix(kyty): populate as much of a Windows direct mapping as fits - #301
Closed
talha-devp wants to merge 1 commit into
Closed
talha-devp wants to merge 1 commit into
talha-devp wants to merge 1 commit into
Conversation
Windows populated a new direct mapping only while a quarter of host memory stayed available afterwards, and otherwise left the whole mapping demand paged. On a 16 GB host that needs about 10 GiB free for Hades II's 6 GiB pool, which a 16 GB PC rarely has once the game's earlier mappings are resident, so the pool stayed demand paged and the game crashed as in simnJS#219 (simnJS#287). Windows now keeps a sixteenth of host memory free instead, 1 GiB on a 16 GB host, and populates the first pages of a mapping for as long as that reserve holds, leaving only the rest on demand. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
|
Merged into AnyKyty as |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Windows populated a new direct mapping only while a quarter of host memory stayed available afterwards, and otherwise left the whole mapping demand paged. On a 16 GB host, Hades II's 6 GiB pool needs about 10 GiB free for that, but by the time the game maps it, its 1 GiB heap and 512 MiB pool are already resident and only about 6.5 to 8.5 GiB are left. So the pool stays demand paged and the game crashes as in #219. This is the 16 GB part of #287.
Windows now keeps a sixteenth of host memory free instead of a quarter (1 GiB on a 16 GB host, 2 GiB on 32 GB). It also no longer decides all or nothing: it populates the first pages of a mapping while that reserve holds and leaves only the rest on demand. A lower all-or-nothing threshold alone was not enough. With a 1 GiB reserve, the 6 GiB mapping landed 200 to 600 MiB short of the threshold in 2 of 3 launches, and one of them crashed. When a mapping is only partly populated, the log says how much, once.
Linux is unchanged: its default
privatebacking does not need the populate, and the quarter rule still applies to itspopulatefallback. The memory that the populate holds up front (the other half of #287) is unchanged.Tested
Windows 10 22H2 (19045), Ryzen 5 5600, RTX 4060 (NVIDIA 621.14), 32 GB. AnyKyty
eb5103d101, WinLibs GCC 15.2 and LLVM 21.1.8, Release, as the Windows job builds it.To simulate a 16 GB host, a helper process locked RAM with
VirtualLockuntil about 10 GB (or 9 GB for the tight case) stayed free. A local build evaluated the reserve with a 16 GiB total and logged each decision. Hades II (PPSA36082), cold launches replaying the same controller recording:eb5103d101), 10.6 GB freeLoadTaskScheduler,0xc0000005)On the full 32 GB host this PR populates everything, as before: 2 of 2 launches of 60 s ran (5,280 and 4,770 frames).
Memory: with everything populated on the simulated 16 GB host, Hades' working set peaked at about 12 GB and free memory fell to about 0.9 GB. Under the reserve, Windows can still trim the populated pages later; I measured only 90 to 180 s sessions.
Tests on the same machine, Windows build with
-DBUILD_TESTING=ON:guest_direct_memory_pages_populate,_demandand_changingpass (3 rounds each).guest_memoryfails at its first check (CheckResidentMappingBookkeepingStaysSmall, "resident direct mapping bookkeeping: -992.11 MiB per GiB mapped"). It fails the same way on the base without this change, and it is not in the CI's test pattern.tools/check_conventions.py --base origin/AnyKytyandtools/check_kyty_settings.pypass. Not tested on Linux: the Linux code is unchanged and the CI builds it.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)