UFC 6 profiling: tracking draft (not for merge) #18515

Closed
nicolasabosch wants to merge 32 commits from upstream-pr/18515 into main
nicolasabosch commented 2026-11-11 19:40:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by nicolasabosch on 2026-11-11T19:40:29Z.


What

This is a tracking draft and is not for merge. It collects the changes from profiling UFC 6 (PPSA23566). Each commit is meant to become its own PR against current main. The findings are in the game bring-up discussion #5996.

The commits that change the frame rate:

  • b900b496ae: wakes a dormant queue worker 0 when an end-of-pipe interrupt completion becomes pending. Before, the interrupt waited out the 50 ms idle quiet period.
  • 83c25d94dc and 40a1e17983: a storage image's CPU-path upload is recorded into the open batch instead of a private SubmitAndWait, and reuses the batch's upload scratch.
  • f9be6cfa9c: a block-unit storage image that crosses two registered 8 MiB import windows is detiled per segment from each range's import, instead of ReadCommitted of the whole image. Before, that meant a shadow publish and a fence wait.
  • 85c5020032: a buffer range that crosses import windows is joined into one import and bound in place. Before, it was copied on the CPU while holding the GPU mutex, which held the mutex about 96 % of the time in gameplay. APS5_NO_JOIN_STRADDLE=1 disables it.
  • de25727963: the fallback for 85c5020032 when a join is refused: one GPU copy per window segment. On its own it measured slower in gameplay (7 vs 9 presents / 10 s), because the copy crosses PCIe twice on every dispatch. APS5_NO_SEGMENT_BUFFER=1 disables it.
  • c87be26205: a compute shader's multi-dword buffer store, or 8-byte typed store, is emitted as one u64 or uvec4 store through aliased storage-buffer views when alignment, bounds, swizzle and base checks pass at run time; otherwise it falls back to the per-byte or per-dword path. Before, an 8-byte typed store was 8 byte stores through buffers_u8. GPU time per gameplay frame drops from about 330 ms to about 170 ms. Needs shaderInt64 and a 16-byte minStorageBufferOffsetAlignment. APS5_NO_WIDE_BUFFER_STORES=1 disables it.
  • 8fe0288d40 and 74814867a4: keep read-only and GPU-written joined ranges resident in VRAM, with write-back bounded to one batch. No gain in gameplay (24–27 vs 27–28). The game records about 130 batches per flip, and VRAM on the 8 GB card is at its budget, so most ranges are refused. Both will be dropped before the split. APS5_NO_BUFFER_RESIDENCY=1 and APS5_NO_WRITTEN_RESIDENCY=1 disable them.

Error fixes, so the game gets error codes instead of exceptions or silence:

  • db2ab89042: sceNetConnect returns ETIMEDOUT on a connect timeout.
  • 7bf1e43bec: a failed sceHttpSendRequest is reported through errno and an epoll event.
  • a277e54495: the NP reachability callback receives the unavailable state.
  • 3e0a0b139f: VideoRecording Open and QueryMemSize return an error.
  • bc75cacf31: APR read failures are reported.

Smaller changes:

  • a04dbb15e4, ba8d3b1932, 76c57009a5, 8bb46325ed: zero-timeout sema and event-flag waits, the QueryPerformanceCounter-to-nanoseconds conversion, clock_gettime and sema signal.
  • 08baa1842f, 736c4db246, 54efb302e3: waits.
  • 0b382e3507: draw relocation is learned when the entry is inserted.
  • ecddfb081a: detiler retirement.
  • 6c2f59b517: shader cache prefetch.

Opt-in switches:

  • APS5_ALIAS_OVERWRITE (f4e64606f1) no longer gains anything after f9be6cfa9c.
  • APS5_PRESENT_REPORT (25ecf1a335) is a local measuring aid, because APS5_PROFILE_DRAW disables the draw finisher.
  • 7fea13a510 is reverted by 7407b9a61f because it measured 5 % slower.

Tested

All numbers are on Windows 11 with an i9-14900HX and an RTX 4070 Laptop, base dd7c8de5de, APS5_LAZY_SHADER_PREPARE=1.

UFC 6 title screen, presents per 10 s, from the [present] report over the steady state of 90 s runs:

Build Presents / 10 s
main 84–117
b900b496ae 257–271
40a1e17983 ~286
f9be6cfa9c ~455
  • The image was checked from game-window captures.
  • These are not trace_digest summaries yet, so they are not valid perf evidence under the Performance report form. Each split PR will carry its own.
  • Tests: ctest -j 32 -R "^(agc_|guest_)" passes 3441 of 3441 at b507ecf34a.
  • The focused tests for f9be6cfa9c ran with VK_LAYER_KHRONOS_validation, ANYPS5_NO_SHADER_CACHE=1 and ANYPS5_REQUIRE_VULKAN=1, with no VUID- errors. That comparison was not run on main.
    UFC 6 gameplay (practice mode), presents per 10 s from APS5_PRESENT_REPORT, played by hand up to gameplay:
