Skip to content

perf(agc): reuse completed write observations across overlapping ranges - #17542

Merged
oneandonlydean merged 3 commits into
boykopovar:mainfrom
PrivacyOnion:perf/resource-observation-coverage
Nov 9, 2026
Merged

oneandonlydean merged 3 commits into
boykopovar:mainfrom
PrivacyOnion:perf/resource-observation-coverage

Conversation

@PrivacyOnion

@PrivacyOnion PrivacyOnion commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

What

Replace the exact-start per-worker collection memo with an ordered union of completed, page-rounded observations. A fully contained request can reuse the observation even when it starts inside an earlier range, or when several successful adjacent/overlapping walks jointly cover it. Holes still require collection. The union is private to the worker and is discarded whenever its collection epoch, unwatch serial or mapping generation changes. Failed walks never publish coverage; fresh/uncached collection, the 64-entry ring and shared-memo mode retain their behavior. Lockless hits return the last fully published tracker.stable generation, not a concurrent walk's generation.

Reject wrapped page-rounded bounds before all memo lookups. The new extreme-address regression exposed an existing ring-cache hit for a wrapped range.

No descriptor-content check, CPU/GPU write stamp, backing lifetime, resource residency check or GPU dependency is removed. There are no title-specific addresses, exceptions or new switches. This is a small observation-layer change, separate from descriptor-heap and write-subscription PRs.

The branch is based on main 0bae53facde88e56d2859f4d39cece93c9aab761; final head 99c145ed4684f18c1b82086348bfd70273d78d5a. The captured integration uses pinned main 095ff72367c43bd3111f5c96ff56d87a720cd8f2. The subsequent main commits change title-run tooling and unrelated voice/text-to-speech libraries; AGC, shader recompiler, libc and libkernel source are identical across those main bases.

Tested

Windows 11 build 26200, Release, WinLibs GCC 15.2.0; Ryzen 5 5600, 16 GiB RAM; NVIDIA GeForce RTX 5070, NVIDIA driver 616.64.

Focused validation logs, test results and overlap review are attached with the timing evidence. The identical GPU test selection is run on current main with the regression fixtures and on the final candidate, with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, VK_LOADER_LAYERS_DISABLE=~implicit~, using ctest --test-dir C:/Users/playl/AppData/Local/Temp/ap5p15 -R <pattern> -V.

The coverage tests exercise interior containment after ring eviction, adjacent ranges in both orders, bridge/overlap/containing ranges, holes, empty/overflowing addresses, new epochs, unwatch/mapping invalidation, a second worker, explicit driver writes and mandatory uncached collection. Existing mapping-history, draw-descriptor and resource-cache tests remain included.

Performance scene: Sniper Ghost Warrior Contracts 2, PPSA03131, 01.004.000, stationary initial tutorial position at 3840x2160. Same machine, original savedata seed, scripted controller inputs and default game settings. Owned title relinked with --windows --no-patches; offline and dummy audio. Both variants completed warm runs in the same scene before measurement. Retained order A1, B1-retry, A2, B2; only APS5_TRACE_SECONDS=240:40 and its output directory enabled for timing. No diagnostic profiling switches, game-log redirection, frame dumps, compilation, GPU tests or overlap scans during retained captures. B1 was closed accidentally by the user before its capture completed; it produced no completed timing window and is explicitly excluded, then repeated in place.

Pure main stops at the tutorial's independent dual-source MIN blend, so gameplay comparison uses identical prerequisites on both sides: #17187, #17157, #16286 and #17255. A is clean integration 504135cf2b198ffca60257e6fffe4bcc13d3b15e; B is a2ab9931fac4cdd1ee7e7c4453a7e4a51b02659a. Production source differs only in this PR's GuestMemory.cpp, which is identical to the final public implementation. All staged libraries except libSceAgcDriver.prx are byte-identical. The fork's perf/sniper-observation-coverage branch contains both integration commits. These common title prerequisites are not carried in this PR.

The two pairs show +3.25% and +2.49% mean FPS in this scene. This is a modest repeated scene-specific gain; no title unlock, campaign-wide gain or reduction in worst-frame latency is claimed. Tails vary in both directions between runs.

Capture Mean FPS p50 ms p90 ms p99 ms Max ms GPU busy ms/present
A1 10.29433 96.610 101.070 108.097 120.521 24.345
B1-retry 10.62927 92.568 98.955 124.030 184.302 24.134
A2 10.36150 94.982 103.773 133.863 146.982 24.277
B2 10.61989 93.621 97.405 107.675 128.697 24.256

tools/performance_compare.py --require-matching-context accepts both pairs. Event buffers fill early: complete frame summaries are retained, while slice inventories are partial (totals_full=false). Missing event slices are not treated as idle time or full-window scope totals. The digests preserve the warnings.

