perf(libc): fast-path resident-run scans in WindowsMappings::collect and collectable #27250
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/27250"
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 birdmarty on 2026-11-25T15:44:57Z.
What
On Windows,
WindowsMappings::collectandWindowsMappings::collectablewalked the per-64 KiBviewsmap entry by entry even across multi-megabyte resident runs tracked inresidentRuns. On large surfaces (render targets, buffers, and textures), each write-watch query did redundantviews.lower_bound/ map iteration and per-page clamping even when the entire range lay inside a single resident run with noPAGE_NOACCESSpages.Changes
core/libs/prx/libc/include/WindowsMappings.hpp:hasNoAccesson each residentRunviaupdateResidentNoAccess(start, end, protection)on bothCommitandSetProtection(follow-upbc6c3abd98): setshasNoAccessonPAGE_NOACCESS, clears it in O(1) when an entire run is restored, and rescans the run's views on partial restoration so the fast path resumes once noPAGE_NOACCESSpages remain.collectableandcollect(includingCollection::Fresh), advance directly across resident runs fromresidentRunsbefore touchingviews, initializing theviewsiterator lazily only when a non-resident range is reached.ownedWords.eraseindisownwhenownedWordsis empty, and skip the per-page clamp loop incollectResidentwhenfromis already 4 KiB aligned.#ifdef APS5_COUNT_MAPPING_QUERIES, exposeResidentRunHasNoAccess(address)for write-watch tests.core/libs/tests/WindowsWriteWatch.cpp: addCheckResidentRunNoAccessTransitions()covering full and partialPAGE_NOACCESSset and restore transitions viaMap,SetProtection, andCommit, verifying bothCollectoutcomes andhasNoAccessflag restoration.Tested
Windows 11 Pro (build 26300), i9-9900K, MinGW-w64 GCC 15.3.0, Release build.
Unit tests on
bc6c3abd98(follow-up on2f6c010189, baseorigin/mainc032ba7c52):ctest -R "^(windows_write_watch|windows_mappings|agc_private_collect)": 9 / 9 passed (windows_write_watch,windows_write_watch_verify_direct,windows_mappings_release,windows_mappings_release_mismatch_{0,1,2},windows_mappings_lock,windows_mappings_lock_pthread,agc_private_collect).ctest -R "^public_headers": 65 / 65 passed.hasNoAccessclearing to match2f6c010189):windows_write_watchfails withrestoring a full resident run via SetProtection did not clear hasNoAccess; passes onbc6c3abd98.tools/check_conventions.py --base origin/main: passed.tools/debt_fold.py --check: passed.Lies of P (
PPSA10621,v01.012.000,3200x1800, Krat Central Station Plaza, AMD Radeon RX 6800, driver26.10.1):61250ca018(together with #26581, #26681, and #26778)):9.94 → 10.83 FPS(p50 99.9 → 91.0 ms,p90 108.9 → 99.2 ms,Graphics.Draw 65.7 → 62.1 ms/f), clean exit with 0 write-back errors.Performance captures (
APS5_TRACE_SECONDS=120:30, clean warm shader cache, no extraAPS5_TRACE_*orAPS5_PROFILE_*switches)Same machine, title (
PPSA10621,v01.012.000,3200x1800, Krat Central Station Plaza), and flags (APS5_DRAW_PIPELINE=1 APS5_NO_DRAW_STAGING=1 APS5_PIPELINE_DISPATCH=1 APS5_PIPELINE_DISPATCH_MISSES=1 APS5_FAST_F32=1):main,c032ba7c52):9.00 FPS,p50 110.5 ms,p90 117.7 ms,max 151.1 ms,gpu 70.31 ms/f,Graphics.Draw 72.33 ms/f(aps5-trace-c032ba7c5273-23148.json.gz).2f6c010189):9.31 FPS(+0.31),p50 106.1 ms(-4.4 ms),p90 114.7 ms(-3.0 ms),max 149.1 ms,gpu 68.70 ms/f(-1.61 ms/f),Graphics.Draw 72.86 ms/f(+0.53 ms/f) (aps5-trace-2f6c010189b9-35796.json.gz).Baseline
aps5-summary.jsonl(c032ba7c52):Candidate
aps5-summary.jsonl(2f6c010189):Series context & interleaved ablation
This PR is part of a general AGC/libc performance series measured on Lies of P (
PPSA10621,v01.012.000,3200x1800, UE4) covering #27249, #27250, #27251, #27252, #27253, #27254, #27268, #27269, #27270, #27271, and #27273 (tested together with #20130, #18757, #26778, #27117, and now-merged #26581 and #26681). Combined on base61250ca018(plus remaining unsplit stack changes), steady-state performance rose from7.25 FPS(p50 135.6 ms,gpu 92.7 ms/f, default settings) to12.15 FPSaverage (12.00/12.30 FPS, peak12.33 FPS,p50 81.5 ms,gpu 57.12 ms/f,+67.6%to+70.1%).Because five of the smaller PRs (#27253, #27254, #27270, #27271, and #27273) looked like they slightly lost average FPS (
-0.03to-0.31 FPS) in single isolated runs onc032ba7c52, we ran an interleaved 4-run ablation (A1 -> B1 -> A2 -> B2,APS5_TRACE_SECONDS=120:30, identical warm shader cache and flags) on the full stack to test whether removing those 5 PRs helped or hurt:61250ca018(WITH all 11 PRs): #27249, #27250, #27251, #27252, #27253, #27254, #27268, #27269, #27270, #27271, #27273 + #20130, #18757, #26778, #27117, #26581, #26681 + remaining unsplit stack changes (per-64 KiB proof/pending tracking and ShapeRecipe).61250ca018MINUS the 5 PRs (#27253, #27254, #27270, #27271, #27273): keeps #27249, #27250, #27251, #27252, #27268, #27269 + #20130, #18757, #26778, #27117, #26581, #26681 + remaining unsplit stack changes.DrawWithRecipe(ms/f)DrawFinish(ms/f)61250ca018, WITH all 11 PRs incl. #27253, #27254, #27270, #27271, #27273)61250ca018, MINUS #27253, #27254, #27270, #27271, #27273)61250ca018, WITH all 11 PRs incl. #27253, #27254, #27270, #27271, #27273)61250ca018, MINUS #27253, #27254, #27270, #27271, #27273)+0.39 FPS(+3.3%)-2.1 ms-4.6 ms-10.5 ms-3.21 ms/f-1.02 ms/f-0.88 ms/fRemoving those 5 PRs hurt every run (
A1 > B1andA2 > B2across all metrics), showing that their single-run isolated dips onc032ba7c52were within±0.25 FPSscene variance while larger bottlenecks (#27268, #27249, #27252, #20130, #18757) still dominated. Individual PR captures above remain isolated againstc032ba7c52.Not tested: Linux (file is Windows-only), fresh Lies of P capture on follow-up
bc6c3abd98(captures above are from2f6c010189).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 MarcZX10 on 2026-11-25T15:52:20Z.
Review: COMMENTED
Reviewed — comments
Material uncertainty remains because I could not run the reported Windows checks or inspect the code’s callers and tests.
What I ran
Reviewed head
2f6c010189b9301ef5605452cc198485ab201e79using the prepared diff andrepo_read.py.Results
Findings
Blocking
None verified.
Non-blocking
SetProtectionand theProtectpath only setRun::hasNoAccesswhen protection becomesPAGE_NOACCESS; they do not clear it when protection is restored.collectablemay then fall back to per-view checks for an entire resident run even after access is restored. Consider updating the flag on every protection change, accounting for partial-run ranges. Evidence:core/libs/prx/libc/include/WindowsMappings.hpp:250,core/libs/prx/libc/include/WindowsMappings.hpp:1094.Not verified
collect,collectable, or protection transitions.review/description.md,review/commits.md,review/manifest.json,review/diff.patch, and the changedWindowsMappings.hppranges 70–270, 650–755, 1070–1125, and 1215–1315.review/files.jsonwas not available through the reader; the file listing showed one changed file and no excluded changed-file content.To get this to a good state
Nothing is required. Optional: update the resident-run no-access tracking on protection restoration, and cover partial and full-run protection transitions in tests.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-26T10:58:22Z.
Review: APPROVED
Reviewed — looks good
The change was reviewed at
bc6c3abd9853cbc8ae386ee24c540711f1d0ee1a; the inspected resident-run fast paths and protection tracking are consistent with the described behavior, while builds and tests were not run here.What I ran
repo_read.py.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No runtime or build checks were performed. The reported Windows tests and performance captures were not independently verified. Both files marked
reviewedin the manifest were read; no files were excluded.To get this to a good state
Nothing is required.