Repository navigation
feat(agc): add the GPU, GPU mutex waits and shader preparation to the trace - #4632
Conversation
|
Capture from a title run: Sword of the Sea (PPSA25344), main menu, RTX 5070 Laptop (NVIDIA 616.92), Windows 11 26200. The build is this PR on our lab branch (with #4526 and #4570), which carries the local patches the title still needs.
A first capture with a 65,536-range GPU buffer filled it at 7.5 s and set The trace itself is not attached because it comes from a title run. AI-assisted: yes (Claude Code) |
… trace The trace gets a gpu track: one slice per recorder batch from its timestamp pair, and with APS5_PROFILE_GPU=1 one per command class range under the [gputime] class names. The GPU clock is mapped onto the CPU clock from calibrated timestamps (VK_KHR_calibrated_timestamps or the EXT version, enabled only when a trace switch is set) taken when the window opens and when it closes. A traced thread's wait for the GPU mutex becomes a GpuMutex.wait.<site> slice, and the shader preparation threads are traced with smaller buffers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
795dc6b to
ad10d4f
Compare
|
#4526 is merged. I rebased this on main: only this PR's commit is left, and it applied cleanly. I also added ad10d4f, which updates the comment in Tested on Linux (GCC 16.2, Radeon 660M, RADV):
One thing for later, not for this PR: in that short window the summary's The full build workflow runs next, and I'll merge when it's green. |
ad10d4f to
eb8a725
Compare
Step 3 of #4477, on top of #4526. The trace gets a
gputrack (a slice per recorder batch, and withAPS5_PROFILE_GPU=1a slice per command class range), slices for waits on the GPU mutex, and the shader preparation threads. A frame that is GPU-bound then shows as the GPU busy while the presenter waits.What
Recorder::readGpuTiminghands each range it reads toPerformanceTrace::GpuRangewhile a window is open. That is the batch's timestamp pair, which a trace switch already turns on (feat(agc): record a present window as a Chrome trace and a summary line #4526), and, withAPS5_PROFILE_GPU=1, each command class range under its[gputime]name:draw,copy,fill,storage-upload,present-blit, and so on. Program ranges are left out. The ranges go into a buffer of 262,144 entries under a mutex of their own (reserved when the window opens, so appending never allocates); past that,trace_droppedis set. Outside a windowGpuRangeis one relaxed load.VK_KHR_calibrated_timestamps, or the EXT version, is enabled only when a trace switch is set, and only if the device offers the device domain and the host domain the CPU clock uses: QPC on Windows,CLOCK_MONOTONICelsewhere.VulkanDevice::CalibrateClocktakes a pair when the window opens and another when it closes, and the mapping is linear between them, so the two clocks agree at both ends of the window. Without the extension there is nogputrack, and the[trace]line says so.GpuMutexthat has to wait becomes aGpuMutex.wait.<site>slice. The site is the oneTagGpuLockSitenames for the[lock]line (dispatch,draw,present,flush, ...), now also kept while a window is open. Outside a windowlock()costs one more predictable branch.shader preparewith buffers of 32,768 events. TheirShader.PrepareArtifactand other timers show up in the trace.docs/dev/BUILD.md(Performance trace).Tested
Windows 11 (26200), WinLibs GCC 15.2.0 r7, Release, RTX 5070 Laptop (NVIDIA 616.92).
agc_performance_trace: new case for the clock mapping. Ranges are mapped linearly between two calibrations (here the GPU clock runs at twice the CPU's rate), a range that starts before the window or has no length is dropped, and with one calibration the mapping uses the CPU rate.ctest -E "^agc_driver|^video_out|^guest_video"): 615 of 616 pass on 795dc6b, includingagc_performance_traceandprx_thread_local_destructors.log_macrosfails as onmainon that machine.APS5_TRACE_FRAMES=120:120andAPS5_PROFILE_GPU=1: thegputrack has 124,454 slices: 8,087 batches and the class ranges, which nest one level deep inside their batch. No slices overlap partially, and no two batches overlap. The batches cover the whole window and add up to 79.14 ms per present. The summary'sgpu_busy_ms_per_present, from the same timestamps through the[present]accounting, is 79.15 ms. Every batch starts after the start of aRecorder.Submitslice on a queue worker (p1 15 us, median 141 us after the latest one), so the mapped GPU clock does not run ahead of the CPU's. Perfetto's trace processor v58.2 imports the file (3.7 MB) with no errors. A first run with a smaller GPU buffer filled it halfway through and settrace_dropped; the buffer now holds 262,144 ranges. Details are in a comment below.tools/check_conventions.py --base origin/mainpasses.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code