A1, tools/trace_digest.py:

seconds 240:40 from present 10221: 412 presents, frame p50 96.6 / p90 101.1 / p99 108.1 / max 120.5 ms, GPU busy 24.3 ms per present

NVIDIA GeForce RTX 5070, NVIDIA 616.64, Windows 10.0.26200, 3840x2160, commit 504135c, dropped: yes

{"commit":"504135cf2b19","dirty":false,"env":{"APS5_NET_DISCONNECTED":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"240:40"},"gpu":"NVIDIA GeForce RTX 5070","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"AMD Ryzen 5 5600 6-Core Processor","cpu_threads":12,"memory_mib":16311,"title_id":"PPSA03131","title":"Sniper Ghost Warrior Contracts 2","content_version":"01.004.000","resolution":"3840x2160","window":{"spec":"seconds 240:40","first_present":10221,"ms":40022.045},"presents":412,"frame_ms":{"p50":96.610,"p90":101.070,"p99":108.097,"max":120.521},"gpu_busy_ms_per_present":24.345,"worker_busy_pct":{"queue worker 0x0":96.364},"top_phases_ms_per_frame":{"Driver.Packet":93.579,"Driver.Packet.draw":58.829,"Driver.Draw":58.072,"Graphics.Draw":55.898,"Graphics.Draw.draw_and_resource_release":41.310,"Driver.Draw.shader_compile_and_link":27.433,"Driver.Draw.draw_enqueued":20.518,"Driver.Packet.dispatch":15.634},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":5.578,"events_lost":1636252,"totals_full":false},"draw committer":{"events_full_after_s":11.521,"events_lost":643399,"totals_full":false}},"trace":"aps5-trace-504135cf2b19-29608.json.gz"}

B1-retry, tools/trace_digest.py:

seconds 240:40 from present 6896: 426 presents, frame p50 92.6 / p90 99.0 / p99 124.0 / max 184.3 ms, GPU busy 24.1 ms per present

NVIDIA GeForce RTX 5070, NVIDIA 616.64, Windows 10.0.26200, 3840x2160, commit a2ab993, dropped: yes

{"commit":"a2ab9931fac4","dirty":false,"env":{"APS5_NET_DISCONNECTED":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"240:40"},"gpu":"NVIDIA GeForce RTX 5070","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"AMD Ryzen 5 5600 6-Core Processor","cpu_threads":12,"memory_mib":16311,"title_id":"PPSA03131","title":"Sniper Ghost Warrior Contracts 2","content_version":"01.004.000","resolution":"3840x2160","window":{"spec":"seconds 240:40","first_present":6896,"ms":40078.026},"presents":426,"frame_ms":{"p50":92.568,"p90":98.955,"p99":124.030,"max":184.302},"gpu_busy_ms_per_present":24.134,"worker_busy_pct":{"queue worker 0x0":96.346},"top_phases_ms_per_frame":{"Driver.Packet":90.608,"Driver.Packet.draw":59.046,"Driver.Draw":58.322,"Graphics.Draw":54.949,"Graphics.Draw.draw_and_resource_release":40.678,"Driver.Draw.shader_compile_and_link":29.292,"Driver.Draw.draw_enqueued":19.368,"Shader.DrawStage":16.347},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":5.653,"events_lost":1665933,"totals_full":false},"draw committer":{"events_full_after_s":11.763,"events_lost":658586,"totals_full":false}},"trace":"aps5-trace-a2ab9931fac4-1952.json.gz"}

A2, tools/trace_digest.py:

seconds 240:40 from present 6905: 415 presents, frame p50 95.0 / p90 103.8 / p99 133.9 / max 147.0 ms, GPU busy 24.3 ms per present

NVIDIA GeForce RTX 5070, NVIDIA 616.64, Windows 10.0.26200, 3840x2160, commit 504135c, dropped: yes

{"commit":"504135cf2b19","dirty":false,"env":{"APS5_NET_DISCONNECTED":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"240:40"},"gpu":"NVIDIA GeForce RTX 5070","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"AMD Ryzen 5 5600 6-Core Processor","cpu_threads":12,"memory_mib":16311,"title_id":"PPSA03131","title":"Sniper Ghost Warrior Contracts 2","content_version":"01.004.000","resolution":"3840x2160","window":{"spec":"seconds 240:40","first_present":6905,"ms":40052.116},"presents":415,"frame_ms":{"p50":94.982,"p90":103.773,"p99":133.863,"max":146.982},"gpu_busy_ms_per_present":24.277,"worker_busy_pct":{"queue worker 0x0":96.379},"top_phases_ms_per_frame":{"Driver.Packet":92.985,"Driver.Packet.draw":59.623,"Driver.Draw":58.872,"Graphics.Draw":55.785,"Graphics.Draw.draw_and_resource_release":41.318,"Driver.Draw.shader_compile_and_link":27.338,"Driver.Draw.draw_enqueued":21.480,"Shader.DrawStage":15.584},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":5.503,"events_lost":1619627,"totals_full":false},"draw committer":{"events_full_after_s":11.433,"events_lost":639889,"totals_full":false}},"trace":"aps5-trace-504135cf2b19-4132.json.gz"}

