perf(agc): import a block that mixes private memory with shared views in smaller runs #15454

Merged
Nesyth merged 1 commit from upstream-pr/15454 into main 2026-11-04 08:31:42 +00:00
Nesyth commented 2026-11-03 11:48:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Nesyth on 2026-11-03T11:48:58Z.


What

On Windows, neighbouring registered ranges are imported as one block. When the block holds writable private direct memory beside shared views, the import maps a read-write alias, and GuestArenaMapAlias moves every resident run in the block into shared views. Since #9159 those views are compared rather than armed, so each sampled texture in them takes a full revalidation walk with byte compares at its draws. Such a block is now remembered with the failed blocks and imported in smaller runs: the private memory is imported directly and stays on the write watch, and an alias covers only the shared views. In Grand Theft Auto V (PPSA04264) the textures that take those walks drop from 125-163 to 38, and the frame p50 drops from 73.7 to 71.2 ms.

  • A block whose pages are all shared views is still joined into one alias import.
  • A single registered range that mixes private memory with shared views is still imported whole through one alias, which demotes its private part as before; a new debt entry says so.
  • The check runs only where a new import is made, so lookups of existing imports do no extra work.
  • #14976 changes the alias call this check returns before; the two merge cleanly.

Tested

Windows 11 Pro 26300, Radeon RX 7900 XTX (AMD Software 26.10.1), Ryzen 7 7800X3D, Release, MinGW-w64 GCC 15.2.

agc_driver_host_import_windows gains three cases:

  • a resident range beside a shared one in one block must be imported on its own and stay private;
  • two neighbouring shared ranges must stay one import;
  • a range that mixes both must still be imported whole.

Reverting the check, or dropping either of its two conditions, makes the test fail.

  • The focused host import, settle, alias and write-tracking tests run with the validation layer on both arms: 66 on main and 66 on this branch pass, with no VUID- lines and no missing layer.

Grand Theft Auto V, Performance graphics mode, gameplay of the opening level, same machine, warm caches:

frame p50 / p90 presents in 30 s FPS over the run, two runs textures compared, per 10 s draw commit
main 9090972b7e 73.7 / 77.0 ms 408 13.98, 14.46 125-163 37.6-39.9 us
this PR 71.2 / 74.7 ms 420 14.49, 14.64, 14.65 38 34.3 us

The last two columns come from separate APS5_PROFILE_DRAW=1 runs (the [rescache] revalidate collect refusals and the [draw] pipelined commit time). Two of the three FPS runs of this PR used an earlier revision of the branch with the same code; only the debt entry moved since.

