perf(agc): join a buffer bound from inside a range larger than the import window into the small ranges after it #15658

Merged
mrfelek merged 2 commits from upstream-pr/15658 into main 2026-11-14 11:49:29 +00:00
mrfelek commented 2026-11-04 00:42:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mrfelek on 2026-11-04T00:42:38Z.


What

A buffer bound from inside a registered range that is larger than the import window, running into the ranges after it, had no import:

  • importRunBounds returns the containing range alone, because it is larger than the window, so runCovers fails at its end and importAccess returns before importAllocation.
  • joinedRun (the importJoined pre-pass in UploadFinish) joins only when every range in the run is larger than the window, or when the binding starts at the run's base.

So such a buffer was copied on the CPU on every bind, and the copy waited for any GPU work pending over it.

joinedRun now also returns the run when its first range is larger than the window and the ranges after it are, together, no larger than the window. The part a join adds beyond the large range stays within one window. The host-imports entry in docs/dev/debt/libSceAgcDriver.md gains one clause for this case.

PPSA22408 (Hot Wheels Infinite Rush) hits this every frame in its garage menu. A dispatch's build reads a 648,000-byte buffer that starts inside a 12 MiB range and ends 123 to 189 KiB into the 2 MiB range after it (same flags, no gap), while GPU work is pending over it. The CPU copy in GuestBufferMemory::copyRegion, under UploadFinish, waited about 16 ms per frame in a pending-write sync.

Overlap: #5372 changes the same line of joinedRun (run.bytes <= window). The two conditions are disjoint: #5372's holds only when the whole run fits the window, this one only when the first range alone is larger than it. #5372 also adds a cap in importJoined that refuses a widened run larger than the window unless the old rule gave the same run from its first range's start, and that cap would refuse this case. If #5372 lands first, I'll rebase this and exempt the case from the cap. No other open PR changes joinedRun (#6197, #6918, #7457 and #10442 touch the import code around it).

Tested

Unit test (agc_driver_graphics, BdaResources.cpp, next to importJoinTests): 128 KiB window, a 192 KiB range followed by 64 KiB ranges.

  • A 32-byte bind from 16 bytes before the end of the large range into the next range must be one import over both ranges (base at the large range, 256 KiB), with nothing copied, and a second bind must reuse it.
  • The same bind across more than a window of small ranges must stay copied, with no import over it.
  • Negative control: with only the new joinedRun line removed, the suite fails at a buffer bound from inside a range larger than the import window into the small range after it was not imported over both.

Focused suites: agc_driver_graphics, agc_driver_recorder and agc_driver_host_import_{at_map,proofs,teardown,windows}, on main 1c8c0efc8c and on this head, both GPUs below.

  • With VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ANYPS5_REQUIRE_VULKAN=1 and ANYPS5_NO_SHADER_CACHE=1: 6 of 6 pass on each side, no VUID- messages on either side, no missing-layer line.
  • Plain runs: 3 of 3 for each suite on each side.
  • tools/check_conventions.py --base origin/main passes.

PPSA22408 garage menu: Linux 7.3, Ryzen 9 5950X, RTX 3080 Ti (NVIDIA 615.71.09), 3840x2160, the game's default settings, the same input route into the garage each run.

  • Both trees are main 1c8c0efc8c + #11346 (4143f1b4a0), the stack this title's garage runs on. This PR does not depend on #11346. A = a14e471883, B = d8ccb992ac (A + this head).
  • Timing runs: A B A B, garage window from 125 s, APS5_TRACE_SUMMARY_EVERY=10 and APS5_PROFILE_GPU=1.
A B
presents per second 6.70 / 6.63 7.55 / 7.52 +13 %
frame p50 149.6 / 150.9 ms 132.5 / 133.0 ms
GPU busy per present 86.5 / 87.4 ms 85.6 / 86.3 ms
  • Trace runs: one per tree, APS5_TRACE_SECONDS=150:10 APS5_TRACE_EVENTS=2097152, no other APS5_TRACE_* / APS5_PROFILE_*. The game's output went to a file (headless run).

Traces: A · B