B2, tools/trace_digest.py:

seconds 240:40 from present 6839: 425 presents, frame p50 93.6 / p90 97.4 / p99 107.7 / max 128.7 ms, GPU busy 24.3 ms per present

NVIDIA GeForce RTX 5070, NVIDIA 616.64, Windows 10.0.26200, 3840x2160, commit a2ab993, dropped: yes

{"commit":"a2ab9931fac4","dirty":false,"env":{"APS5_NET_DISCONNECTED":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"240:40"},"gpu":"NVIDIA GeForce RTX 5070","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"AMD Ryzen 5 5600 6-Core Processor","cpu_threads":12,"memory_mib":16311,"title_id":"PPSA03131","title":"Sniper Ghost Warrior Contracts 2","content_version":"01.004.000","resolution":"3840x2160","window":{"spec":"seconds 240:40","first_present":6839,"ms":40019.229},"presents":425,"frame_ms":{"p50":93.621,"p90":97.405,"p99":107.675,"max":128.697},"gpu_busy_ms_per_present":24.256,"worker_busy_pct":{"queue worker 0x0":96.383},"top_phases_ms_per_frame":{"Driver.Packet":90.720,"Driver.Packet.draw":57.293,"Driver.Draw":56.578,"Graphics.Draw":54.803,"Graphics.Draw.draw_and_resource_release":40.638,"Driver.Draw.shader_compile_and_link":27.460,"Driver.Draw.draw_enqueued":19.407,"Shader.DrawStage":15.318},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":5.455,"events_lost":1652377,"totals_full":false},"draw committer":{"events_full_after_s":11.397,"events_lost":660713,"totals_full":false}},"trace":"aps5-trace-a2ab9931fac4-7524.json.gz"}

Evidence archive: timing traces, digests, comparisons and validation logs

Final validation: candidate 99c145ed4684f18c1b82086348bfd70273d78d5a passes 12/12; current-main production plus the identical regression fixtures (f6ca157aeca61ebdc9dff356be62265e863aa02b) passes all 9 existing tests, while the 3 new coverage cases fail at their intended reuse/wrapped-range assertions. Neither log has VUID- errors, a missing requested validation layer or skipped CTest tests. Linux-only fake-watch cases were not run locally; no Linux claim is made.

Final overlap check scanned 1,970 open PRs, 28 sharing files. The tool exits 2 for 14 conflicted comparisons: #5021, #6186, #6188, #6192, #6209, #7604, #7642, #10193, #12840, #13928, #13929, #15136, #15529 and #15807. Their full patches were manually reviewed and their fetched heads are unchanged at this final check; none modifies EpochCollectMap, epochCollectMap or collectWrites. No duplicate interval-union implementation was found. This does not duplicate #12745's write subscriptions, #17226's content hashes or #9508's descriptor heap/queue batching.

python tools/check_conventions.py --base origin/main was run as required: the fork's old main comparison reports 123 findings/18 errors in pre-existing upstream changes. The same source check against actual upstream/main passes. The final PR title/body are checked against actual main before publication. No fork-main update or unrelated source fix is included.

The automatic GitHub checks were queued when opened. A manual full Linux/Windows build dispatch was attempted and GitHub returned HTTP 403: this repository requires administrator rights to dispatch that workflow. The local Windows GPU validation above is completed; no completed full CI build is claimed for this PR.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 5070, NVIDIA 616.64, Windows 11 build 26200
  • AI-assisted: yes

@github-actions github-actions Bot added build agc libSceAgc* labels Nov 8, 2026
@oneandonlydean oneandonlydean self-assigned this Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Some 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.

Pull request Shared files not compared
PR 5021 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 6186 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 6188 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 6192 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 6209 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 7604 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 7642 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 9508 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
core/libs/prx/libSceAgcDriver/tests/CollectMemoGeneration.cpp
PR 10193 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 13928 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 13929 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 15136 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 15529 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 15807 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 16884 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp

@github-actions github-actions Bot added the perf Performance change label Nov 8, 2026
@oneandonlydean
oneandonlydean merged commit 6bbe255 into boykopovar:main Nov 9, 2026
14 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* build perf Performance change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants