fix(agc): allocate Windows page permissions on demand #8139
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8139"
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 Izamaru on 2026-10-19T23:56:46Z.
What
On Windows,
PageSpan::allocatecommits one byte per 4-KiB guest page even when most of the arena has never been queried. Replace that dense allocation with a small atomic directory and 64-KiB metadata chunks allocated when readable pages are recorded.Missing chunks remain unknown and take the ordinary query path. Recording an inaccessible run does not allocate missing chunks; inaccessible entries in existing chunks are still cached. Invalidation,
accessSerial, initialization publication and access flags are retained. Chunks have process lifetime, like the previous flat allocation. Linux retains its flat allocation.This is a memory-allocation change, independent of merged #6701's write-generation stamps and #7788's Linux image caching. It overlaps the
PageSpanimplementation in #6921 (run scanning). Sequencing is agreed with @milescoviello: #8139 goes first; after it merges, @milescoviello will rebase #6921 and adapt its summaries to the sparse chunks, preserving the fences and the Linux flat allocation. This PR has no prerequisite and does not bundle #6921. We can help validate the author's rebased #6921 on Windows.Tested
Current-integration Windows revalidation, 2026-10-23
342ac2eda0696b40775e09eb8c928b180758bc1d.0ef6f9fc9a53f2962b6fa238b0dcb5e6ae1e04c6.b655ff3e4424e765ba0d64581f81449067cfabdd.0ec002d3ddcd5717c68f234527baa82212b470d0, treed63906895db5de0962eecb33083a02f28840b652.The main branch advanced during preparation, so the final paired comparison was repeated on the pinned main above. The only merge conflict was in
core/libs/prx/libSceAgcDriver/CMakeLists.txt: preserve both main'sagc_locks_testsblock and this PR's Windows page-state test block. The productionGuestMemory.cppmerged automatically; the sparse implementation andPageStates.cppfixture are unchanged. The diff against the pinned main still contains only the original three files. #6921 is not bundled.The control uses the pinned main's production code, byte for byte, with only the same CMake registration and
PageStates.cppfixture added so both sides run identical cases. It is a fixture-only control, not a claim that unmodified main already contains these new tests. The exact final commit was created in the fork, fetched by SHA, checked against the complete locally resolved tree, rebuilt and tested before moving the PR branch to it.Same environment on both sides: Release, Windows 11 build 26200, WinLibs MinGW-w64 GCC 15.2.0 r7; NVIDIA GeForce RTX 4090, driver 617.14; Khronos validation 1.4.363.0.
The same eight behavioral cases pass on both:
agc_page_states,agc_driver_graphics,agc_sparse_buffer_holes,agc_copy_input_kept_bytes,agc_depth_copy_kept_bytes,agc_draw_inputs_copied,agc_space_pending_writes,agc_pending_write_snapshot.0ec002d3d0ef6f9fc9Run serially with
ctest -V --timeout 30,ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationand loader layer diagnostics. Both behavioral selections confirm three actual Khronos instance-layer insertions and the RTX 4090 device. Their VUID sets are empty; neither log reports the requested layer missing or skipped cases. The page-state and metadata fixtures themselves are CPU tests and create no Vulkan instance.Fresh-process metadata control on this pinned integration
With main production,
agc_page_state_metadatafails as expected withpage permissions committed a dense arena tableand 262,664,192 bytes incremental private commit. With the exact final head it passes at 102,400 bytes, a 262,561,792-byte (250.40-MiB) reduction in this fixture. Querying an untouched reserved chunk also passes its no-allocation check.The behavioral fixture covers concurrent first publication, chunk boundaries, guest bytes, reserved holes, protection changes, decommit and recommit through the access observer.
git diff --checkand conventions against the pinned main pass. The literalorigin/mainconventions check was also run; its unrelated upstream findings come from that ref tracking the older fork main.Limitations: focused synthetic Windows/NVIDIA validation only; no full-suite, Linux runtime, other-vendor GPU, title-runtime, title-unblock, FPS or whole-game memory claim. The 250.40-MiB figure is a metadata-initialization measurement, not a saving measured in Yōtei. Full Windows/Linux CI still requires a collaborator to dispatch the project build workflow for the updated head. Subsequent main commits are outside these pinned results.
The independent Windows 10 reports below retain their original heads and are separate from this author's 2026-10-23 revalidation.
Independent Windows 10 validation
TheSovietWaffle reports that
agc_page_statesandagc_page_state_metadatapass 5 of 5 on the earlier head20ddc95c5: Windows 10 Pro 22H2 build 19045, WinLibs GCC 15.2.0, Release, Ryzen system with an RTX 3080 and Radeon iGPU.This independently extends the page-state and metadata test coverage to Windows 10. These two fixtures exercise CPU-side memory-permission and metadata paths; the listed adapters do not establish Vulkan/GPU coverage. No exact private-commit measurements were supplied, so this report is not an independent measurement of the 250.40-MiB reduction above.
Earlier published head with a baseline
xXPBSXx reports a paired Windows run on the earlier head
2533730bf2: Windows 10 Pro 10.0.19045, Ryzen 7 5800X3D, WinLibs GCC 15.2.0 (MinGW-w64 UCRT), Release. Onlyagc_page_state_testswas built, withctest -Nconfirming the two cases.agc_page_statesandagc_page_state_metadataboth pass in all three runs.tests/PageStates.cppwas retained and only productionExecution/src/GuestMemory.cppwas replaced by merge-basecabd80f472. The behavioral test passes; the metadata test fails in all three runs withpage permissions committed a dense arena tableand 262,664,192 bytes of initialization private commit.This independently reproduces the dense baseline on Windows 10 for that earlier published head. These are CPU permission/metadata fixtures only; no other tests, platforms, full suite or titles were run. No PR-side private-commit value was supplied, so the exact 250.40-MiB reduction above has not been independently remeasured by this report.
Checklist
main; no other open PR implements the same functions — refreshed against the pinned main above. #6921 has an agreed merge order: #8139 first, then the author rebases #6921.NotImplemented_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 TheSovietWaffle on 2026-10-20T07:40:44Z.
Windows 10 data point (Windows 10 Pro 22H2 19045, WinLibs GCC 15.2.0, Release, Ryzen with RTX 3080 and Radeon iGPU), head
20ddc95c5:agc_page_statesandagc_page_state_metadatapass 5 of 5.AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by Izamaru on 2026-10-20T12:45:17Z.
@milescoviello, could we agree on sequencing between #8139 and #6921? The changes are complementary: #8139 makes Windows page-state storage sparse, while #6921 accelerates scans using block summaries.
Local merge-tree checks found conflicts in
GuestMemory.cppin either order. The combined implementation needs to preserve sparse allocation, summary invalidation and the concurrency fences.Would merging #8139 first work for you? We can help adapt and validate the Windows path afterward. If you and the maintainer prefer #6921 first, we can instead rebase #8139 onto it and preserve both behaviors.
Could we agree on the merge order and who handles the combined adaptation before taking #8139 out of draft?
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-20T12:56:52Z.
@Izamaru Yes, #8139 first works for me, and I'll handle the combined version in #6921. #8139 fixes how much memory the Windows table commits, while #6921 only speeds up scans, so it makes sense for the fix to go in first.
After #8139 is merged, I'll rebase #6921 onto it:
Chunk. 65536 entries is a whole number of 64-page blocks, so every chunk carries its own 1024 summary bytes, and the sparse allocation stays as #8139 has it.runalready does for zero.settleandforgetfences stay on the chunk's entries and summaries.callocwith the summaries after the pages, as #6921 does now.I'll add a case to your
PageStatestest with a run that crosses a chunk boundary into an unallocated chunk. If you can, a Windows check of the rebased #6921 would help:agc_page_statesplus #6921'sGuestAllocationscases.Thanks also, @TheSovietWaffle, for the Windows run here.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by Izamaru on 2026-10-20T14:01:54Z.
@milescoviello Thanks, #8139 first works for us too. I refreshed it against main
cabd80f47; the standalone PR still contains only its original three files.The experiment is now published in our fork: lab/compat-8139-6921 (diff against the pinned main). It combines #8139 at
20ddc95c5and #6921 atf05f64ab3, based on main44e3389c8. This is an independent integration experiment for review, not validation of your future rebase.Pinned published tip:
70cc3909b92c4b3b07defb0c9058c1f94dd0893b. Its complete Git tree68c20938ba97225d6ddac0ca94b652097603e43eexactly matches the locally tested candidatec6e0b6854756ebf8ee950dd86041214984f68eaf; the original upstream commits are retained in the merge history. The additional Windows fixture is included.On Windows 11 build 26200, GCC 15.2.0 r7, Release, RTX 4090 driver 617.14:
The experiment puts the 1024 summary bytes in each 65536-entry chunk, skips missing chunks and preserves the settle/forget fences and Linux flat allocation, consistent with your proposed direction. Linux and the full suite were not run. The agreed order remains #8139 first, then your adapted #6921. We can test agc_page_states plus your GuestAllocations cases when you publish the rebase. No loading-time, FPS or gameplay claim.
AI-assisted: yes (OpenAI Codex); author reviewed and is responsible for the results.
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-20T14:15:41Z.
Thanks @Izamaru, that is useful ahead of the rebase. The check that removing the summary clear in
forgetmakes your test fail is exactly the integration defect I would worry about. Yes, please shareagc_page_state_runs(a gist or a branch is fine). I will carry it in the rebased #6921 with you credited in the description, next to myGuestAllocationscases, and ping you here when it is up so you can run the Windows side.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by Izamaru on 2026-10-20T14:24:52Z.
@milescoviello I updated my earlier comment after your reply with the published lab/compat-8139-6921 branch. The
agc_page_state_runsfixture is included; the pinned commit, test results and limitations are all in that updated comment. We can run the Windows checks when your rebase is ready.AI-assisted: yes (OpenAI Codex).
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-20T14:27:53Z.
Thanks @Izamaru, I will take
agc_page_state_runsfromlab/compat-8139-6921for the rebase and credit it.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T01:20:53Z.
Independent Windows run of this PR with a baseline (data only).
Environment: Windows 10 Pro 10.0.19045, Ryzen 7 5800X3D, WinLibs GCC 15.2.0 (MinGW-w64 UCRT), Release. PR head
2533730bf2; merge-tree againstmainis clean. I built onlyagc_page_state_tests; the two tests areagc_page_statesandagc_page_state_metadata(ctest -Nlists both; the GPU on this machine plays no part in them).Results (3 runs each):
tests/PageStates.cppand replaced onlyExecution/src/GuestMemory.cppwith its version from the merge basecabd80f472, then rebuilt.agc_page_state_metadatafails 3/3 withpage permissions committed a dense arena tableandpage-permission initialization: 262664192 bytes of private commit;agc_page_statespasses. I restored the PR'sGuestMemory.cppafterwards.This adds the failing baseline to the earlier pass-only Windows data point.
Not run: other platforms, the other tests, the full repository CTest, and any title or console run.
AI-assisted (Claude Code).