{"commit":"9090972b7e91","dirty":false,"env":{"APS5_LOG_TIMESTAMPS":"1","APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"150:30"},"gpu":"AMD Radeon RX 7900 XTX","driver":"AMD proprietary driver 26.10.1 (LLPC)","os":"Windows 10.0.26300","cpu":"AMD Ryzen 7 7800X3D 8-Core Processor","cpu_threads":16,"memory_mib":31860,"title_id":"PPSA04264","title":"Grand Theft Auto V","content_version":"01.011.001","resolution":"3840x2160","window":{"spec":"seconds 150:30","first_present":3874,"ms":30033.654},"presents":408,"frame_ms":{"p50":73.666,"p90":76.967,"p99":79.540,"max":81.630},"gpu_busy_ms_per_present":31.673,"worker_busy_pct":{"queue worker 0x0":98.160},"top_phases_ms_per_frame":{"Driver.Packet":68.959,"Graphics.Draw":57.773,"Driver.Packet.draw":54.694,"Driver.Draw":54.380,"Graphics.Draw.draw_and_resource_release":53.413,"Driver.Draw.draw_enqueued":32.593,"Driver.Draw.shader_compile_and_link":16.823,"Shader.DrawStage":12.177},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":8.338,"events_lost":683195,"totals_full":false},"draw committer":{"events_full_after_s":17.189,"events_lost":195932,"totals_full":false}},"trace":"aps5-trace-9090972b7e91-29412.json.gz"}
{"commit":"8490638cc30a","dirty":false,"env":{"APS5_LOG_TIMESTAMPS":"1","APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"150:30"},"gpu":"AMD Radeon RX 7900 XTX","driver":"AMD proprietary driver 26.10.1 (LLPC)","os":"Windows 10.0.26300","cpu":"AMD Ryzen 7 7800X3D 8-Core Processor","cpu_threads":16,"memory_mib":31860,"title_id":"PPSA04264","title":"Grand Theft Auto V","content_version":"01.011.001","resolution":"3840x2160","window":{"spec":"seconds 150:30","first_present":3884,"ms":30044.492},"presents":420,"frame_ms":{"p50":71.242,"p90":74.660,"p99":78.224,"max":80.897},"gpu_busy_ms_per_present":30.743,"worker_busy_pct":{"queue worker 0x0":98.119},"top_phases_ms_per_frame":{"Driver.Packet":67.021,"Graphics.Draw":55.498,"Driver.Packet.draw":53.714,"Driver.Draw":53.395,"Graphics.Draw.draw_and_resource_release":51.116,"Driver.Draw.draw_enqueued":31.607,"Driver.Draw.shader_compile_and_link":16.924,"Shader.DrawStage":12.222},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":8.507,"events_lost":664702,"totals_full":false},"draw committer":{"events_full_after_s":17.823,"events_lost":179147,"totals_full":false}},"trace":"aps5-trace-8490638cc30a-42684.json.gz"}

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: AMD Radeon RX 7900 XTX, AMD Software 26.10.1 (32.0.32015.7029), Windows 11 Pro 26300
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5136705522 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15454). Originally posted by [Nesyth](https://github.com/Nesyth) on 2026-11-03T11:48:58Z. --- ### What On Windows, neighbouring registered ranges are imported as one block. When the block holds writable private direct memory beside shared views, the import maps a read-write alias, and `GuestArenaMapAlias` moves every resident run in the block into shared views. Since #9159 those views are compared rather than armed, so each sampled texture in them takes a full revalidation walk with byte compares at its draws. Such a block is now remembered with the failed blocks and imported in smaller runs: the private memory is imported directly and stays on the write watch, and an alias covers only the shared views. In Grand Theft Auto V (PPSA04264) the textures that take those walks drop from 125-163 to 38, and the frame p50 drops from 73.7 to 71.2 ms. - A block whose pages are all shared views is still joined into one alias import. - A single registered range that mixes private memory with shared views is still imported whole through one alias, which demotes its private part as before; a new debt entry says so. - The check runs only where a new import is made, so lookups of existing imports do no extra work. - #14976 changes the alias call this check returns before; the two merge cleanly. ### Tested Windows 11 Pro 26300, Radeon RX 7900 XTX (AMD Software 26.10.1), Ryzen 7 7800X3D, Release, MinGW-w64 GCC 15.2. `agc_driver_host_import_windows` gains three cases: - a resident range beside a shared one in one block must be imported on its own and stay private; - two neighbouring shared ranges must stay one import; - a range that mixes both must still be imported whole. Reverting the check, or dropping either of its two conditions, makes the test fail. - The focused host import, settle, alias and write-tracking tests run with the validation layer on both arms: 66 on `main` and 66 on this branch pass, with no `VUID-` lines and no missing layer. Grand Theft Auto V, Performance graphics mode, gameplay of the opening level, same machine, warm caches: | | frame p50 / p90 | presents in 30 s | FPS over the run, two runs | textures compared, per 10 s | draw commit | |---|---|---|---|---|---| | `main` `9090972b7e` | 73.7 / 77.0 ms | 408 | 13.98, 14.46 | 125-163 | 37.6-39.9 us | | this PR | 71.2 / 74.7 ms | 420 | 14.49, 14.64, 14.65 | 38 | 34.3 us | The last two columns come from separate `APS5_PROFILE_DRAW=1` runs (the `[rescache] revalidate` collect refusals and the `[draw] pipelined` commit time). Two of the three FPS runs of this PR used an earlier revision of the branch with the same code; only the debt entry moved since. ```json {"commit":"9090972b7e91","dirty":false,"env":{"APS5_LOG_TIMESTAMPS":"1","APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"150:30"},"gpu":"AMD Radeon RX 7900 XTX","driver":"AMD proprietary driver 26.10.1 (LLPC)","os":"Windows 10.0.26300","cpu":"AMD Ryzen 7 7800X3D 8-Core Processor","cpu_threads":16,"memory_mib":31860,"title_id":"PPSA04264","title":"Grand Theft Auto V","content_version":"01.011.001","resolution":"3840x2160","window":{"spec":"seconds 150:30","first_present":3874,"ms":30033.654},"presents":408,"frame_ms":{"p50":73.666,"p90":76.967,"p99":79.540,"max":81.630},"gpu_busy_ms_per_present":31.673,"worker_busy_pct":{"queue worker 0x0":98.160},"top_phases_ms_per_frame":{"Driver.Packet":68.959,"Graphics.Draw":57.773,"Driver.Packet.draw":54.694,"Driver.Draw":54.380,"Graphics.Draw.draw_and_resource_release":53.413,"Driver.Draw.draw_enqueued":32.593,"Driver.Draw.shader_compile_and_link":16.823,"Shader.DrawStage":12.177},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":8.338,"events_lost":683195,"totals_full":false},"draw committer":{"events_full_after_s":17.189,"events_lost":195932,"totals_full":false}},"trace":"aps5-trace-9090972b7e91-29412.json.gz"} {"commit":"8490638cc30a","dirty":false,"env":{"APS5_LOG_TIMESTAMPS":"1","APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"150:30"},"gpu":"AMD Radeon RX 7900 XTX","driver":"AMD proprietary driver 26.10.1 (LLPC)","os":"Windows 10.0.26300","cpu":"AMD Ryzen 7 7800X3D 8-Core Processor","cpu_threads":16,"memory_mib":31860,"title_id":"PPSA04264","title":"Grand Theft Auto V","content_version":"01.011.001","resolution":"3840x2160","window":{"spec":"seconds 150:30","first_present":3884,"ms":30044.492},"presents":420,"frame_ms":{"p50":71.242,"p90":74.660,"p99":78.224,"max":80.897},"gpu_busy_ms_per_present":30.743,"worker_busy_pct":{"queue worker 0x0":98.119},"top_phases_ms_per_frame":{"Driver.Packet":67.021,"Graphics.Draw":55.498,"Driver.Packet.draw":53.714,"Driver.Draw":53.395,"Graphics.Draw.draw_and_resource_release":51.116,"Driver.Draw.draw_enqueued":31.607,"Driver.Draw.shader_compile_and_link":16.924,"Shader.DrawStage":12.222},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":8.507,"events_lost":664702,"totals_full":false},"draw committer":{"events_full_after_s":17.823,"events_lost":179147,"totals_full":false}},"trace":"aps5-trace-8490638cc30a-42684.json.gz"} ``` ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: AMD Radeon RX 7900 XTX, AMD Software 26.10.1 (32.0.32015.7029), Windows 11 Pro 26300 - [x] AI-assisted: yes
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!15454
No description provided.