Summary lines (aps5-summary.jsonl)
{"commit":"a14e47188381","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"16384","APS5_PAD_INPUT_FILE":"<path>","APS5_STAGING_POOL_MIB":"768","APS5_TRACE_EVENTS":"2097152","APS5_TRACE_SECONDS":"150:10","APS5_UNIT_SHADOW_MIB":"512"},"gpu":"NVIDIA GeForce RTX 3080 Ti","driver":"NVIDIA 615.71.09","os":"Linux 7.3.0-10-generic","cpu":"AMD Ryzen 9 5950X 16-Core Processor","cpu_threads":32,"memory_mib":32003,"title_id":"PPSA22408","title":"HOT WHEELS™️ Infinite Rush","content_version":"01.000.000","resolution":"3840x2160","window":{"spec":"seconds 150:10","first_present":3277,"ms":10052.912},"presents":68,"frame_ms":{"p50":148.113,"p90":153.721,"p99":158.861,"max":158.861},"gpu_busy_ms_per_present":86.475,"worker_busy_pct":{"queue worker 0x0":85.813,"queue worker 0x20":99.333},"top_phases_ms_per_frame":{"Driver.Packet":273.652,"Driver.Packet.memory_wait":139.167,"Driver.Packet.dispatch":78.634,"Driver.Dispatch":77.597,"Vulkan.Dispatch":56.027,"Vulkan.Dispatch.shader_resources":51.354,"Resources.Complete":43.033,"Graphics.Draw":28.389},"trace_dropped":false,"trace":"aps5-trace-a14e47188381-886846.json.gz"}
{"commit":"d8ccb992ace6","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"16384","APS5_PAD_INPUT_FILE":"<path>","APS5_STAGING_POOL_MIB":"768","APS5_TRACE_EVENTS":"2097152","APS5_TRACE_SECONDS":"150:10","APS5_UNIT_SHADOW_MIB":"512"},"gpu":"NVIDIA GeForce RTX 3080 Ti","driver":"NVIDIA 615.71.09","os":"Linux 7.3.0-10-generic","cpu":"AMD Ryzen 9 5950X 16-Core Processor","cpu_threads":32,"memory_mib":32003,"title_id":"PPSA22408","title":"HOT WHEELS™️ Infinite Rush","content_version":"01.000.000","resolution":"3840x2160","window":{"spec":"seconds 150:10","first_present":3335,"ms":10030.690},"presents":77,"frame_ms":{"p50":130.724,"p90":134.807,"p99":141.593,"max":141.593},"gpu_busy_ms_per_present":85.052,"worker_busy_pct":{"queue worker 0x0":83.832,"queue worker 0x20":99.429},"top_phases_ms_per_frame":{"Driver.Packet":238.669,"Driver.Packet.memory_wait":122.670,"Driver.Packet.dispatch":44.233,"Driver.Dispatch":43.236,"Driver.Packet.pipeline_drain":41.314,"Graphics.Draw":27.302,"Vulkan.Dispatch":23.331,"Graphics.Draw.draw_and_resource_release":23.253},"trace_dropped":false,"trace":"aps5-trace-d8ccb992ace6-893942.json.gz"}
trace_digest.py
**seconds 150:10** from present 3277: 68 presents, frame p50 148.1 / p90 153.7 / p99 158.9 / max 158.9 ms, GPU busy 86.5 ms per present
NVIDIA GeForce RTX 3080 Ti, NVIDIA 615.71.09, Linux 7.3.0-10-generic, 3840x2160, commit a14e47188381, dropped: no

```json
{"commit":"a14e47188381","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"16384","APS5_PAD_INPUT_FILE":"<path>","APS5_STAGING_POOL_MIB":"768","APS5_TRACE_EVENTS":"2097152","APS5_TRACE_SECONDS":"150:10","APS5_UNIT_SHADOW_MIB":"512"},"gpu":"NVIDIA GeForce RTX 3080 Ti","driver":"NVIDIA 615.71.09","os":"Linux 7.3.0-10-generic","cpu":"AMD Ryzen 9 5950X 16-Core Processor","cpu_threads":32,"memory_mib":32003,"title_id":"PPSA22408","title":"HOT WHEELS\u2122\ufe0f Infinite Rush","content_version":"01.000.000","resolution":"3840x2160","window":{"spec":"seconds 150:10","first_present":3277,"ms":10052.912},"presents":68,"frame_ms":{"p50":148.113,"p90":153.721,"p99":158.861,"max":158.861},"gpu_busy_ms_per_present":86.475,"worker_busy_pct":{"queue worker 0x0":85.813,"queue worker 0x20":99.333},"top_phases_ms_per_frame":{"Driver.Packet":273.652,"Driver.Packet.memory_wait":139.167,"Driver.Packet.dispatch":78.634,"Driver.Dispatch":77.597,"Vulkan.Dispatch":56.027,"Vulkan.Dispatch.shader_resources":51.354,"Resources.Complete":43.033,"Graphics.Draw":28.389},"trace_dropped":false,"trace":"aps5-trace-a14e47188381-886846.json.gz"}
```

**Slowest frames** (largest slices inside each, inclusive)

- present 3308: 158.9 ms at 4569 ms: Driver.Packet (queue worker 0x20) 158.3, Driver.Packet.memory_wait (queue worker 0x20) 144.2, Driver.Packet (queue worker 0x0) 132.1, batch (gpu) 88.3
- present 3323: 156.2 ms at 6795 ms: Driver.Packet (queue worker 0x20) 155.8, Driver.Packet.memory_wait (queue worker 0x20) 141.1, Driver.Packet (queue worker 0x0) 128.9, batch (gpu) 85.9
- present 3332: 154.6 ms at 8131 ms: Driver.Packet (queue worker 0x20) 154.1, Driver.Packet.memory_wait (queue worker 0x20) 140.0, Driver.Packet (queue worker 0x0) 125.7, batch (gpu) 87.3
- present 3338: 154.5 ms at 9017 ms: Driver.Packet (queue worker 0x20) 154.0, Driver.Packet.memory_wait (queue worker 0x20) 139.9, Driver.Packet (queue worker 0x0) 126.2, batch (gpu) 88.5
- present 3286: 154.1 ms at 1327 ms: Driver.Packet (queue worker 0x20) 153.7, Driver.Packet.memory_wait (queue worker 0x20) 142.9, Driver.Packet (queue worker 0x0) 126.5, batch (gpu) 89.1

**Persistent spikes** (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame)

- present 3308: 158.9 ms at 4569 ms, persistence 21.4 ms
- present 3279: 153.9 ms at 293 ms, persistence 16.4 ms
- present 3286: 154.1 ms at 1327 ms, persistence 15.0 ms
- present 3323: 156.2 ms at 6795 ms, persistence 14.4 ms
- present 3338: 154.5 ms at 9017 ms, persistence 14.1 ms
- present 3293: 153.6 ms at 2358 ms, persistence 12.9 ms
- present 3332: 154.6 ms at 8131 ms, persistence 12.7 ms
- present 3301: 153.6 ms at 3534 ms, persistence 11.6 ms
- present 3316: 153.6 ms at 5761 ms, persistence 11.6 ms
- present 3305: 153.1 ms at 4124 ms, persistence 10.4 ms

**Threads** (ms per frame)

| thread | busy | wait | untraced | in slices < 20 us | largest |
|---|---|---|---|---|---|
| queue worker 0x0 | 112.9 (76 %) | 7.6 (5 %) | 27.3 | 38.2 | Driver.Packet 120.6, Recorder.Submit 0.0 |
| draw committer | 25.9 (18 %) | 0.6 (0 %) | 121.3 | 3.4 | Graphics.Draw 24.9, Recorder.Sync 0.8 |
| queue worker 0x20 | 4.8 (3 %) | 142.0 (96 %) | 1.1 | 2.9 | Driver.Packet 146.4, Driver.EndSubmission 0.0 |
| presenter | 0.5 (0 %) | 0.0 (0 %) | 147.3 | 0.1 | VideoOut.Flip 0.5, Driver.Present 0.0 |
| gpu | 86.4 (58 %) | 0.0 (0 %) | 61.4 | 0.0 | batch 86.4 |

**Largest slices** (ms per frame, inclusive, all threads): Driver.Packet 267.0, Driver.Packet.memory_wait 139.2, batch 86.4, Driver.Packet.dispatch 78.4, Driver.Dispatch 77.4, Vulkan.Dispatch 54.8, Vulkan.Dispatch.shader_resources 49.2, Resources.Complete 42.2, Graphics.Draw 27.7, Recorder.Sync 25.1

**Longest waits**

- Driver.Packet.memory_wait (queue worker 0x20) 74.5 ms at 7924 ms, present 3330
- Driver.Packet.memory_wait (queue worker 0x20) 72.8 ms at 1426 ms, present 3286
- Driver.Packet.memory_wait (queue worker 0x20) 72.6 ms at 9417 ms, present 3340
- Driver.Packet.memory_wait (queue worker 0x20) 72.5 ms at 7780 ms, present 3329
- Driver.Packet.memory_wait (queue worker 0x20) 72.5 ms at 2742 ms, present 3295
- Driver.Packet.memory_wait (queue worker 0x20) 71.7 ms at 3038 ms, present 3297
- Driver.Packet.memory_wait (queue worker 0x20) 71.7 ms at 4668 ms, present 3308
- Driver.Packet.memory_wait (queue worker 0x20) 71.3 ms at 2599 ms, present 3294
- Driver.Packet.memory_wait (queue worker 0x20) 71.2 ms at 90 ms, present 3277
- Driver.Packet.memory_wait (queue worker 0x20) 71.2 ms at 234 ms, present 3278

**Largest GPU batches** (GPU ranges inside, and the CPU slices that recorded each, inclusive)

- batch 105: 20.0 ms at 174 ms, present 3278: GPU no ranges; recorded by Graphics.Draw (draw committer) 1.9, Graphics.Draw.draw_and_resource_release (draw committer) 1.7
- batch 2406: 19.9 ms at 4162 ms, present 3305: GPU no ranges; recorded by Graphics.Draw (draw committer) 1.8, Graphics.Draw.draw_and_resource_release (draw committer) 1.6, Recorder.Reap (draw committer) 0.0
- batch 2754: 19.8 ms at 4766 ms, present 3309: GPU no ranges; recorded by Graphics.Draw (draw committer) 2.1, Graphics.Draw.draw_and_resource_release (draw committer) 1.8, GpuMutex.wait.label (draw committer) 0.0, Recorder.Reap (draw committer) 0.0
- batch 1139: 19.8 ms at 1950 ms, present 3290: GPU no ranges; recorded by Graphics.Draw (draw committer) 2.2, Graphics.Draw.draw_and_resource_release (draw committer) 2.0, Recorder.Submit (draw committer) 0.0, Recorder.Reap (draw committer) 0.0
- batch 2156: 19.3 ms at 3717 ms, present 3302: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 0.3, Driver.Packet.dispatch (queue worker 0x0) 0.3, Driver.Dispatch (queue worker 0x0) 0.2, Vulkan.Dispatch (queue worker 0x0) 0.1
**seconds 150:10** from present 3335: 77 presents, frame p50 130.7 / p90 134.8 / p99 141.6 / max 141.6 ms, GPU busy 85.1 ms per present
NVIDIA GeForce RTX 3080 Ti, NVIDIA 615.71.09, Linux 7.3.0-10-generic, 3840x2160, commit d8ccb992ace6, dropped: no

```json
{"commit":"d8ccb992ace6","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"16384","APS5_PAD_INPUT_FILE":"<path>","APS5_STAGING_POOL_MIB":"768","APS5_TRACE_EVENTS":"2097152","APS5_TRACE_SECONDS":"150:10","APS5_UNIT_SHADOW_MIB":"512"},"gpu":"NVIDIA GeForce RTX 3080 Ti","driver":"NVIDIA 615.71.09","os":"Linux 7.3.0-10-generic","cpu":"AMD Ryzen 9 5950X 16-Core Processor","cpu_threads":32,"memory_mib":32003,"title_id":"PPSA22408","title":"HOT WHEELS\u2122\ufe0f Infinite Rush","content_version":"01.000.000","resolution":"3840x2160","window":{"spec":"seconds 150:10","first_present":3335,"ms":10030.69},"presents":77,"frame_ms":{"p50":130.724,"p90":134.807,"p99":141.593,"max":141.593},"gpu_busy_ms_per_present":85.052,"worker_busy_pct":{"queue worker 0x0":83.832,"queue worker 0x20":99.429},"top_phases_ms_per_frame":{"Driver.Packet":238.669,"Driver.Packet.memory_wait":122.67,"Driver.Packet.dispatch":44.233,"Driver.Dispatch":43.236,"Driver.Packet.pipeline_drain":41.314,"Graphics.Draw":27.302,"Vulkan.Dispatch":23.331,"Graphics.Draw.draw_and_resource_release":23.253},"trace_dropped":false,"trace":"aps5-trace-d8ccb992ace6-893942.json.gz"}
```

**Slowest frames** (largest slices inside each, inclusive)

- present 3347: 141.6 ms at 1561 ms: Driver.Packet (queue worker 0x20) 141.1, Driver.Packet.memory_wait (queue worker 0x20) 130.1, Driver.Packet (queue worker 0x0) 110.3, batch (gpu) 87.8
- present 3390: 141.3 ms at 7159 ms: Driver.Packet (queue worker 0x20) 140.9, Driver.Packet.memory_wait (queue worker 0x20) 125.9, Driver.Packet (queue worker 0x0) 114.0, batch (gpu) 85.3
- present 3378: 136.2 ms at 5598 ms: Driver.Packet (queue worker 0x20) 135.6, Driver.Packet.memory_wait (queue worker 0x20) 124.0, Driver.Packet (queue worker 0x0) 108.3, batch (gpu) 87.5
- present 3372: 135.8 ms at 4830 ms: Driver.Packet (queue worker 0x20) 135.3, Driver.Packet.memory_wait (queue worker 0x20) 119.3, Driver.Packet (queue worker 0x0) 108.3, batch (gpu) 84.9
- present 3355: 135.7 ms at 2606 ms: Driver.Packet (queue worker 0x20) 135.2, Driver.Packet.memory_wait (queue worker 0x20) 124.1, Driver.Packet (queue worker 0x0) 108.3, batch (gpu) 86.1

**Persistent spikes** (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame)

- present 3347: 141.6 ms at 1561 ms, persistence 19.2 ms
- present 3390: 141.3 ms at 7159 ms, persistence 18.9 ms
- present 3378: 136.2 ms at 5598 ms, persistence 13.6 ms
- present 3372: 135.8 ms at 4830 ms, persistence 13.3 ms
- present 3355: 135.7 ms at 2606 ms, persistence 13.2 ms
- present 3337: 134.8 ms at 268 ms, persistence 11.8 ms
- present 3405: 134.2 ms at 9116 ms, persistence 10.6 ms
- present 3341: 132.5 ms at 789 ms, persistence 9.2 ms
- present 3384: 134.4 ms at 6376 ms, persistence 9.1 ms
- present 3374: 132.1 ms at 5089 ms, persistence 9.1 ms

**Threads** (ms per frame)

| thread | busy | wait | untraced | in slices < 20 us | largest |
|---|---|---|---|---|---|
| queue worker 0x0 | 98.7 (76 %) | 4.2 (3 %) | 27.4 | 38.5 | Driver.Packet 102.8, Recorder.Submit 0.0 |
| draw committer | 31.6 (24 %) | 0.5 (0 %) | 98.2 | 3.3 | Graphics.Draw 23.8, Recorder.Sync 7.5 |
| queue worker 0x20 | 4.5 (3 %) | 124.6 (96 %) | 1.1 | 2.9 | Driver.Packet 129.1, Driver.EndSubmission 0.0 |
| presenter | 0.5 (0 %) | 0.0 (0 %) | 129.7 | 0.1 | VideoOut.Flip 0.5, Driver.Present 0.0 |
| gpu | 85.1 (65 %) | 0.0 (0 %) | 45.2 | 0.0 | batch 85.1 |

**Largest slices** (ms per frame, inclusive, all threads): Driver.Packet 231.9, Driver.Packet.memory_wait 122.7, batch 85.1, Driver.Packet.dispatch 44.0, Driver.Dispatch 43.0, Driver.Packet.pipeline_drain 40.0, Graphics.Draw 26.6, Graphics.Draw.draw_and_resource_release 22.4, Vulkan.Dispatch 22.2, Driver.Packet.draw 20.6

**Longest waits**

- Driver.Packet.memory_wait (queue worker 0x20) 55.3 ms at 628 ms, present 3339
- Driver.Packet.memory_wait (queue worker 0x20) 54.5 ms at 7194 ms, present 3390
- Driver.Packet.memory_wait (queue worker 0x20) 54.1 ms at 7123 ms, present 3389
- Driver.Packet.memory_wait (queue worker 0x20) 53.7 ms at 3480 ms, present 3361
- Driver.Packet.memory_wait (queue worker 0x20) 53.7 ms at 5958 ms, present 3380
- Driver.Packet.memory_wait (queue worker 0x20) 53.6 ms at 1797 ms, present 3348
- Driver.Packet.memory_wait (queue worker 0x20) 53.2 ms at 1148 ms, present 3343
- Driver.Packet.memory_wait (queue worker 0x20) 53.2 ms at 1596 ms, present 3347
- Driver.Packet.memory_wait (queue worker 0x20) 52.6 ms at 1401 ms, present 3345
- Driver.Packet.memory_wait (queue worker 0x20) 52.6 ms at 754 ms, present 3340

**Largest GPU batches** (GPU ranges inside, and the CPU slices that recorded each, inclusive)

- batch 5836: 20.3 ms at 9284 ms, present 3406: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 0.7, Driver.Packet.dispatch (queue worker 0x0) 0.7, Driver.Dispatch (queue worker 0x0) 0.6, Vulkan.Dispatch (queue worker 0x0) 0.2
- batch 989: 20.3 ms at 1601 ms, present 3347: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 0.5, Driver.Packet.dispatch (queue worker 0x0) 0.4, Driver.Dispatch (queue worker 0x0) 0.4, Vulkan.Dispatch (queue worker 0x0) 0.2
- batch 2694: 19.9 ms at 4342 ms, present 3368: GPU no ranges; recorded by Graphics.Draw (draw committer) 1.9, Graphics.Draw.draw_and_resource_release (draw committer) 1.6, Graphics.Draw.index_upload (draw committer) 0.0, Recorder.Submit (draw committer) 0.0
- batch 2135: 19.8 ms at 3420 ms, present 3361: GPU no ranges; recorded by Graphics.Draw (draw committer) 1.6, Graphics.Draw.draw_and_resource_release (draw committer) 1.4
- batch 1315: 19.7 ms at 2124 ms, present 3351: GPU no ranges; recorded by Graphics.Draw (draw committer) 1.3, Graphics.Draw.draw_and_resource_release (draw committer) 1.1, GpuMutex.wait.label (draw committer) 0.0

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 RTX 3080 Ti, driver 615.71.09, Ubuntu 26.10 (Linux 7.3); AMD Radeon 780M, RADV Mesa 26.0.8, Ubuntu 26.04.1 (Linux 7.0)
  • AI-assisted: yes

AI-assisted.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5146837877 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15658). Originally posted by [mrfelek](https://github.com/mrfelek) on 2026-11-04T00:42:38Z. --- ### What A buffer bound from inside a registered range that is larger than the import window, running into the ranges after it, had no import: - `importRunBounds` returns the containing range alone, because it is larger than the window, so `runCovers` fails at its end and `importAccess` returns before `importAllocation`. - `joinedRun` (the `importJoined` pre-pass in `UploadFinish`) joins only when every range in the run is larger than the window, or when the binding starts at the run's base. So such a buffer was copied on the CPU on every bind, and the copy waited for any GPU work pending over it. `joinedRun` now also returns the run when its first range is larger than the window and the ranges after it are, together, no larger than the window. The part a join adds beyond the large range stays within one window. The host-imports entry in `docs/dev/debt/libSceAgcDriver.md` gains one clause for this case. PPSA22408 (Hot Wheels Infinite Rush) hits this every frame in its garage menu. A dispatch's build reads a 648,000-byte buffer that starts inside a 12 MiB range and ends 123 to 189 KiB into the 2 MiB range after it (same flags, no gap), while GPU work is pending over it. The CPU copy in `GuestBufferMemory::copyRegion`, under `UploadFinish`, waited about 16 ms per frame in a pending-write sync. **Overlap:** #5372 changes the same line of `joinedRun` (`run.bytes <= window`). The two conditions are disjoint: #5372's holds only when the whole run fits the window, this one only when the first range alone is larger than it. #5372 also adds a cap in `importJoined` that refuses a widened run larger than the window unless the old rule gave the same run from its first range's start, and that cap would refuse this case. If #5372 lands first, I'll rebase this and exempt the case from the cap. No other open PR changes `joinedRun` (#6197, #6918, #7457 and #10442 touch the import code around it). ### Tested **Unit test** (`agc_driver_graphics`, `BdaResources.cpp`, next to `importJoinTests`): 128 KiB window, a 192 KiB range followed by 64 KiB ranges. - A 32-byte bind from 16 bytes before the end of the large range into the next range must be one import over both ranges (base at the large range, 256 KiB), with nothing copied, and a second bind must reuse it. - The same bind across more than a window of small ranges must stay copied, with no import over it. - Negative control: with only the new `joinedRun` line removed, the suite fails at `a buffer bound from inside a range larger than the import window into the small range after it was not imported over both`. **Focused suites**: `agc_driver_graphics`, `agc_driver_recorder` and `agc_driver_host_import_{at_map,proofs,teardown,windows}`, on `main` `1c8c0efc8c` and on this head, both GPUs below. - With `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, `ANYPS5_REQUIRE_VULKAN=1` and `ANYPS5_NO_SHADER_CACHE=1`: 6 of 6 pass on each side, no `VUID-` messages on either side, no missing-layer line. - Plain runs: 3 of 3 for each suite on each side. - `tools/check_conventions.py --base origin/main` passes. **PPSA22408 garage menu**: Linux 7.3, Ryzen 9 5950X, RTX 3080 Ti (NVIDIA 615.71.09), 3840x2160, the game's default settings, the same input route into the garage each run. - Both trees are `main` `1c8c0efc8c` + #11346 (`4143f1b4a0`), the stack this title's garage runs on. This PR does not depend on #11346. A = `a14e471883`, B = `d8ccb992ac` (A + this head). - Timing runs: A B A B, garage window from 125 s, `APS5_TRACE_SUMMARY_EVERY=10` and `APS5_PROFILE_GPU=1`. | | A | B | | |---|---|---|---| | presents per second | 6.70 / 6.63 | 7.55 / 7.52 | **+13 %** | | frame p50 | 149.6 / 150.9 ms | 132.5 / 133.0 ms | | | GPU busy per present | 86.5 / 87.4 ms | 85.6 / 86.3 ms | | - Trace runs: one per tree, `APS5_TRACE_SECONDS=150:10 APS5_TRACE_EVENTS=2097152`, no other `APS5_TRACE_*` / `APS5_PROFILE_*`. The game's output went to a file (headless run). Traces: [A](https://github.com/mrfelek/AnyPS5/releases/download/perf-15658-traces/aps5-trace-a14e47188381-886846.json.gz) · [B](https://github.com/mrfelek/AnyPS5/releases/download/perf-15658-traces/aps5-trace-d8ccb992ace6-893942.json.gz) <details><summary>Summary lines (aps5-summary.jsonl)</summary> ``` {"commit":"a14e47188381","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"16384","APS5_PAD_INPUT_FILE":"<path>","APS5_STAGING_POOL_MIB":"768","APS5_TRACE_EVENTS":"2097152","APS5_TRACE_SECONDS":"150:10","APS5_UNIT_SHADOW_MIB":"512"},"gpu":"NVIDIA GeForce RTX 3080 Ti","driver":"NVIDIA 615.71.09","os":"Linux 7.3.0-10-generic","cpu":"AMD Ryzen 9 5950X 16-Core Processor","cpu_threads":32,"memory_mib":32003,"title_id":"PPSA22408","title":"HOT WHEELS™️ Infinite Rush","content_version":"01.000.000","resolution":"3840x2160","window":{"spec":"seconds 150:10","first_present":3277,"ms":10052.912},"presents":68,"frame_ms":{"p50":148.113,"p90":153.721,"p99":158.861,"max":158.861},"gpu_busy_ms_per_present":86.475,"worker_busy_pct":{"queue worker 0x0":85.813,"queue worker 0x20":99.333},"top_phases_ms_per_frame":{"Driver.Packet":273.652,"Driver.Packet.memory_wait":139.167,"Driver.Packet.dispatch":78.634,"Driver.Dispatch":77.597,"Vulkan.Dispatch":56.027,"Vulkan.Dispatch.shader_resources":51.354,"Resources.Complete":43.033,"Graphics.Draw":28.389},"trace_dropped":false,"trace":"aps5-trace-a14e47188381-886846.json.gz"} {"commit":"d8ccb992ace6","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"16384","APS5_PAD_INPUT_FILE":"<path>","APS5_STAGING_POOL_MIB":"768","APS5_TRACE_EVENTS":"2097152","APS5_TRACE_SECONDS":"150:10","APS5_UNIT_SHADOW_MIB":"512"},"gpu":"NVIDIA GeForce RTX 3080 Ti","driver":"NVIDIA 615.71.09","os":"Linux 7.3.0-10-generic","cpu":"AMD Ryzen 9 5950X 16-Core Processor","cpu_threads":32,"memory_mib":32003,"title_id":"PPSA22408","title":"HOT WHEELS™️ Infinite Rush","content_version":"01.000.000","resolution":"3840x2160","window":{"spec":"seconds 150:10","first_present":3335,"ms":10030.690},"presents":77,"frame_ms":{"p50":130.724,"p90":134.807,"p99":141.593,"max":141.593},"gpu_busy_ms_per_present":85.052,"worker_busy_pct":{"queue worker 0x0":83.832,"queue worker 0x20":99.429},"top_phases_ms_per_frame":{"Driver.Packet":238.669,"Driver.Packet.memory_wait":122.670,"Driver.Packet.dispatch":44.233,"Driver.Dispatch":43.236,"Driver.Packet.pipeline_drain":41.314,"Graphics.Draw":27.302,"Vulkan.Dispatch":23.331,"Graphics.Draw.draw_and_resource_release":23.253},"trace_dropped":false,"trace":"aps5-trace-d8ccb992ace6-893942.json.gz"} ``` </details> <details><summary>trace_digest.py</summary> ```` **seconds 150:10** from present 3277: 68 presents, frame p50 148.1 / p90 153.7 / p99 158.9 / max 158.9 ms, GPU busy 86.5 ms per present NVIDIA GeForce RTX 3080 Ti, NVIDIA 615.71.09, Linux 7.3.0-10-generic, 3840x2160, commit a14e47188381, dropped: no ```json {"commit":"a14e47188381","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"16384","APS5_PAD_INPUT_FILE":"<path>","APS5_STAGING_POOL_MIB":"768","APS5_TRACE_EVENTS":"2097152","APS5_TRACE_SECONDS":"150:10","APS5_UNIT_SHADOW_MIB":"512"},"gpu":"NVIDIA GeForce RTX 3080 Ti","driver":"NVIDIA 615.71.09","os":"Linux 7.3.0-10-generic","cpu":"AMD Ryzen 9 5950X 16-Core Processor","cpu_threads":32,"memory_mib":32003,"title_id":"PPSA22408","title":"HOT WHEELS\u2122\ufe0f Infinite Rush","content_version":"01.000.000","resolution":"3840x2160","window":{"spec":"seconds 150:10","first_present":3277,"ms":10052.912},"presents":68,"frame_ms":{"p50":148.113,"p90":153.721,"p99":158.861,"max":158.861},"gpu_busy_ms_per_present":86.475,"worker_busy_pct":{"queue worker 0x0":85.813,"queue worker 0x20":99.333},"top_phases_ms_per_frame":{"Driver.Packet":273.652,"Driver.Packet.memory_wait":139.167,"Driver.Packet.dispatch":78.634,"Driver.Dispatch":77.597,"Vulkan.Dispatch":56.027,"Vulkan.Dispatch.shader_resources":51.354,"Resources.Complete":43.033,"Graphics.Draw":28.389},"trace_dropped":false,"trace":"aps5-trace-a14e47188381-886846.json.gz"} ``` **Slowest frames** (largest slices inside each, inclusive) - present 3308: 158.9 ms at 4569 ms: Driver.Packet (queue worker 0x20) 158.3, Driver.Packet.memory_wait (queue worker 0x20) 144.2, Driver.Packet (queue worker 0x0) 132.1, batch (gpu) 88.3 - present 3323: 156.2 ms at 6795 ms: Driver.Packet (queue worker 0x20) 155.8, Driver.Packet.memory_wait (queue worker 0x20) 141.1, Driver.Packet (queue worker 0x0) 128.9, batch (gpu) 85.9 - present 3332: 154.6 ms at 8131 ms: Driver.Packet (queue worker 0x20) 154.1, Driver.Packet.memory_wait (queue worker 0x20) 140.0, Driver.Packet (queue worker 0x0) 125.7, batch (gpu) 87.3 - present 3338: 154.5 ms at 9017 ms: Driver.Packet (queue worker 0x20) 154.0, Driver.Packet.memory_wait (queue worker 0x20) 139.9, Driver.Packet (queue worker 0x0) 126.2, batch (gpu) 88.5 - present 3286: 154.1 ms at 1327 ms: Driver.Packet (queue worker 0x20) 153.7, Driver.Packet.memory_wait (queue worker 0x20) 142.9, Driver.Packet (queue worker 0x0) 126.5, batch (gpu) 89.1 **Persistent spikes** (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame) - present 3308: 158.9 ms at 4569 ms, persistence 21.4 ms - present 3279: 153.9 ms at 293 ms, persistence 16.4 ms - present 3286: 154.1 ms at 1327 ms, persistence 15.0 ms - present 3323: 156.2 ms at 6795 ms, persistence 14.4 ms - present 3338: 154.5 ms at 9017 ms, persistence 14.1 ms - present 3293: 153.6 ms at 2358 ms, persistence 12.9 ms - present 3332: 154.6 ms at 8131 ms, persistence 12.7 ms - present 3301: 153.6 ms at 3534 ms, persistence 11.6 ms - present 3316: 153.6 ms at 5761 ms, persistence 11.6 ms - present 3305: 153.1 ms at 4124 ms, persistence 10.4 ms **Threads** (ms per frame) | thread | busy | wait | untraced | in slices < 20 us | largest | |---|---|---|---|---|---| | queue worker 0x0 | 112.9 (76 %) | 7.6 (5 %) | 27.3 | 38.2 | Driver.Packet 120.6, Recorder.Submit 0.0 | | draw committer | 25.9 (18 %) | 0.6 (0 %) | 121.3 | 3.4 | Graphics.Draw 24.9, Recorder.Sync 0.8 | | queue worker 0x20 | 4.8 (3 %) | 142.0 (96 %) | 1.1 | 2.9 | Driver.Packet 146.4, Driver.EndSubmission 0.0 | | presenter | 0.5 (0 %) | 0.0 (0 %) | 147.3 | 0.1 | VideoOut.Flip 0.5, Driver.Present 0.0 | | gpu | 86.4 (58 %) | 0.0 (0 %) | 61.4 | 0.0 | batch 86.4 | **Largest slices** (ms per frame, inclusive, all threads): Driver.Packet 267.0, Driver.Packet.memory_wait 139.2, batch 86.4, Driver.Packet.dispatch 78.4, Driver.Dispatch 77.4, Vulkan.Dispatch 54.8, Vulkan.Dispatch.shader_resources 49.2, Resources.Complete 42.2, Graphics.Draw 27.7, Recorder.Sync 25.1 **Longest waits** - Driver.Packet.memory_wait (queue worker 0x20) 74.5 ms at 7924 ms, present 3330 - Driver.Packet.memory_wait (queue worker 0x20) 72.8 ms at 1426 ms, present 3286 - Driver.Packet.memory_wait (queue worker 0x20) 72.6 ms at 9417 ms, present 3340 - Driver.Packet.memory_wait (queue worker 0x20) 72.5 ms at 7780 ms, present 3329 - Driver.Packet.memory_wait (queue worker 0x20) 72.5 ms at 2742 ms, present 3295 - Driver.Packet.memory_wait (queue worker 0x20) 71.7 ms at 3038 ms, present 3297 - Driver.Packet.memory_wait (queue worker 0x20) 71.7 ms at 4668 ms, present 3308 - Driver.Packet.memory_wait (queue worker 0x20) 71.3 ms at 2599 ms, present 3294 - Driver.Packet.memory_wait (queue worker 0x20) 71.2 ms at 90 ms, present 3277 - Driver.Packet.memory_wait (queue worker 0x20) 71.2 ms at 234 ms, present 3278 **Largest GPU batches** (GPU ranges inside, and the CPU slices that recorded each, inclusive) - batch 105: 20.0 ms at 174 ms, present 3278: GPU no ranges; recorded by Graphics.Draw (draw committer) 1.9, Graphics.Draw.draw_and_resource_release (draw committer) 1.7 - batch 2406: 19.9 ms at 4162 ms, present 3305: GPU no ranges; recorded by Graphics.Draw (draw committer) 1.8, Graphics.Draw.draw_and_resource_release (draw committer) 1.6, Recorder.Reap (draw committer) 0.0 - batch 2754: 19.8 ms at 4766 ms, present 3309: GPU no ranges; recorded by Graphics.Draw (draw committer) 2.1, Graphics.Draw.draw_and_resource_release (draw committer) 1.8, GpuMutex.wait.label (draw committer) 0.0, Recorder.Reap (draw committer) 0.0 - batch 1139: 19.8 ms at 1950 ms, present 3290: GPU no ranges; recorded by Graphics.Draw (draw committer) 2.2, Graphics.Draw.draw_and_resource_release (draw committer) 2.0, Recorder.Submit (draw committer) 0.0, Recorder.Reap (draw committer) 0.0 - batch 2156: 19.3 ms at 3717 ms, present 3302: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 0.3, Driver.Packet.dispatch (queue worker 0x0) 0.3, Driver.Dispatch (queue worker 0x0) 0.2, Vulkan.Dispatch (queue worker 0x0) 0.1 ```` ```` **seconds 150:10** from present 3335: 77 presents, frame p50 130.7 / p90 134.8 / p99 141.6 / max 141.6 ms, GPU busy 85.1 ms per present NVIDIA GeForce RTX 3080 Ti, NVIDIA 615.71.09, Linux 7.3.0-10-generic, 3840x2160, commit d8ccb992ace6, dropped: no ```json {"commit":"d8ccb992ace6","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"16384","APS5_PAD_INPUT_FILE":"<path>","APS5_STAGING_POOL_MIB":"768","APS5_TRACE_EVENTS":"2097152","APS5_TRACE_SECONDS":"150:10","APS5_UNIT_SHADOW_MIB":"512"},"gpu":"NVIDIA GeForce RTX 3080 Ti","driver":"NVIDIA 615.71.09","os":"Linux 7.3.0-10-generic","cpu":"AMD Ryzen 9 5950X 16-Core Processor","cpu_threads":32,"memory_mib":32003,"title_id":"PPSA22408","title":"HOT WHEELS\u2122\ufe0f Infinite Rush","content_version":"01.000.000","resolution":"3840x2160","window":{"spec":"seconds 150:10","first_present":3335,"ms":10030.69},"presents":77,"frame_ms":{"p50":130.724,"p90":134.807,"p99":141.593,"max":141.593},"gpu_busy_ms_per_present":85.052,"worker_busy_pct":{"queue worker 0x0":83.832,"queue worker 0x20":99.429},"top_phases_ms_per_frame":{"Driver.Packet":238.669,"Driver.Packet.memory_wait":122.67,"Driver.Packet.dispatch":44.233,"Driver.Dispatch":43.236,"Driver.Packet.pipeline_drain":41.314,"Graphics.Draw":27.302,"Vulkan.Dispatch":23.331,"Graphics.Draw.draw_and_resource_release":23.253},"trace_dropped":false,"trace":"aps5-trace-d8ccb992ace6-893942.json.gz"} ``` **Slowest frames** (largest slices inside each, inclusive) - present 3347: 141.6 ms at 1561 ms: Driver.Packet (queue worker 0x20) 141.1, Driver.Packet.memory_wait (queue worker 0x20) 130.1, Driver.Packet (queue worker 0x0) 110.3, batch (gpu) 87.8 - present 3390: 141.3 ms at 7159 ms: Driver.Packet (queue worker 0x20) 140.9, Driver.Packet.memory_wait (queue worker 0x20) 125.9, Driver.Packet (queue worker 0x0) 114.0, batch (gpu) 85.3 - present 3378: 136.2 ms at 5598 ms: Driver.Packet (queue worker 0x20) 135.6, Driver.Packet.memory_wait (queue worker 0x20) 124.0, Driver.Packet (queue worker 0x0) 108.3, batch (gpu) 87.5 - present 3372: 135.8 ms at 4830 ms: Driver.Packet (queue worker 0x20) 135.3, Driver.Packet.memory_wait (queue worker 0x20) 119.3, Driver.Packet (queue worker 0x0) 108.3, batch (gpu) 84.9 - present 3355: 135.7 ms at 2606 ms: Driver.Packet (queue worker 0x20) 135.2, Driver.Packet.memory_wait (queue worker 0x20) 124.1, Driver.Packet (queue worker 0x0) 108.3, batch (gpu) 86.1 **Persistent spikes** (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame) - present 3347: 141.6 ms at 1561 ms, persistence 19.2 ms - present 3390: 141.3 ms at 7159 ms, persistence 18.9 ms - present 3378: 136.2 ms at 5598 ms, persistence 13.6 ms - present 3372: 135.8 ms at 4830 ms, persistence 13.3 ms - present 3355: 135.7 ms at 2606 ms, persistence 13.2 ms - present 3337: 134.8 ms at 268 ms, persistence 11.8 ms - present 3405: 134.2 ms at 9116 ms, persistence 10.6 ms - present 3341: 132.5 ms at 789 ms, persistence 9.2 ms - present 3384: 134.4 ms at 6376 ms, persistence 9.1 ms - present 3374: 132.1 ms at 5089 ms, persistence 9.1 ms **Threads** (ms per frame) | thread | busy | wait | untraced | in slices < 20 us | largest | |---|---|---|---|---|---| | queue worker 0x0 | 98.7 (76 %) | 4.2 (3 %) | 27.4 | 38.5 | Driver.Packet 102.8, Recorder.Submit 0.0 | | draw committer | 31.6 (24 %) | 0.5 (0 %) | 98.2 | 3.3 | Graphics.Draw 23.8, Recorder.Sync 7.5 | | queue worker 0x20 | 4.5 (3 %) | 124.6 (96 %) | 1.1 | 2.9 | Driver.Packet 129.1, Driver.EndSubmission 0.0 | | presenter | 0.5 (0 %) | 0.0 (0 %) | 129.7 | 0.1 | VideoOut.Flip 0.5, Driver.Present 0.0 | | gpu | 85.1 (65 %) | 0.0 (0 %) | 45.2 | 0.0 | batch 85.1 | **Largest slices** (ms per frame, inclusive, all threads): Driver.Packet 231.9, Driver.Packet.memory_wait 122.7, batch 85.1, Driver.Packet.dispatch 44.0, Driver.Dispatch 43.0, Driver.Packet.pipeline_drain 40.0, Graphics.Draw 26.6, Graphics.Draw.draw_and_resource_release 22.4, Vulkan.Dispatch 22.2, Driver.Packet.draw 20.6 **Longest waits** - Driver.Packet.memory_wait (queue worker 0x20) 55.3 ms at 628 ms, present 3339 - Driver.Packet.memory_wait (queue worker 0x20) 54.5 ms at 7194 ms, present 3390 - Driver.Packet.memory_wait (queue worker 0x20) 54.1 ms at 7123 ms, present 3389 - Driver.Packet.memory_wait (queue worker 0x20) 53.7 ms at 3480 ms, present 3361 - Driver.Packet.memory_wait (queue worker 0x20) 53.7 ms at 5958 ms, present 3380 - Driver.Packet.memory_wait (queue worker 0x20) 53.6 ms at 1797 ms, present 3348 - Driver.Packet.memory_wait (queue worker 0x20) 53.2 ms at 1148 ms, present 3343 - Driver.Packet.memory_wait (queue worker 0x20) 53.2 ms at 1596 ms, present 3347 - Driver.Packet.memory_wait (queue worker 0x20) 52.6 ms at 1401 ms, present 3345 - Driver.Packet.memory_wait (queue worker 0x20) 52.6 ms at 754 ms, present 3340 **Largest GPU batches** (GPU ranges inside, and the CPU slices that recorded each, inclusive) - batch 5836: 20.3 ms at 9284 ms, present 3406: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 0.7, Driver.Packet.dispatch (queue worker 0x0) 0.7, Driver.Dispatch (queue worker 0x0) 0.6, Vulkan.Dispatch (queue worker 0x0) 0.2 - batch 989: 20.3 ms at 1601 ms, present 3347: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 0.5, Driver.Packet.dispatch (queue worker 0x0) 0.4, Driver.Dispatch (queue worker 0x0) 0.4, Vulkan.Dispatch (queue worker 0x0) 0.2 - batch 2694: 19.9 ms at 4342 ms, present 3368: GPU no ranges; recorded by Graphics.Draw (draw committer) 1.9, Graphics.Draw.draw_and_resource_release (draw committer) 1.6, Graphics.Draw.index_upload (draw committer) 0.0, Recorder.Submit (draw committer) 0.0 - batch 2135: 19.8 ms at 3420 ms, present 3361: GPU no ranges; recorded by Graphics.Draw (draw committer) 1.6, Graphics.Draw.draw_and_resource_release (draw committer) 1.4 - batch 1315: 19.7 ms at 2124 ms, present 3351: GPU no ranges; recorded by Graphics.Draw (draw committer) 1.3, Graphics.Draw.draw_and_resource_release (draw committer) 1.1, GpuMutex.wait.label (draw committer) 0.0 ```` </details> ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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: NVIDIA RTX 3080 Ti, driver 615.71.09, Ubuntu 26.10 (Linux 7.3); AMD Radeon 780M, RADV Mesa 26.0.8, Ubuntu 26.04.1 (Linux 7.0) - [x] AI-assisted: yes AI-assisted.
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!15658
No description provided.