Proposal: one shared performance trace format (Chrome trace-event JSON) and a summary line, so perf numbers can be compared #4477

Closed
opened 2026-10-12 13:01:40 +00:00 by AlxcBTW · 7 comments
AlxcBTW commented 2026-10-12 13:01:40 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by AlxcBTW on 2026-10-12T13:01:40Z.


Perf reports and PRs use different profilers, so the numbers are hard to compare (raised in the dev chat). I'd like one capture that everyone runs the same way, and a template that asks for its output.

What exists today

  • APS5_PROFILE_DRAW=1 prints about 40 [tag] lines ([present], [draw], [lock], [guestmem], [groupcap], ...) through ProfileOutput to stderr, one report per 10 s window. [present] has the presents, p50/p90/max wait, GPU busy and idle gaps per present. [draw] has driver phases in us per packet. [lock] is per queue worker.
  • APS5_PROFILE_GPU=1 adds timestamp queries per recorded range, reported on [gputime] every 10 s by program address and by command class (Recorder::CommandClass).
  • APS5_NO_LOCK_PROFILE, APS5_NO_HOLD_PROFILE and APS5_NO_HOOKSYNC_PROFILE turn parts of this off.
  • -DAPS5_ENABLE_TIMING_LOG=ON writes a per-flip [FrameTiming] line to frame-timing.log (FrameTiming in PerformanceTimer.hpp).

These are 10 s aggregates, so a stall or a single slow frame is not visible, and the text formats differ per line. #3815 (APS5_TRACE_CALLS) traces library calls, not time; it does not overlap, but it could write into the same file later.