Build Presents / 10 s GPU busy per frame
b507ecf34a ~9 ~330 ms
de25727963 (segment copies) ~7 ~1,300 ms
85c5020032 (joined import in place) 27–28 ~290 ms
8fe0288d40 (read-only VRAM residency) 24–26 ~330 ms
74814867a4 (GPU-written VRAM residency) 26–27 ~330 ms
c87be26205 (wide buffer stores, warm shader cache) 43–44 ~170 ms
  • At 85c5020032, about 2,400 straddling ranges (about 40 GiB) per 10 s are served in place, with 0 segment copies and 0 CPU fallbacks. Joined imports stop being created once gameplay starts.
  • APS5_PROFILE_GPU=1 in gameplay: about 80 % of GPU time is compute dispatches of about 2 ms each that bind these 20–46 MiB buffers. Copies and barriers are about 1.5 s per 10 s.
  • Host memory over PCIe is not the cause: a profiled run with these buffers resident in VRAM had the same dispatch times. The cost was in the recompiled shaders: per-byte 8-byte typed stores, per-dword vector stores, atomics outside the staging path, and NaN emulation. c87be26205 fixes the stores.
  • Remaining top shaders after c87be26205: one at about 26 ms per frame that has an atomic store and a read on the same binding with no barrier, so it cannot take the spanned-wave path; and one at about 18 ms per frame dominated by atomics.
  • Forcing past the VRAM budget for written residency made gameplay worse (20–25), from about 8 GiB of write-back per 10 s. Compiling with fast float math (no NaN emulation) gave 37–39, below c87be26205, so it is not included.
  • One of the two profiled gameplay runs at 85c5020032 ended in a device fault ([device-fault] result 5) after about 10 s of gameplay; the other did not. Not reproduced since.
  • The image at c87be26205 was checked by hand in gameplay.
  • Full suite at c87be26205: ctest -j 32 passes 3451 of 3453. The 2 failures are guest_raise_short_sleep and guest_raise_short_sleep_without_wake, which time out at 30 s under parallel load and pass alone in 0.2 s. BufferWideStores adds 43 execution cases.

