perf(libkernel): prefault mapped Windows direct memory in the background #4290
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4290"
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 moong15 on 2026-10-12T04:57:14Z.
What
Opt-in background prefaulting of mapped Windows direct memory. With
APS5_PREFAULT_MEMORYset, a worker processes mapped ranges of at least 2 MiB usingVirtualLockfollowed byVirtualUnlockin 2 MiB chunks. It requests soft working-set headroom of at least 64 MiB minimum and 128 MiB maximum. The worker does not write the pages. Linux is unchanged.This aims to move first-touch page residency work away from guest loading threads. It is separate from the write-protection exception tracking fixed by #4535, which is now merged. The option can increase memory residency and remains disabled by default. A successful lock is followed immediately by an unlock, so residency is not guaranteed afterward.
Reopened after #4535 merged and rebased without conflicts onto
mainea2bbefb2. Current head:b2e1166df. The diff remains one file, 56 added lines. The earlier adjacent #4281 change is already in main. An open-PR search for prefault/VirtualLock found no competing implementation; automated overlap review remains pending.Tested
Reopening validation:
git diff --checkpassed. No build, runtime test or game comparison has been rerun on the rebasedb2e1166dfhead. This remains a draft while that validation and the current repository's performance-report evidence are pending.Historical evidence, not validation of the rebased head: Windows 11 Pro 26200, Ryzen 7 9800X3D, 47 GB RAM, Radeon RX 9070 XT (driver 32.0.32015.2008), WinLibs GCC 15.2, Release.
guest_memorypreviously passed with the option unset and set.Earlier Hades II PPSA36082 v01.006 warm-cache runs used a local
d146ec1b6build with this branch's DirectMemory.cpp, unpublished diagnostics, two cache options,APS5_HOST_IMPORT_MIB=16384andAPS5_NO_WRITE_WATCH=1in both arms. Without prefault, 4/4 runs crashed with a LoadTaskScheduler null write around 7.4-7.5 seconds; with prefault, 5/5 survived their observation windows (three 69-77 seconds and two 40 seconds) and the longer runs opened menu audio banks. Those results do not establish performance or correctness with normal write tracking on current main, nor prove the crash's cause.Subsequent combined-fix investigation and its limitations are recorded in #4535. Fresh matched main-versus-prefault measurements with write tracking enabled are needed here. No current-head speed, cold-cache, rendered-menu or gameplay claim is made. Before making a speed claim, collect the same-machine/same-scene summary lines and attach traces as required by the Performance report issue form. Full upstream CI requires a maintainer's manual workflow run.
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)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T06:49:43Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libkernel/CMakeLists.txtL1117core/libs/prx/libkernel/CMakeLists.txtL1117Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T08:14:17Z.
Tested on Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release: this PR merged onto
mainc080fc2d5(no conflict).windows_prefault_enabled(0.64 s) andwindows_prefault_disabled(0.38 s) pass with the PR.DirectMemory.cpptaken back tomain,windows_prefault_enabledfails (Prefault check failedatWindowsPrefault.cpp:39, 6.4 s);windows_prefault_disabledstill passes. So the new check fails without the change and the test finishes in well under 30 s either way.Not tested: Linux (Windows-only code), a console, a title run.
AI-assisted (Claude Code).
Pull request closed