Repository navigation
perf(agc): wait for the display keys' writer before a present takes the device lock's time - #10160
Merged
oneandonlydean merged 3 commits intoOct 26, 2026
Conversation
…he device lock's time The presenter checks a display buffer's DCC keys under the device lock. When the batch of the kernel that writes those keys had not finished, the check waited for the GPU while holding the lock, and the queue worker recording the next frame waited behind the presenter. PresentDisplayBuffer now first syncs through the key range with the unlocked wait the flush hook uses: the presenter's acquisition is the outermost on its thread and nothing has been decided yet, so the lock is released for the GPU wait and retaken for the completions. The key check that follows finds the batch finished. Tested on Windows in a title's menu: the presenter's GPU waits under the lock went from 721 (1.38 s) to 1 (0 ms) per 10 s, and the queue worker's waits for the lock from 1.47 s to 0.18 s per 10 s.
…locked With APS5_PROFILE_DRAW set, the [present] line now counts the presents whose sync through the display buffer's DCC keys waited for the GPU before the key check, outside the GPU mutex, and the milliseconds they waited: the waits the presenter took under the mutex before.
…t the GPU mutex A headless device presents a DCC display buffer while a recorded kernel that copies over its keys is still pending, holding the GPU mutex once as Driver::Present does. The present must release the mutex for that wait (the hold serial advances), read the keys the kernel stored and reach the swapchain; with nothing pending it must keep the mutex. It stops at the missing swapchain, after the key check.
|
This pull request is labeled |
|
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.
|
12 tasks done
12 tasks done
EagleBearerYS
added a commit
to EagleBearerYS/AnyPS5
that referenced
this pull request
Oct 24, 2026
…gests and trace-window summary lines
EagleBearerYS
marked this pull request as ready for review
October 24, 2026 21:54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The presenter checks a display buffer's DCC keys under the device lock.
PresentDisplayBuffernow first syncs through the key range with the unlocked wait the flush hook uses.dccAddress != 0,tilingMode == 0).Authorship: the fix is @fable-void's (fable-void/AnyPS5@9ed1466f35), carried unchanged under his authorship as 96bccd4. His message reports, in a title's menu on Windows: GPU waits under the lock went from 721 (1.38 s) to 1 (0 ms) per 10 s, and the queue worker's waits for the lock from 1.47 s to 0.18 s per 10 s. The counter and the test are ours.
The commits:
[present]line behindAPS5_PROFILE_DRAW:waits outside the GPU mutex for the display keys' writer: N, X ms. With the profile off it costs one test of astatic const bool.agc_driver_present_key_writer_wait(tests/execution/PresentKeyWriterWait.cpp).VulkanDevice::PresentDisplayBufferheadless, holding the GPU mutex once, asDriver::Presentdoes, over a display buffer whose keys a recorded GPU copy is still writing.GuestMemory::GpuHoldSerial()advanced (the presenter released and retook the mutex for the writer); and the writer is no longer pending.Tested
APS5_PROFILE_DRAW=1, on our lane F tree (12aa911), which carries this fix with fable-void's other shared-code fixes:mainwould make with the device lock held (this PR's commit alone was not run in the title).agc_driver_present_key_writer_wait):--repeat until-fail:20: 17 tests ran 20 times each, and 17video_out_*tests skip with no display;main44a59ed):main's implementation (agc_driver_present_key_writer_wait: "the presenter synchronized with the display keys' writer without releasing the GPU mutex"): 2 pass, 1 fails. Green ×10 with this PR: all 3 run and pass (the new test,agc_display_buffer_dccandagc_driver_dcc_key_presync), none skip.agc_display_buffer_dcc, ×10 with this PR) and the 2 device tests skip.main's driver and this PR over the 12 non-video_outtests give the same singleVUID-VkDeviceCreateInfo-pNext-pNextin the same tests with the same counts. No newVUID-.APS5_LAZY_SHADER_PREPARE=1,APS5_NO_GPL=1andAPS5_HOST_IMPORT_MIB=6400. GPU clocks weren't locked (P0 in 98.8–99.4 % of samples, mean 1,398–1,412 MHz).The trees: without this PR,
test/10160-village-base(d55142d,main137a8fa plus fix(agc): put a retired import's unchanged ranges back in the write watch #8926's fix, which the title needs to get past its intro); with it,test/10160-village(0f8178c), the same tree plus this PR's three commits, the same as 96bccd4, a3af6b1 and 5419643 by patch-id.Speed, from the 10-s summary rows over 399–461 s and 519–581 s of each run, after the menu stood in all four:
The means are 0.386 fps with and 0.387 without, and the runs of one build differ as much as the builds do, so the frame rate is unchanged within noise. At this menu the presenter is busy 3.3–4.1 ms per frame in all four traces (
trace_digest.py's thread table). This PR makes no frame-rate claim.The menu takes this PR's path: in the 60-s traces of runs 1 and 4 (with), the presenter thread retakes the GPU mutex at the
hooksite, the site this PR's unlocked wait for the display keys' writer retakes it at, 3 and 6 times (GpuMutex.wait.hook; the trace records a retake only when it had to wait, so these are lower bounds). In runs 2 and 3 (without), the presenter has no such slice.Memory, from 1 minute into the menu to the end of each run: private memory 18,481–19,381 MB at 1 minute, growing 723–907 MB per minute in all four, with no commit floor.
Closes: runs 1, 2 and 3 end with a crash in the presenter at close, after the measured window, in both builds; run 4 closed cleanly.
Summary lines (
aps5-summary.jsonl), the rows of the 60-s trace windows (APS5_TRACE_SECONDS=460:60) of run 2 (without) and run 1 (with):{"commit":"d55142d279a0","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"6400","APS5_LAZY_SHADER_PREPARE":"1","APS5_NO_GPL":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"460:60","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","cpu":"AMD Ryzen 9 5900HS with Radeon Graphics","cpu_threads":16,"memory_mib":15776,"title_id":"PPSA01556","title":"Resident Evil Village","content_version":"01.210.000","resolution":"3840x2160","window":{"spec":"seconds 460:60","first_present":2587,"ms":61597.811},"presents":24,"frame_ms":{"p50":2532.486,"p90":2938.668,"p99":3711.990,"max":3711.990},"gpu_busy_ms_per_present":280.063,"worker_busy_pct":{"queue worker 0x0":99.698,"queue worker 0x38":0.138,"queue worker 0x20":93.610,"queue worker 0x28":96.828},"top_phases_ms_per_frame":{"Driver.Packet":7447.818,"Driver.Packet.memory_wait":4571.201,"Driver.Packet.draw":2059.353,"Driver.Draw":2058.176,"Graphics.Draw":1780.472,"Graphics.Draw.draw_and_resource_release":1755.706,"Resources.Complete":803.815,"Driver.Packet.dispatch":599.660},"trace_dropped":false,"trace":"aps5-trace-d55142d279a0-3524.json.gz"}{"commit":"0f8178cbca31","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"6400","APS5_LAZY_SHADER_PREPARE":"1","APS5_NO_GPL":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"460:60","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","cpu":"AMD Ryzen 9 5900HS with Radeon Graphics","cpu_threads":16,"memory_mib":15776,"title_id":"PPSA01556","title":"Resident Evil Village","content_version":"01.210.000","resolution":"3840x2160","window":{"spec":"seconds 460:60","first_present":1181,"ms":62201.146},"presents":23,"frame_ms":{"p50":2652.280,"p90":3043.922,"p99":3484.024,"max":3484.024},"gpu_busy_ms_per_present":278.929,"worker_busy_pct":{"queue worker 0x0":99.689,"queue worker 0x38":0.065,"queue worker 0x20":93.795,"queue worker 0x28":96.836},"top_phases_ms_per_frame":{"Driver.Packet":7849.574,"Driver.Packet.memory_wait":4808.638,"Driver.Packet.draw":2208.895,"Driver.Draw":2207.691,"Graphics.Draw":1908.668,"Graphics.Draw.draw_and_resource_release":1882.055,"Resources.Complete":855.785,"Driver.Packet.dispatch":651.564},"trace_dropped":false,"trace":"aps5-trace-0f8178cbca31-15520.json.gz"}Files: each run's trace, its trace-window summary line and
tools/trace_digest.pyoutput: run 1, run 2, run 3, run 4.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)