perf(agc): wait for the display keys' writer before a present takes the device lock's time #10160
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10160"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-23T11:17:29Z.
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
96bccd4c94. 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:
96bccd4c94(fable-void): the fix.a3af6b1149: a profile-only counter on the[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.54196438fc: the test,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 (12aa911767), which carries this fix with fable-void's other shared-code fixes: That's per 10 s: GPU waits thatmainwould 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;main44a59edc3a):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(d55142d279,main137a8fab89plus #8926's fix, which the title needs to get past its intro); with it,test/10160-village(0f8178cbca), the same tree plus this PR's three commits, the same as96bccd4c94,a3af6b1149and54196438fcby 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):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)