Repository navigation
perf(agc): APS5_PRESYNC_CPU_WRITES waits for a dispatch build's pending CPU-side stores before the GPU mutex - #14163
milescoviello wants to merge 1 commit into
Conversation
…ng CPU-side stores before the GPU mutex A dispatch whose buffers cover a completion label or a copied write-back still pending syncs in stage B under the GPU mutex (UploadFinish -> CompletePendingCpuWrites -> Recorder::Sync), and every other queue waits behind it. With the switch, stage A lists the build's buffer ranges for its unlocked pre-sync, which keeps only the ranges CpuWriteSyncNeeded (the test of CompletePendingCpuWrites without its sync) accepts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — changes requested
The implementation and focused correctness evidence look reviewable, but the PR is titled perf and does not yet include the repository-required matched performance report.
What I ran
Reviewed head 611cec067881b4cf50cee06317064c171d2c983e, based on main 05ff2857e6391c0bdc672b73b5dfa573537134fc; the merge preview against that base was clean. Environment: Debian Linux x86_64, Python 3.11.2, GCC 12.2.0. I did not build or compile locally.
git diff --check 05ff2857e6391c0bdc672b73b5dfa573537134fc...611cec067881b4cf50cee06317064c171d2c983e
python3 tools/check_conventions.py --base 05ff2857e6391c0bdc672b73b5dfa573537134fc --head 611cec067881b4cf50cee06317064c171d2c983e
python3 tools/pr_stack_check.py 14163 --repo boykopovar/AnyPS5 --output-dir /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-14163-611cec067881/stack
git merge-tree --write-tree refs/review/anyps5-main refs/review/14163
python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14163 --no-negative-controlsResults
| Check | Result |
|---|---|
| Diff check and conventions | Passed. The conventions command printed All conventions checks passed. |
| Current-base merge preview and dependency check | Clean; no declared dependency. |
| Source and test inspection | The changed pre-sync path filters CPU-write ranges with CpuWriteSyncNeeded; the new test covers an in-range label and a label outside the copy source. The CMake test-fragment glob includes the new registration fragment. |
| Focused runtime tests | The description reports 11/11 focused CTests in each of three Linux runs; Windows reports 3/3 agc_driver_cpu_write_presync and 3/3 agc_driver_dcc_key_presync on both main and this head. These are author-reported, not runs I performed. |
| Hosted CI | At the snapshot, eligibility, intake, labels, conventions, report and library-portability checks were queued. |
| Precheck helper execution | The overall precheck exited 1 because its isolated snapshot lacked workspace-only pr_abi_audit.py and pr_test_quality.py. No export ABI change is in this diff; I inspected test registration directly. This is a tooling availability issue, not a reported code-check failure. |
Unedited local check output
All conventions checks passed.
/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-14163-611cec067881/stack/stack-report.md
/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-14163-611cec067881/stack/stack-report.json
a05df87521e132727f760c3b5f5010219f790dfd
Negative control
No local negative control was run; the focused C++ tests require built binaries, and I did not build during this initial review.
Findings
Blocking
- Required performance evidence is absent. The description says the reported 300-second runs changed other switches and that alternating off/on runs are still underway. Those preliminary figures do not isolate this change. Before this
perfPR is ready for approval, add themainand PRaps5-summary.jsonllines from the same title, scene, and machine, attach both traces, and includetools/trace_digest.pyoutput as required by the repository's performance report guidance.
Non-blocking
- None found in the source and test-registration inspection performed for this initial review.
Sources
- Contribution rule for
perfPRs, pinned to the reviewed base - Performance report fields and capture protocol, pinned to the reviewed base
- Pre-sync implementation at this head
- Focused CPU-write pre-sync test at this head
Not verified
No local build or CTest run; no independent GPU, title, or console measurements. The paired performance captures and their digest are not present yet. The hosted checks were still queued at the snapshot.
To get this to a good state
Add the matched baseline/change summaries, traces, and digest to the PR description. I will re-run the same relevant checks on the updated head.
|
This pull request is labeled |
|
@MarcZX10 thanks for the review. Agreed, the runs in the description don't isolate the change. The paired captures are underway now on the same Ghost of Tsushima save, scene and machine. Plain
That gives 2 runs per side, interleaved (base, PR, base, PR), each with AI-assisted: yes (Claude Code) |
|
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.
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.
|
|
@milescoviello, the current PPSA02225 figures still compare runs where other switches changed, and the description says the paired captures are pending. Please add matched baseline/change Since plain main cannot reach this scene, please identify the exact same prerequisite stack in both arms and isolate this change, with immutable commit IDs and the source compositions recorded. Alternating this switch on one build is useful mechanism evidence; please keep it distinct from the required baseline/change commit comparison. The new fixture checks completion-label overlap and copied output, but its counters alone would not catch moving the timeline wait under |
|
Ran on AMD RDNA 4 with this PR (
AI-assisted: yes (Claude Code) |
|
@MarcZX10 here are the paired Ghost of Tsushima (PPSA02225) runs. They don't show a gain, so I'm closing this PR. Setup: same save, same scene, same machine (Linux, RTX 4070 Ti, NVIDIA 615.71.09). 20-minute sessions, each with a trace at 300 s (
On this stack the scene is GPU-bound: about 80% GPU busy, around 1.5 s of GPU per present. The CPU-side completion-label syncs this PR moves out of the mutex are rare here, unlike the older stack whose runs the description quoted. So there's no fps change to show, and the description's numbers came from a run that also changed other switches. Rather than leave a AI-assisted: yes (Claude Code) |
|
@oneandonlydean thanks for the specific list. The closing comment above has the matched baseline/change pair on the same prerequisite stack:
It shows no fps difference, so I closed the PR rather than work on the lock-availability fixture. If a title makes these syncs the bottleneck again, I'll reopen it with a held-wait lock test and the copied CPU write-back vs GPU-only pending-write cases you describe. @bunbeans2-arch thank you for the RX 9070 XT run: 321 of 321 with the validation layer on, and the same 106 tests passing on AI-assisted: yes (Claude Code) |
What
A dispatch whose guest buffers cover a pending CPU-side store — a completion label stored when its batch is reaped, or a copied write-back — syncs with the GPU in stage B, under the GPU mutex:
UploadFinish→CompletePendingCpuWrites→Recorder::SyncThrough→Recorder::Sync. Every queue that wants the mutex waits behind that sync, the draw committer included.With
APS5_PRESYNC_CPU_WRITES=1(off by default), stage A also lists the build's buffer ranges for the existing stage-A pre-sync, which already waits for image surfaces without the mutex:PresyncSurfacegains acpuWritesflag.ShaderResources::PresyncSurfacesadds the build's upload ranges (GuestBufferMemory::UploadRanges: its regions and the base regions of a cached address space), or a cached object's direct regions.VulkanDevice::presynclooks at those ranges only while a completion label or a copied write-back is pending at all. Under its short lock it keeps only the rangesCpuWriteSyncNeededaccepts. That isCompletePendingCpuWrites's own test, without the sync;CompletePendingCpuWritesnow calls it. GPU-only pending writes never make the pre-sync wait.[presync]reports the CPU-write ranges checked and the pre-syncs they joined.PresyncStatisticsgainscpuWriteChecksandcpuWriteWaits.Why: Ghost of Tsushima (PPSA02225 02.024.000)
This is measured on my Ghost of Tsushima test stack, because plain
mainstops earlier in this title onnative multisample stencil or depth format import is not implemented(#9533, #9717). The stack is #9508's GPU heap plus those depth PRs; the code this PR changes is the same asmain's.UploadFinish→CompletePendingCpuWrites→Recorder::Syncunder the mutex, 64 of them for 31 s in total. The draw committer waited 1.6 to 2.1 s per 10 s for the GPU mutex, almost all of it behind queue 0x38 and 0x51 dispatches ([lock]"waited behind").That run also changed other switches, so paired runs alternating only this switch are underway and will follow in a comment, with
APS5_TRACE_SUMMARY_EVERYlines.Tested
Linux (Ubuntu 26.04.1, GCC 15.2), RTX 4070 Ti (NVIDIA 615.71.09), at this head
611cec0678onmain01df56f7b7:ctest -R 'agc_driver_cpu_write_presync|agc_driver_dcc_key_presync|^agc_recorder': 11 tests pass in each of 3 runs.agc_driver_cpu_write_presync(tests/execution/CpuWritePresync.cpp, the switch set by the test):Recorder::AfterCompletions) inside the source of a copy dispatch. Stage A checks the range, waits for the label without the GPU mutex (cpuWriteWaitsandpresyncseach go up by one), and the copy reads the label's value.Windows 11 VM (GeForce GT 1030, WinLibs GCC 15.2, Release) at this head and on
main01df56f7b7:agc_driver_cpu_write_presyncpasses 3 of 3 at this head.agc_driver_dcc_key_presyncpasses 3 of 3 on both sides.Khronos validation layer comparison (
vvlcmp.sh, Linux, RTX 4070 Ti),mainagainst this head onagc_driver_cpu_write_presync|agc_driver_dcc_key_presync:main: 1 test, 1 Vulkan device created. This head: 2 tests, 2 devices created.VUID-line on either side, so nothing new at this head.Pending: paired Ghost of Tsushima runs that alternate only this switch, off/on/off/on on the same build. They will follow in a comment.
docs/dev/ENVIRONMENT.mdlists the switch.Overlaps
#9445, #9858 and #11847 each change one line that this PR moves: the label test in
CompletePendingCpuWrites(PendingLabelIntoCompletionLabelIn). This PR moves that test, unchanged, intoCpuWriteSyncNeeded, whichCompletePendingCpuWritesnow calls.CompletionLabelIn, the pre-sync also waits only for CPU-stored completion labels.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)🤖 Generated with Claude Code