feat(agc): add APS5_TRACE_SUMMARY_EVERY for summary lines of a long session #4812

Merged
AlxcBTW merged 1 commit from upstream-pr/4812 into main 2026-10-14 10:24:57 +00:00
AlxcBTW commented 2026-10-12 22:41:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by AlxcBTW on 2026-10-12T22:41:16Z.


Follow-up to #4526 and #4581, requested by TideOPL on #4526: profiling that runs in the background for a long session. This is mode 1 of the two modes proposed there, APS5_TRACE_SUMMARY_EVERY: a summary line per interval, no trace. Repeated windows with rotation (APS5_TRACE_EVERY) and streaming are separate PRs.

What

  • Switch. APS5_TRACE_SUMMARY_EVERY=<seconds> (a whole number above 0; a malformed value fails the first present). The first present opens the first interval. At the first present at least <seconds> s after the interval opened, the presenter appends one line to aps5-summary.jsonl (in APS5_TRACE_DIR or the working directory) and opens the next interval at that same present, so intervals follow each other without a gap. An interval still open when the title exits writes nothing.
  • Line. The fields of the window summary line (commit, dirty, env, gpu, driver, os, resolution, window, presents, frame_ms p50/p90/p99/max, gpu_busy_ms_per_present, worker_busy_pct, top_phases_ms_per_frame, trace_dropped) for that interval only, plus interval_start_s and interval_end_s (seconds since the first present). window is {"spec":"summary_every <seconds>","first_present":...,"ms":...}, trace is the empty string. Window lines are byte-identical to before.
  • No event buffer. Each trace thread already keeps per-scope totals. The presenter subtracts the totals of the previous interval; nothing else is recorded. Without a window switch the threads allocate no buffer (capacity 0), and the GPU range list is not filled.
  • Combined with a window switch. The intervals run for the whole session; the window records its full trace on top. Event buffers are filled only while the window is open (TraceThread checks one relaxed flag after accounting the total). The window's own summary line is taken from the totals at its open and close, so it holds only the time inside the window, as before; the interval lines continue unchanged around it.
  • Unset. Configured() stays one static bool, Recording() one relaxed load; nothing is allocated and no output changes. A thread whose window switch is set behaves as before (the window's buffer flag is true exactly while it was recording).
  • tools/trace_digest.py. A .jsonl argument prints the interval lines as one row per interval (frame p50, p90, p99, max, GPU busy per present, busiest queue worker, largest phase), an ASCII sparkline of the frame p99 and of the GPU busy time, and a note when commit, environment, GPU, driver or OS changes between intervals. Window lines in the file are skipped. --json prints the rows. Digesting a trace is unchanged.
  • Documented in docs/dev/BUILD.md (Performance trace, "Summaries for a long session").

Not in this PR: repeated windows with rotation, streaming a long trace to disk.

Tested

  • agc_performance_trace (extended): interval parsing and rejected values, when an interval is due and that it counts from its restart, a thread that is not buffering (totals kept, no slice, zero-capacity buffer untouched), the totals subtraction, and the exact JSON of an interval line.
  • tools/tests/test_trace_digest.py (extended): window lines skipped, row contents, identity change, sparkline scaling, the table and --json through main, a file without interval lines. 13 tests pass locally.
  • Fork CI (AlxcBTW/AnyPS5, configure, test registration check, build, libs, ctest on Linux with lavapipe and on Windows with WinLibs GCC 15.2.0): https://github.com/AlxcBTW/AnyPS5/actions/runs/38316206683 passes on both. That run tested the same change before it was squashed into one commit and rebased onto current main; the PR CI runs on this head.
  • Conventions: tools/check_conventions.py --base origin/main passes.
  • Not run with a title: the game was not started for this change.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none (#4526 and #4581 are merged)
  • Unblocks: APS5_TRACE_EVERY (repeated windows with rotation) and streaming, as separate PRs
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4835838121 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4812). Originally posted by [AlxcBTW](https://github.com/AlxcBTW) on 2026-10-12T22:41:16Z. --- Follow-up to #4526 and #4581, requested by TideOPL on #4526: profiling that runs in the background for a long session. This is mode 1 of the two modes proposed there, `APS5_TRACE_SUMMARY_EVERY`: a summary line per interval, no trace. Repeated windows with rotation (`APS5_TRACE_EVERY`) and streaming are separate PRs. ### What - **Switch.** `APS5_TRACE_SUMMARY_EVERY=<seconds>` (a whole number above 0; a malformed value fails the first present). The first present opens the first interval. At the first present at least `<seconds>` s after the interval opened, the presenter appends one line to `aps5-summary.jsonl` (in `APS5_TRACE_DIR` or the working directory) and opens the next interval at that same present, so intervals follow each other without a gap. An interval still open when the title exits writes nothing. - **Line.** The fields of the window summary line (`commit`, `dirty`, `env`, `gpu`, `driver`, `os`, `resolution`, `window`, `presents`, `frame_ms` p50/p90/p99/max, `gpu_busy_ms_per_present`, `worker_busy_pct`, `top_phases_ms_per_frame`, `trace_dropped`) for that interval only, plus `interval_start_s` and `interval_end_s` (seconds since the first present). `window` is `{"spec":"summary_every <seconds>","first_present":...,"ms":...}`, `trace` is the empty string. Window lines are byte-identical to before. - **No event buffer.** Each trace thread already keeps per-scope totals. The presenter subtracts the totals of the previous interval; nothing else is recorded. Without a window switch the threads allocate no buffer (capacity 0), and the GPU range list is not filled. - **Combined with a window switch.** The intervals run for the whole session; the window records its full trace on top. Event buffers are filled only while the window is open (`TraceThread` checks one relaxed flag after accounting the total). The window's own summary line is taken from the totals at its open and close, so it holds only the time inside the window, as before; the interval lines continue unchanged around it. - **Unset.** `Configured()` stays one static bool, `Recording()` one relaxed load; nothing is allocated and no output changes. A thread whose window switch is set behaves as before (the window's buffer flag is true exactly while it was recording). - **`tools/trace_digest.py`.** A `.jsonl` argument prints the interval lines as one row per interval (frame p50, p90, p99, max, GPU busy per present, busiest queue worker, largest phase), an ASCII sparkline of the frame p99 and of the GPU busy time, and a note when commit, environment, GPU, driver or OS changes between intervals. Window lines in the file are skipped. `--json` prints the rows. Digesting a trace is unchanged. - Documented in `docs/dev/BUILD.md` (Performance trace, "Summaries for a long session"). Not in this PR: repeated windows with rotation, streaming a long trace to disk. ### Tested - **`agc_performance_trace` (extended):** interval parsing and rejected values, when an interval is due and that it counts from its restart, a thread that is not buffering (totals kept, no slice, zero-capacity buffer untouched), the totals subtraction, and the exact JSON of an interval line. - **`tools/tests/test_trace_digest.py` (extended):** window lines skipped, row contents, identity change, sparkline scaling, the table and `--json` through `main`, a file without interval lines. 13 tests pass locally. - **Fork CI** (AlxcBTW/AnyPS5, configure, test registration check, build, libs, ctest on Linux with lavapipe and on Windows with WinLibs GCC 15.2.0): https://github.com/AlxcBTW/AnyPS5/actions/runs/38316206683 passes on both. That run tested the same change before it was squashed into one commit and rebased onto current `main`; the PR CI runs on this head. - **Conventions:** `tools/check_conventions.py --base origin/main` passes. - Not run with a title: the game was not started for this change. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none (#4526 and #4581 are merged) - [x] Unblocks: `APS5_TRACE_EVERY` (repeated windows with rotation) and streaming, as separate PRs - [x] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-13 09:39:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T09:39:36Z.


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.

Pull request Conflicting files (lines on main) Same exports Same new files
#5046 core/libs/prx/libSceAgcDriver/Execution/include/PerformanceTrace.hpp L86, L406-407
#5047 core/libs/prx/libSceAgcDriver/Execution/include/PerformanceTrace.hpp L86, L406-407
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6142717087 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4812#issuecomment-6142717087). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-13T09:39:36Z. --- <!-- pr-overlap --> 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**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #5046 | `core/libs/prx/libSceAgcDriver/Execution/include/PerformanceTrace.hpp` [L86](https://github.com/boykopovar/AnyPS5/blob/23e93c0547bfe5cbdcf4f8c41ea789b9af9b8c65/core/libs/prx/libSceAgcDriver/Execution/include/PerformanceTrace.hpp#L86), [L406-407](https://github.com/boykopovar/AnyPS5/blob/23e93c0547bfe5cbdcf4f8c41ea789b9af9b8c65/core/libs/prx/libSceAgcDriver/Execution/include/PerformanceTrace.hpp#L406-L407) | | | | #5047 | `core/libs/prx/libSceAgcDriver/Execution/include/PerformanceTrace.hpp` [L86](https://github.com/boykopovar/AnyPS5/blob/23e93c0547bfe5cbdcf4f8c41ea789b9af9b8c65/core/libs/prx/libSceAgcDriver/Execution/include/PerformanceTrace.hpp#L86), [L406-407](https://github.com/boykopovar/AnyPS5/blob/23e93c0547bfe5cbdcf4f8c41ea789b9af9b8c65/core/libs/prx/libSceAgcDriver/Execution/include/PerformanceTrace.hpp#L406-L407) | | |
adriadam10 commented 2026-10-13 16:00:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T16:00:22Z.


Checked the diff, built it merged onto current main and ran agc_performance_trace (passes; it does not compile without the change, so it exercises the new code). Interval parsing is strict, the totals subtraction and the window/interval interplay match the description, and with no switch nothing is allocated or changed. Merging once the full Build is green.

Note: #5046 and #5047 touch PerformanceTrace.hpp in the same places, so whichever lands second needs a rebase.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6149696027 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4812#issuecomment-6149696027). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-13T16:00:22Z. --- Checked the diff, built it merged onto current main and ran `agc_performance_trace` (passes; it does not compile without the change, so it exercises the new code). Interval parsing is strict, the totals subtraction and the window/interval interplay match the description, and with no switch nothing is allocated or changed. Merging once the full Build is green. Note: #5046 and #5047 touch `PerformanceTrace.hpp` in the same places, so whichever lands second needs a rebase.
Sign in to join this conversation.
No reviewers
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!4812
No description provided.