perf(libkernel): commit Windows direct backing when mapped #4281
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4281"
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?
Imported from boykopovar/AnyPS5. Originally posted by eljackjoestar-cmd on 2026-10-12T03:59:54Z.
What
On Windows, creating direct-memory backing charges its entire allocation to the system commit limit even when only a small part is mapped. Lost Soul Aside allocates almost all 13.5 GiB of guest direct memory at startup; the unused backing leaves too little commit headroom for level loading.
Create paging-file sections with
SEC_RESERVE, then commit reserved mapped pages before applying guest protection. Existing committed views retain their contents. Physical contents remain shared between aliases and survive unmap/remap until their backing is released. Linux keeps its current implementation. This follows Microsoft's CreateFileMapping and VirtualAlloc contracts; it changes host allocation lifetime, not guest protection or shader semantics.Checked open PRs for
SEC_RESERVEand direct-memory commitment. #2054 changes singly mapped pages to private write-watched storage to avoid Windows exception-frame corruption; #637 changes write tracking; neither implements this backing reservation. No equivalent fix was found.Tested
Separate checkout based on main
d146ec1b6, Windows 11 x64, WinLibs GCC 15.2, Release, BUILD_TESTING=ON.libc,libkernelandguest_memory_testsbuild.guest_memorypasses in 1.46 s, including new sparse 256 MiB backing checks that map its first and last pages, verify zero initialization, shared alias writes, unchanged distant contents and preservation across unmap/remap. Existing protection, physical reuse, partial release and alias tests remain passing.A separate native probe allocates 2 GiB, maps 16 KiB at offset 1 GiB and verifies alias writes and remapped contents. System commit rose by 2,167,386,112 bytes immediately after allocation on the same-main baseline, versus 4,861,952 bytes with the integration candidate and 13,668,352 bytes with the isolated branch. These global counters include unrelated host activity; the large eager backing charge is absent, not a promise about exact per-page process accounting.
Lost Soul Aside integration testing with existing graphics/audio dependencies and #4271: startup had about 19.2 GiB commit headroom where the prior run had about 6.4 GiB. It reached the title menu and then level loading; near the end of loading about 3 GiB remained. The run subsequently aborted on
buffer descriptor uses an unsupported type. Earlier cold startup still had an Unreal garbage-collection assertion. Gameplay, green flashes, startup crackling and full playability are not claimed fixed. Integration dependencies are excluded from this branch.Committed pages are not decommitted merely by unmapping a view; their contents must survive later remapping. Commitment persists until the physical backing and remaining views are destroyed. Peak gameplay memory, Linux execution, older Windows versions and full CI remain unverified. No game data, logs, snapshots, probes or experimental diagnostics are committed.
Checklist
main; no other open PR implements the same functions