perf(agc): remember an evicting import request's budget refusal until it could succeed #6730
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6730"
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 EagleBearerYS on 2026-10-16T07:54:01Z.
What
At a full host import budget, a request that may evict asked again on every use. That covers an upload's region that needs an import, and
HostImportFor. Each time it walked every live import inevictableBytesand was refused again. #6457 remembers the refusals of requests that may not evict. This PR remembers the evicting ones too, for exactly as long as the refusal can't turn into a success.Depends on: #6457. This branch is #6457 plus this PR's commits and a merge of
main5d9dcc42d2.Why. In Resident Evil Village (PPSA01556)'s first scene the 6400 MiB budget is full, and one upload range is refused at every use:
How. Without a held overlapping import, an evicting request is refused when the bytes of non-evictable imports outside its run, plus the run's own bytes, exceed the budget. A refusal can only become a success when one of these happens:
So each refusal is remembered with the state that decided it and the room it left, for every block a step-down tries. It is answered from memory, and still counted as refused and remembered, while all of these hold:
epochandliveBytesare unchanged: no import was made or retired;stillRefusedrule;A remembered refusal reproduces the scan's own decision: if the run can step down and the request's range fits in the room left, less any budget drop since, it steps down as the scan would, without a new walk; otherwise it is refused. A join's refusal is remembered too, kept apart from other requests for the same run, since a join skips the held-import check and never steps down.
Every condition is exact or errs toward trying again, so a request that could succeed is never answered from memory.
Not changed:
refreshImportsdrops stale entries, and a device change andClearHostImportsclear them.Cost in Resident Evil Village's scene (by design, not measured yet): at ~72 address-based builds per second, which restamp the imports they map, the memory is walked again at most once per build, instead of once per request.
Overlap. At this head the overlap check lists the same other PRs as for #6457, so this PR adds no conflict beyond #6457's own. #6479, also stacked on #6457, changes the same budget path in
importRunAtand adds tests toBdaResources.cpp. This PR uses #6479's rule for a budget that moves, so whichever lands second keeps both. #6918 (Scramblrrrr, draft) clips a partly committed import window to the aligned committed span that holds the request, inwindowRun, and merges cleanly with this PR. The evicting refusals this PR remembers are keyed by the runwindowRunreturns and compared by its ranges, so a clipped window is remembered as its own run, and a window whose committed span changes is a new request.Tested
agc_driver_graphics' mock device):GuestBufferMemory.cppwith the tests kept:8 evicting requests for one refused piece at a full budget with nothing evictable scanned the imports 8 times, not once. Green:Graphics validation tests passed.ctest -R '^agc'×5: 605/605 three times, and twice 604/605. The one failure wasagc_driver_preparation_scope_settle, a known load flake that passes 10/10 alone.agc_driver_graphicsincluded):guest_kqueuefails, on both sides; it fails on that runner withmaintoo.GuestBufferMemory.cpp:8 evicting requests alternating between two 64 KiB ranges of one refused 256 KiB block scanned the imports 8 times, not once;8 uploads bound across three refused ranges scanned the imports for their join 8 times, not once;8 evicting requests that step down from a refused block scanned the imports 8 times, not once.agc_driver_graphics×10: 10/10;ctest -R '^agc': 607/607 (43 skipped).GuestBufferMemory.cppand the new tests,agc_driver_graphicsfails in every one of 3 runs on Linux and Windows; with the three commits it passes 10 of 10 on both. In the suites onlyguest_kqueuefails on Windows, on both sides.main:ctest -R '^agc'on GitHub's Linux runner at the merged head passes 606 of 607; the one failure is the sameagc_driver_preparation_scope_settleload flake.-fsyntax-only -Wall: no new diagnostics against #6457's head.7539ba611, this branch merged withmain52798f71d5(comment): all 63 tests built from the targets this PR changes pass.python3 tools/check_conventions.py --base origin/main: passed. No comment lines added.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-16T08:39:14Z.
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/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppL1659docs/dev/debt/libSceAgcDriver.mdL196-197Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdImported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-16T21:06:40Z.
Data point from a CPU-bound scene on Windows: RTX 3060 12 GB (NVIDIA 617.42), i5-12400F, Windows 10 19045, MinGW GCC Release. Minecraft Dungeons II (PPSA16064 01.100.100), title screen, no input, 200 s rows,
APS5_PROFILE_DRAW=1 APS5_PROFILE_GPU=1;mainc84249186vsmain+ this PR, interleaved with three other PRs in one batch, two rounds. FPS is the mean of the last 10[present]windows, GPU busy and idle gaps per frame over the last 8. This scene is CPU-bound on this machine (45-48 ms of idle gaps per frame).mainefdba5df4)Within the run-to-run spread (about ±1.5 % here), no regression, 0 fatal. The title screen on a 12 GB card has no evicting imports to refuse, so it doesn't exercise the path this changes.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by keravyn-ops on 2026-10-17T10:16:29Z.
AMD / Windows run of this PR at
7539ba611: Radeon 780M (RDNA 3, 0x15bf), AMD driver 25.10.20.01 (32.0.21020.1007), Windows 11 Home 10.0.26100, WinLibs GCC 15.2.0 r7, Release.Every ctest entry built from the test targets this PR changes passes (63):
agc_recorder_device_selection,agc_pipeline_cache,agc_pipeline_cache_file,agc_pipeline_library,agc_pipeline_library_off,agc_pipeline_library_fast_only,agc_import_watch,agc_import_watch_other_family,agc_unchanged_cpu_stamps,agc_storage_kept_unit_settle,agc_storage_baseline_settled,agc_storage_integer_clear,agc_storage_upload_lifetime,agc_storage_upload_failure,agc_storage_written_buffer_order,agc_storage_split_writeback,agc_copied_direct_ordering,agc_storage_writeback_blocks,agc_recorder_read_list,agc_space_pending_writes,agc_host_import_unmap,agc_parked_import_unmap,agc_host_import_retirement,agc_sparse_run_import,agc_sparse_run_import_copied,agc_unit_shadow,agc_storage_cpu_snapshot,agc_descriptor_pool_recycling,agc_draw_snapshot_cap,agc_draw_snapshot_epoch,agc_multisample_guest_access,agc_draw_inputs_in_place,agc_pending_write_snapshot,agc_resident_present,agc_queued_write_groups,agc_tiled_resolve,agc_slice_dirty,agc_metadata_pass,agc_host_import_second_mapping,agc_pending_key_stores,agc_shadowed_key_stores,agc_sample_dumps,agc_driver_vertex_target_range_copied,agc_driver_vertex_target_range_imported,agc_driver_undithered_alpha_to_coverage_state,agc_driver_msaa_dcc_state,agc_driver_alpha_to_coverage_state,agc_driver_prepared_graphics_prebuild_unset,agc_driver_prepared_graphics_prebuild_0,agc_driver_prepared_graphics_prebuild_1,agc_driver_graphics,agc_driver_f16_fma_denormal_modes,agc_driver_linear_target_resident,agc_driver_prepared_graphics,agc_driver_prepared_unregistered_graphics,agc_driver_storage_write_back_overhang,agc_sparse_buffer_holes,agc_pipeline_journal,agc_pipeline_library_clear_waits_for_build,agc_descriptor_pool_reset_failure,agc_driver_address_space_teardown,agc_compute_descriptor_layout_flags,agc_driver_covered_centroid_stateAI-assisted: yes (runs made on the device above).
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-18T19:34:19Z.
This pull request is labeled
perf, so it needs the summary line of a capture onmainand one with the change, from the same title, scene and machine, as the Performance report form asks. Please paste bothaps5-summary.jsonllines, attach the two traces and add the output oftools/trace_digest.py.