Proposal

  1. Capture. APS5_TRACE_FRAMES=<start>:<count> (presents, e.g. 600:300) or APS5_TRACE_SECONDS=<start>:<length>. Nothing is recorded outside the window. It writes aps5-trace-<commit>-<pid>.json.gz to the working directory (APS5_TRACE_DIR overrides). Format: Chrome trace-event JSON, which opens in ui.perfetto.dev (local, no upload), chrome://tracing, and can be imported into Tracy.
  2. Tracks. One thread track per queue worker (queue 0x..), the front end (packet decode, Graphics::Draw), the presenter, and the shader/pipeline compile threads. A GPU track is built from the existing timestamp queries (BeginGpuTiming/EndGpuTiming), with the same classes as [gputime] (Draw, Copy, Fill, PresentBlit, ...) plus one slice per batch.
  3. Events. Complete events (ph:X) named after the current metric keys (Driver.Packet, Driver.WorkerWait, Submission.queue, lock waits by site), one present instant per flip, counters (ph:C) for batches in flight. Args carry only counts, bytes, hashes and guest program addresses.
  4. Summary. One JSON line appended to aps5-summary.jsonl next to the trace: commit, dirty, env (all APS5_* set), gpu, driver, os, resolution, window, presents, frame_ms {p50,p90,p99,max}, gpu_busy_ms_per_present, worker_busy_pct per queue, top_phases_ms_per_frame (top 8), trace_dropped.
  5. Cost and size. Events go to a preallocated per-thread buffer and are written by the existing ProfileOutput writer thread, so no I/O on a worker. At the cap (default 20 MB gzipped, under GitHub's 25 MB attachment limit) it stops and sets trace_dropped, rather than slowing the title down. Slices under 20 us are folded into counters.
  6. Reuse. The metric keys of FrameTiming, ProfileOutput (bounded queue, drop count) and ShaderDeviceProfile (device and limits for the GPU/driver fields). The [...] lines stay as they are.
  7. Tracy as an optional build flag later (-DAPS5_ENABLE_TRACY=ON, built from a submodule as the PR checklist asks). The same zones would feed both outputs.

Privacy

A trace contains timings, event names, counts, byte sizes, thread names, and guest addresses or hashes of programs. It contains no game memory, no file names or paths of the title, no strings from the title and no user name. The summary has the machine's GPU, driver and OS version.

Measurement protocol (for the template)

  • Warm shader and pipeline cache: run the scene once, restart, then capture.
  • Fixed window in the same scene, stated by name or position; same resolution and settings for both sides of a comparison.
  • No other APS5_TRACE_* or APS5_PROFILE_* switch and no log redirect, since they cost time. Only APS5_TRACE_FRAMES.
  • Report the base commit and the PR commit from the same machine, same session.
  • Attach the .json.gz and paste the summary line.

A perf issue and PR template would ask for: summary line, trace file, commit, env switches, GPU, driver, OS, which scene.

Questions: is a present-count window the right default? Is .jsonl next to the trace acceptable, or should the summary go into the trace metadata only? I can write the first PR (capture and summary for the queue workers and presenter), and leave GPU track and templates for follow-ups.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5814181773 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/4477). Originally posted by [AlxcBTW](https://github.com/AlxcBTW) on 2026-10-12T13:01:40Z. --- Perf reports and PRs use different profilers, so the numbers are hard to compare (raised in the dev chat). I'd like one capture that everyone runs the same way, and a template that asks for its output. ### What exists today - `APS5_PROFILE_DRAW=1` prints about 40 `[tag]` lines (`[present]`, `[draw]`, `[lock]`, `[guestmem]`, `[groupcap]`, ...) through `ProfileOutput` to stderr, one report per 10 s window. `[present]` has the presents, p50/p90/max wait, GPU busy and idle gaps per present. `[draw]` has driver phases in us per packet. `[lock]` is per queue worker. - `APS5_PROFILE_GPU=1` adds timestamp queries per recorded range, reported on `[gputime]` every 10 s by program address and by command class (`Recorder::CommandClass`). - `APS5_NO_LOCK_PROFILE`, `APS5_NO_HOLD_PROFILE` and `APS5_NO_HOOKSYNC_PROFILE` turn parts of this off. - `-DAPS5_ENABLE_TIMING_LOG=ON` writes a per-flip `[FrameTiming]` line to `frame-timing.log` (`FrameTiming` in `PerformanceTimer.hpp`). These are 10 s aggregates, so a stall or a single slow frame is not visible, and the text formats differ per line. #3815 (`APS5_TRACE_CALLS`) traces library calls, not time; it does not overlap, but it could write into the same file later. ### Proposal 1. **Capture.** `APS5_TRACE_FRAMES=<start>:<count>` (presents, e.g. `600:300`) or `APS5_TRACE_SECONDS=<start>:<length>`. Nothing is recorded outside the window. It writes `aps5-trace-<commit>-<pid>.json.gz` to the working directory (`APS5_TRACE_DIR` overrides). Format: Chrome trace-event JSON, which opens in ui.perfetto.dev (local, no upload), chrome://tracing, and can be imported into Tracy. 2. **Tracks.** One thread track per queue worker (`queue 0x..`), the front end (packet decode, `Graphics::Draw`), the presenter, and the shader/pipeline compile threads. A GPU track is built from the existing timestamp queries (`BeginGpuTiming`/`EndGpuTiming`), with the same classes as `[gputime]` (Draw, Copy, Fill, PresentBlit, ...) plus one slice per batch. 3. **Events.** Complete events (`ph:X`) named after the current metric keys (`Driver.Packet`, `Driver.WorkerWait`, `Submission.queue`, lock waits by site), one `present` instant per flip, counters (`ph:C`) for batches in flight. Args carry only counts, bytes, hashes and guest program addresses. 4. **Summary.** One JSON line appended to `aps5-summary.jsonl` next to the trace: `commit`, `dirty`, `env` (all `APS5_*` set), `gpu`, `driver`, `os`, `resolution`, `window`, `presents`, `frame_ms` {p50,p90,p99,max}, `gpu_busy_ms_per_present`, `worker_busy_pct` per queue, `top_phases_ms_per_frame` (top 8), `trace_dropped`. 5. **Cost and size.** Events go to a preallocated per-thread buffer and are written by the existing `ProfileOutput` writer thread, so no I/O on a worker. At the cap (default 20 MB gzipped, under GitHub's 25 MB attachment limit) it stops and sets `trace_dropped`, rather than slowing the title down. Slices under 20 us are folded into counters. 6. **Reuse.** The metric keys of `FrameTiming`, `ProfileOutput` (bounded queue, drop count) and `ShaderDeviceProfile` (device and limits for the GPU/driver fields). The `[...]` lines stay as they are. 7. **Tracy** as an optional build flag later (`-DAPS5_ENABLE_TRACY=ON`, built from a submodule as the PR checklist asks). The same zones would feed both outputs. ### Privacy A trace contains timings, event names, counts, byte sizes, thread names, and guest addresses or hashes of programs. It contains no game memory, no file names or paths of the title, no strings from the title and no user name. The summary has the machine's GPU, driver and OS version. ### Measurement protocol (for the template) - Warm shader and pipeline cache: run the scene once, restart, then capture. - Fixed window in the same scene, stated by name or position; same resolution and settings for both sides of a comparison. - No other `APS5_TRACE_*` or `APS5_PROFILE_*` switch and no log redirect, since they cost time. Only `APS5_TRACE_FRAMES`. - Report the base commit and the PR commit from the same machine, same session. - Attach the `.json.gz` and paste the summary line. A perf issue and PR template would ask for: summary line, trace file, commit, env switches, GPU, driver, OS, which scene. Questions: is a present-count window the right default? Is `.jsonl` next to the trace acceptable, or should the summary go into the trace metadata only? I can write the first PR (capture and summary for the queue workers and presenter), and leave GPU track and templates for follow-ups. AI-assisted: yes (Claude Code)
TideOPL commented 2026-10-12 13:07:36 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by TideOPL on 2026-10-12T13:07:36Z.


LGTM +1

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6124894598 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/4477#issuecomment-6124894598). Originally posted by [TideOPL](https://github.com/TideOPL) on 2026-10-12T13:07:36Z. --- LGTM +1
CnRJay commented 2026-10-12 13:19:10 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-12T13:19:10Z.


+1

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6125094198 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/4477#issuecomment-6125094198). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-10-12T13:19:10Z. --- +1
AlxcBTW commented 2026-10-12 14:32:43 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by AlxcBTW on 2026-10-12T14:32:43Z.


@adriadam10 draft for step 1 (#4526) of #4477 is up, as asked. Step 2 (folded stacks from the existing worker sampler, for speedscope/flamegraphs) follows as a separate small PR.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6126370241 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/4477#issuecomment-6126370241). Originally posted by [AlxcBTW](https://github.com/AlxcBTW) on 2026-10-12T14:32:43Z. --- @adriadam10 draft for step 1 (#4526) of #4477 is up, as asked. Step 2 (folded stacks from the existing worker sampler, for speedscope/flamegraphs) follows as a separate small PR. AI-assisted: yes (Claude Code)
EagleBearerYS commented 2026-10-12 18:26:31 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-12T18:26:31Z.


Item 7 is up as #4607. -DAPS5_ENABLE_TRACY=ON (default OFF) builds the Tracy 0.14.1 client from a new 3rdparty/tracy submodule (3-clause BSD) and reports every PerformanceTimer scope as a Tracy zone, one frame per presented flip, with the queue workers and the presenter named.

What it brings in, for the decision here:

  • one build option, off by default. Off, the submodule is not configured and the driver objects are byte-identical to main;
  • one submodule, built only with the option;
  • no new environment variables, output files or build steps in the default build. The client listens on localhost only and records only while a profiler is connected;
  • on MinGW, a no-op __cxa_thread_atexit linked into the Tracy client, because emulated TLS frees thread_local objects before their destructors run (the problem fixed in #4029).

It doesn't need the trace format of #4526: both hook PerformanceTimer and conflict in two lines of PerformanceTimer.hpp, so whichever lands first, the other rebases. Tested on Windows with a capture of Unpacking (PPSA07117); not built on Linux.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6130162778 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/4477#issuecomment-6130162778). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-12T18:26:31Z. --- Item 7 is up as #4607. `-DAPS5_ENABLE_TRACY=ON` (default `OFF`) builds the Tracy 0.14.1 client from a new `3rdparty/tracy` submodule (3-clause BSD) and reports every `PerformanceTimer` scope as a Tracy zone, one frame per presented flip, with the queue workers and the presenter named. What it brings in, for the decision here: - one build option, off by default. Off, the submodule is not configured and the driver objects are byte-identical to `main`; - one submodule, built only with the option; - no new environment variables, output files or build steps in the default build. The client listens on localhost only and records only while a profiler is connected; - on MinGW, a no-op `__cxa_thread_atexit` linked into the Tracy client, because emulated TLS frees `thread_local` objects before their destructors run (the problem fixed in #4029). It doesn't need the trace format of #4526: both hook `PerformanceTimer` and conflict in two lines of `PerformanceTimer.hpp`, so whichever lands first, the other rebases. Tested on Windows with a capture of Unpacking (PPSA07117); not built on Linux.
oneandonlydean commented 2026-10-12 18:38:41 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-12T18:38:41Z.


In favour, and I'm taking it in steps. A fixed capture window with a summary line that records the commit, the GPU and driver and the switches of the run is what the performance reports here have been missing: most of this week's numbers came from different profilers on patched trees and could not be compared.

Order: #4570 (collapsed stacks) first, since it adds no variable and no dependency, then #4526 once its Linux build is green and it is rebased over #4570. #4570 conflicts with main since #4511 went in (Unwind.cpp, the block it moves into the header); please rebase it. #4632 and #4581 are reviewed after that as usual. #4607 (Tracy) fits as the optional step 7 on the same timers; it will need a rebase over #4526.

#4590 changes the issue forms under .github/, so that one waits for the owner.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6130363896 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/4477#issuecomment-6130363896). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-12T18:38:41Z. --- In favour, and I'm taking it in steps. A fixed capture window with a summary line that records the commit, the GPU and driver and the switches of the run is what the performance reports here have been missing: most of this week's numbers came from different profilers on patched trees and could not be compared. Order: #4570 (collapsed stacks) first, since it adds no variable and no dependency, then #4526 once its Linux build is green and it is rebased over #4570. #4570 conflicts with `main` since #4511 went in (`Unwind.cpp`, the block it moves into the header); please rebase it. #4632 and #4581 are reviewed after that as usual. #4607 (Tracy) fits as the optional step 7 on the same timers; it will need a rebase over #4526. #4590 changes the issue forms under `.github/`, so that one waits for the owner.
adriadam10 commented 2026-10-12 19:19:20 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-12T19:19:20Z.


On the two questions:

  • A present-count window is the right default: both sides of a comparison then cover the same presents of the same scene, while a seconds window covers a different number of presents whenever the change moves the frame time. APS5_TRACE_SECONDS stays useful for titles that stall before presenting.
  • aps5-summary.jsonl next to the trace is fine. The line is what gets pasted into an issue or a PR, and keeping it out of the trace leaves the trace a plain Chrome trace that every viewer opens.

Reviewed #4526 (Linux build, tests, and the gzip output checked with independent readers); comment there. We'll report the shader-object measurements of #2242 with this summary line once it is on main.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6131007418 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/4477#issuecomment-6131007418). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-12T19:19:20Z. --- On the two questions: - A present-count window is the right default: both sides of a comparison then cover the same presents of the same scene, while a seconds window covers a different number of presents whenever the change moves the frame time. `APS5_TRACE_SECONDS` stays useful for titles that stall before presenting. - `aps5-summary.jsonl` next to the trace is fine. The line is what gets pasted into an issue or a PR, and keeping it out of the trace leaves the trace a plain Chrome trace that every viewer opens. Reviewed #4526 (Linux build, tests, and the gzip output checked with independent readers); comment there. We'll report the shader-object measurements of #2242 with this summary line once it is on `main`.
adriadam10 commented 2026-10-12 21:09:34 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-12T21:09:34Z.


Status of the plan:

  • Collapsed stacks: #4570, merged.
  • Capture (APS5_TRACE_FRAMES/APS5_TRACE_SECONDS, trace + aps5-summary.jsonl): #4526, merged.
  • GPU track, GPU mutex waits and shader preparation: #4632, merged.
  • tools/trace_digest.py: #4581, merged.
  • Tracy (-DAPS5_ENABLE_TRACY=ON): #4607, merged.
  • Issue form and the PR-template / CONTRIBUTING line: #4590, merged.

Next: a section in the progress comment of each PR, showing the delta between the summary lines of main and of the PR when someone pastes both (same GPU, driver, resolution, window and switches; otherwise it says why it can't compare). That will be a separate PR.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6132653550 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/4477#issuecomment-6132653550). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-12T21:09:34Z. --- Status of the plan: - Collapsed stacks: #4570, merged. - Capture (`APS5_TRACE_FRAMES`/`APS5_TRACE_SECONDS`, trace + `aps5-summary.jsonl`): #4526, merged. - GPU track, GPU mutex waits and shader preparation: #4632, merged. - `tools/trace_digest.py`: #4581, merged. - Tracy (`-DAPS5_ENABLE_TRACY=ON`): #4607, merged. - Issue form and the PR-template / CONTRIBUTING line: #4590, merged. Next: a section in the progress comment of each PR, showing the delta between the summary lines of main and of the PR when someone pastes both (same GPU, driver, resolution, window and switches; otherwise it says why it can't compare). That will be a separate PR.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#4477
No description provided.