Checklist

  • Based on current main; no other open PR implements the same functions (based on dd7c8de5de, not rebased)
  • One topic per PR; follow-ups go in a new PR (tracking draft; it will be split)
  • 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 (PPSA23566 gameplay now runs at about 4.3 FPS)
  • GPUs tested: NVIDIA GeForce RTX 4070 Laptop GPU, driver 616.92, Windows 11 Pro 26300
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5265728716 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18515). Originally posted by [nicolasabosch](https://github.com/nicolasabosch) on 2026-11-11T19:40:29Z. --- ### What This is a tracking draft and is not for merge. It collects the changes from profiling UFC 6 (PPSA23566). Each commit is meant to become its own PR against current `main`. The findings are in the game bring-up discussion #5996. The commits that change the frame rate: - **b900b496ae:** wakes a dormant queue worker 0 when an end-of-pipe interrupt completion becomes pending. Before, the interrupt waited out the 50 ms idle quiet period. - **83c25d94dc and 40a1e17983:** a storage image's CPU-path upload is recorded into the open batch instead of a private `SubmitAndWait`, and reuses the batch's upload scratch. - **f9be6cfa9c:** a block-unit storage image that crosses two registered 8 MiB import windows is detiled per segment from each range's import, instead of `ReadCommitted` of the whole image. Before, that meant a shadow publish and a fence wait. - **85c5020032:** a buffer range that crosses import windows is joined into one import and bound in place. Before, it was copied on the CPU while holding the GPU mutex, which held the mutex about 96 % of the time in gameplay. `APS5_NO_JOIN_STRADDLE=1` disables it. - **de25727963:** the fallback for 85c5020032 when a join is refused: one GPU copy per window segment. On its own it measured slower in gameplay (7 vs 9 presents / 10 s), because the copy crosses PCIe twice on every dispatch. `APS5_NO_SEGMENT_BUFFER=1` disables it. - **c87be26205:** a compute shader's multi-dword buffer store, or 8-byte typed store, is emitted as one `u64` or `uvec4` store through aliased storage-buffer views when alignment, bounds, swizzle and base checks pass at run time; otherwise it falls back to the per-byte or per-dword path. Before, an 8-byte typed store was 8 byte stores through `buffers_u8`. GPU time per gameplay frame drops from about 330 ms to about 170 ms. Needs `shaderInt64` and a 16-byte `minStorageBufferOffsetAlignment`. `APS5_NO_WIDE_BUFFER_STORES=1` disables it. - **8fe0288d40 and 74814867a4:** keep read-only and GPU-written joined ranges resident in VRAM, with write-back bounded to one batch. No gain in gameplay (24–27 vs 27–28). The game records about 130 batches per flip, and VRAM on the 8 GB card is at its budget, so most ranges are refused. Both will be dropped before the split. `APS5_NO_BUFFER_RESIDENCY=1` and `APS5_NO_WRITTEN_RESIDENCY=1` disable them. Error fixes, so the game gets error codes instead of exceptions or silence: - **db2ab89042:** `sceNetConnect` returns ETIMEDOUT on a connect timeout. - **7bf1e43bec:** a failed `sceHttpSendRequest` is reported through errno and an epoll event. - **a277e54495:** the NP reachability callback receives the unavailable state. - **3e0a0b139f:** VideoRecording `Open` and `QueryMemSize` return an error. - **bc75cacf31:** APR read failures are reported. Smaller changes: - `a04dbb15e4`, `ba8d3b1932`, `76c57009a5`, `8bb46325ed`: zero-timeout sema and event-flag waits, the QueryPerformanceCounter-to-nanoseconds conversion, clock_gettime and sema signal. - `08baa1842f`, `736c4db246`, `54efb302e3`: waits. - `0b382e3507`: draw relocation is learned when the entry is inserted. - `ecddfb081a`: detiler retirement. - `6c2f59b517`: shader cache prefetch. Opt-in switches: - `APS5_ALIAS_OVERWRITE` (f4e64606f1) no longer gains anything after f9be6cfa9c. - `APS5_PRESENT_REPORT` (25ecf1a335) is a local measuring aid, because `APS5_PROFILE_DRAW` disables the draw finisher. - 7fea13a510 is reverted by 7407b9a61f because it measured 5 % slower. ### Tested All numbers are on Windows 11 with an i9-14900HX and an RTX 4070 Laptop, base dd7c8de5de, `APS5_LAZY_SHADER_PREPARE=1`. UFC 6 title screen, presents per 10 s, from the `[present]` report over the steady state of 90 s runs: | Build | Presents / 10 s | |---|---| | main | 84–117 | | b900b496ae | 257–271 | | 40a1e17983 | ~286 | | f9be6cfa9c | ~455 | - The image was checked from game-window captures. - These are not `trace_digest` summaries yet, so they are not valid perf evidence under the Performance report form. Each split PR will carry its own. - Tests: `ctest -j 32 -R "^(agc_|guest_)"` passes 3441 of 3441 at b507ecf34a. - The focused tests for f9be6cfa9c ran with `VK_LAYER_KHRONOS_validation`, `ANYPS5_NO_SHADER_CACHE=1` and `ANYPS5_REQUIRE_VULKAN=1`, with no `VUID-` errors. That comparison was not run on main. UFC 6 gameplay (practice mode), presents per 10 s from `APS5_PRESENT_REPORT`, played by hand up to gameplay: | Build | Presents / 10 s | GPU busy per frame | |---|---|---| | b507ecf34a | ~9 | ~330 ms | | de25727963 (segment copies) | ~7 | ~1,300 ms | | 85c5020032 (joined import in place) | 27–28 | ~290 ms | | 8fe0288d40 (read-only VRAM residency) | 24–26 | ~330 ms | | 74814867a4 (GPU-written VRAM residency) | 26–27 | ~330 ms | | c87be26205 (wide buffer stores, warm shader cache) | 43–44 | ~170 ms | - At 85c5020032, about 2,400 straddling ranges (about 40 GiB) per 10 s are served in place, with 0 segment copies and 0 CPU fallbacks. Joined imports stop being created once gameplay starts. - `APS5_PROFILE_GPU=1` in gameplay: about 80 % of GPU time is compute dispatches of about 2 ms each that bind these 20–46 MiB buffers. Copies and barriers are about 1.5 s per 10 s. - Host memory over PCIe is not the cause: a profiled run with these buffers resident in VRAM had the same dispatch times. The cost was in the recompiled shaders: per-byte 8-byte typed stores, per-dword vector stores, atomics outside the staging path, and NaN emulation. c87be26205 fixes the stores. - Remaining top shaders after c87be26205: one at about 26 ms per frame that has an atomic store and a read on the same binding with no barrier, so it cannot take the spanned-wave path; and one at about 18 ms per frame dominated by atomics. - Forcing past the VRAM budget for written residency made gameplay worse (20–25), from about 8 GiB of write-back per 10 s. Compiling with fast float math (no NaN emulation) gave 37–39, below c87be26205, so it is not included. - One of the two profiled gameplay runs at 85c5020032 ended in a device fault (`[device-fault] result 5`) after about 10 s of gameplay; the other did not. Not reproduced since. - The image at c87be26205 was checked by hand in gameplay. - Full suite at c87be26205: `ctest -j 32` passes 3451 of 3453. The 2 failures are `guest_raise_short_sleep` and `guest_raise_short_sleep_without_wake`, which time out at 30 s under parallel load and pass alone in 0.2 s. `BufferWideStores` adds 43 execution cases. ### Checklist - [ ] Based on current `main`; no other open PR implements the same functions (based on dd7c8de5de, not rebased) - [ ] One topic per PR; follow-ups go in a new PR (tracking draft; it will be split) - [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 (PPSA23566 gameplay now runs at about 4.3 FPS) - [x] GPUs tested: NVIDIA GeForce RTX 4070 Laptop GPU, driver 616.92, Windows 11 Pro 26300 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-11-16 21:23:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-16T21:23:56Z.

Review: COMMENTED


Reviewed — comments

This tracking draft spans many independent subsystems, and the review is incomplete because multiple changed files were not read in full and no checks were run.

What I ran

Head reviewed: c87be26205f607ae7ffbb3b5ba2f4bef2caa4fff. I read the prepared description, commits, manifest, and diff; I did not run commands or tests.

Results

Check Result Note
Prepared change materials passed Description, commits, manifest, and diff read
Runtime code review not run Several changed files remain unread
Tests not run No test commands executed

Findings

Blocking

None identified in the portions reviewed.

Non-blocking

  • The title and description explicitly characterize this as a tracking draft not for merge, with commits intended to become separate PRs. Split the topics before proposing this as a mergeable change.
  • sceHttpWaitRequest now copies queued events into nbev (core/libs/prx/libSceHttp/Export.cpp:5467), but the changed code shown does not validate nbev when events are queued. A null or invalid output pointer could fault; confirm the API's pointer validation contract and guard it as needed.

Not verified

No tests, builds, or prechecks were run. Full text was read for core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp, core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp, and core/shader/recompiler/SpirvBackend/src/SpirvRuntimeBuffer.cpp; changed hunks were read from review/diff.patch. The other changed files were not read in full, including files marked included: false in review/manifest.json (notably shader recompiler, texture, kernel timing, and test files). The description's reported test and performance results were not independently verified.

To get this to a good state

Nothing is required. Optional: split the tracking draft into topic-focused PRs and verify sceHttpWaitRequest output-pointer handling against its API contract.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5927966611 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18515#pullrequestreview-5927966611). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-16T21:23:56Z. **Review:** COMMENTED --- # Reviewed — comments This tracking draft spans many independent subsystems, and the review is incomplete because multiple changed files were not read in full and no checks were run. ## What I ran Head reviewed: `c87be26205f607ae7ffbb3b5ba2f4bef2caa4fff`. I read the prepared description, commits, manifest, and diff; I did not run commands or tests. ## Results | Check | Result | Note | |---|---|---| | Prepared change materials | passed | Description, commits, manifest, and diff read | | Runtime code review | not run | Several changed files remain unread | | Tests | not run | No test commands executed | ## Findings ### Blocking None identified in the portions reviewed. ### Non-blocking - The title and description explicitly characterize this as a tracking draft not for merge, with commits intended to become separate PRs. Split the topics before proposing this as a mergeable change. - `sceHttpWaitRequest` now copies queued events into `nbev` (`core/libs/prx/libSceHttp/Export.cpp:5467`), but the changed code shown does not validate `nbev` when events are queued. A null or invalid output pointer could fault; confirm the API's pointer validation contract and guard it as needed. ## Not verified No tests, builds, or prechecks were run. Full text was read for `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp`, `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp`, and `core/shader/recompiler/SpirvBackend/src/SpirvRuntimeBuffer.cpp`; changed hunks were read from `review/diff.patch`. The other changed files were not read in full, including files marked `included: false` in `review/manifest.json` (notably shader recompiler, texture, kernel timing, and test files). The description's reported test and performance results were not independently verified. ## To get this to a good state Nothing is required. Optional: split the tracking draft into topic-focused PRs and verify `sceHttpWaitRequest` output-pointer handling against its API contract.

Pull request closed

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!18515
No description provided.