Repository navigation
feat(agc): record a present window as a Chrome trace and a summary line - #4526
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's two commits on our lab branch, which carries the local patches the title still needs (cf01fcab4 in the summary).
The summary line ( {"commit":"cf01fcab4c2d","dirty":false,"env":{"APS5_HOST_IMPORT_JOIN":"1","APS5_NO_PAD_INPUT":"1","APS5_RESOURCE_CACHE_ENTRIES":"8192","APS5_TRACE_DIR":"<path>","APS5_TRACE_FRAMES":"120:120"},"gpu":"NVIDIA GeForce RTX 5070 Laptop GPU","driver":"NVIDIA 616.92","os":"Windows 10.0.26200","resolution":"3840x2160","window":{"spec":"frames 120:120","first_present":120,"ms":15841.663},"presents":120,"frame_ms":{"p50":129.535,"p90":154.547,"p99":168.741,"max":170.205},"gpu_busy_ms_per_present":78.555,"worker_busy_pct":{"queue worker 0x0":99.423,"queue worker 0x20":79.485},"top_phases_ms_per_frame":{"Driver.Packet":233.912,"Driver.Packet.dispatch":91.290,"Driver.Packet.memory_wait":76.991,"Driver.Dispatch":72.094,"Vulkan.Dispatch":41.527,"Driver.Packet.draw":38.134,"Driver.Draw":38.049,"Vulkan.Dispatch.shader_resources":36.774},"trace_dropped":false,"trace":"aps5-trace-cf01fcab4c2d-60720.json.gz"}
The first capture wrote no file, which is what the second commit fixes. The zlib in the tree (libjpeg-turbo's) is built with The trace itself is not attached because it comes from a title run. 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.
|
|
Read through dafae93. The code is fine by reading: malformed values throw at the first present, nothing falls back, and with the variables unset the cost is one relaxed atomic load per What it brings in is the part that needs a decision, and it is the owner's rather than mine:
#4477 has no answer from him yet, so I am leaving this open until it does. Two things in the meantime:
#4570 has no new variable or dependency, so it can go in on its own once its build is green. It conflicts with this one in |
|
@oneandonlydean thanks for the read. The Agreed on the order: #4570 first, then I merge If it makes the owner's call easier, I can shrink what this brings in:
AI-assisted: yes (Claude Code) |
|
Reviewed a2c49da on Linux (GCC 16.2, Release):
Ready from my side once it is rebased over #4570, as Dean said. |
APS5_TRACE_FRAMES=<start>:<count> (or APS5_TRACE_SECONDS=<start>:<length>) records every PerformanceTimer scope and stage of the queue workers and the presenter inside the window as complete events, named after their frame timing keys, into a preallocated buffer per thread. Slices under 20 us are counted per thread instead of written; a full buffer stops that thread and sets trace_dropped. When the window closes, a ProfileOutput writer thread writes aps5-trace-<commit>-<pid>.json.gz and appends one line to aps5-summary.jsonl. Without either switch a PerformanceTimer costs one more predictable branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The zlib in the tree (libjpeg-turbo's) is built with NO_GZIP, so deflateInit2 refuses the gzip wrapper (windowBits 31) and no trace was written. The trace file now writes the gzip header, a raw deflate stream, and the CRC-32 and size trailer itself. The writer's result line is flushed, since stderr is buffered in a title process. The file writing moves to TraceFile, and a test inflates a written file and checks its CRC-32 and size. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
a2c49da to
6116fc7
Compare
|
#4570 is merged. I rebased this on top of it: the conflicts in libSceAgcDriver's Linux (GCC 16.2), full build: |
|
@AlxcBTW I'd rather the profiler just runs in the background all the time so I can have a game running for a prolonged period, gather data and iterate from there. |
|
@TideOPL makes sense. A long session is where the interesting stalls show up. The window is bounded today because every slice is buffered (262,144 events per thread). I'd add two modes in a follow-up PR:
Would that cover what you want, or do you need a full trace of the whole session? That would need a streaming writer instead of the in-memory buffer. AI-assisted: yes (Claude Code) |
|
@AlxcBTW, these are good. I would say a third option for streaming is ideal, looking long term when games stay up for longer than 1 - 2 hours, long traces could be great. |
|
@TideOPL agreed. I'll do it in three small PRs, in this order:
I'll tag you on each. AI-assisted: yes (Claude Code) |
|
@TideOPL step 1 is up: #4812 ( AI-assisted: yes (Claude Code) |
Step 1 of #4477. A window of presents is recorded as a Chrome trace-event file plus one summary line, so perf numbers in issues and PRs come from the same capture. The GPU track, the compile threads and the perf templates are follow-ups.
What
APS5_TRACE_FRAMES=<start>:<count>records<count>presents from present<start>(counted from 0).APS5_TRACE_SECONDS=<start>:<length>records from the first present at least<start>s after the first present until the first present<length>s later. The window opens and closes at a present. A malformed value, or both switches together, fails the first present.PerformanceTimeralready brackets the driver's phases with theFrameTimingkeys. While the window is open, a timer on a queue worker or on the presenter also records its scope and eachMarkstage as a complete event (ph:X):Driver.WorkerWait,Driver.Packet,Driver.Packet.draw,Graphics.Draw,Recorder.Submit,Driver.Present,Driver.Present.inflight_wait,Vulkan.Retire, and so on. Each present is a globalpresentinstant with its number. The thread tracks use the existing thread roles (queue worker 0x0,presenter).trace_dropped. Every slice is added to a per-thread total by scope and stage; a slice under 20 us is not written, and its time goes to the thread's counter<thread> folded(ms per present).ProfileOutputof its own (the existing one writes to stderr) gzips it on its writer thread toaps5-trace-<commit>-<pid>.json.gzand appends the summary line toaps5-summary.jsonl, both inAPS5_TRACE_DIRor the working directory. The deflate stream comes from the zlib that libjpeg-turbo already builds from source (the onelibSceZliblinks), so there is no new submodule. That zlib is built withNO_GZIP, soTraceFilewrites the gzip header and the CRC-32 and size trailer itself.commit,dirty,env(everyAPS5_*; a value containing/or\is written as<path>),gpu,driver(VkPhysicalDeviceDriverPropertiesname and info),os,resolution(the video output's),window,presents,frame_ms{p50, p90, p99, max} of the intervals between presents,gpu_busy_ms_per_present(the batch timestamps behind[present]),worker_busy_pctper queue worker (share of the window inDriver.Packet,Driver.Suspend,Driver.EndSubmission,Driver.RewindandDriver.Completion, the non-wait part ofFrameTiming's worker accounting),top_phases_ms_per_frame(the eight largest scopes and stages, withoutDriver.WorkerWait),trace_droppedandtrace.commitanddirtycome from a header that a build step regenerates from git on every build (trace_revision.cmake, rewritten only when it changes), so an incremental build never reports a stale commit.PerformanceTimerdoes one relaxed load and one more null check, and nothing is allocated. With a switch set, the recorder writes the batch timestamp pair for the whole run, as withAPS5_PROFILE_DRAW, sogpu_busy_ms_per_presentneeds no profile switch.docs/dev/BUILD.md(Performance trace).Not in this step: the GPU track, compile threads,
Submission.*and lock-site events, a batches-in-flight counter, the templates. From the questions in #4477: the window defaults to presents, and the summary goes only intoaps5-summary.jsonl, not into the trace.Tested
Windows 11 (26200), WinLibs GCC 15.2.0 r7, Release.
agc_performance_trace(new): window edges by frames and by seconds, rejected values, the buffer cap and the dropped flag, folding of short slices and the per-present counter, JSON string escaping, the exact JSON of a small thread, every summary field, a written.json.gzinflated and checked against its CRC-32 and size, and appended summary lines.ctest -E "^agc_driver|^video_out|^guest_video"): 615 of 616 pass, includingagc_performance_traceandprx_thread_local_destructors;log_macrosfails as onmainon that machine. TheBUILD_TESTINGbuild also linksagc_driver_mesh_testsand the other targets that compile the driver sources.APS5_TRACE_FRAMES=120:120wrote a 2.5 MB trace (26.6 MB of JSON, 284,124 events onqueue worker 0x0,queue worker 0x20andpresenter, nothing dropped) and its summary line. Perfetto's trace processor v58.2 (the engine of ui.perfetto.dev) imports it with no errors. Details are in a comment below. The first capture wrote nothing, because the bundled zlib has no gzip wrapper; the second commit fixes that.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