feat(trace): record host, title and per-frame benchmark data #7080

Merged
Rengundom merged 5 commits from upstream-pr/7080 into main 2026-10-20 08:19:24 +00:00
Rengundom commented 2026-10-17 10:35:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Rengundom on 2026-10-17T10:35:01Z.


What

Adds what a benchmark report needs to the trace summaries, so results from different machines can be compared and recomputed.

  • The summary line (APS5_TRACE_SUMMARY_EVERY, APS5_TRACE_FRAMES/APS5_TRACE_SECONDS) now also has the host's cpu (brand string), cpu_threads and memory_mib, and, when app0/sce_sys/param.json is present, title_id, title and content_version. param.json's contentVersion is now read (empty when absent).
  • APS5_TRACE_BENCH=1 together with APS5_TRACE_SUMMARY_EVERY rewrites aps5-bench-<commit>-<pid>.json.gz at each interval (in APS5_TRACE_DIR or the working directory): format aps5-bench/1, the summary's identity fields, and per interval start_s, end_s, first_present, resolution, gpu_busy_ms and frame_us, the whole microseconds between consecutive presents. The last 240 intervals are kept and intervals_dropped counts older ones. Frame times cost 4 bytes per present; the file is formatted and compressed on a writer thread. Any other value of the switch, or the switch without APS5_TRACE_SUMMARY_EVERY, fails the first present.
  • The file holds timings and host identity only: no guest memory, paths or title strings beyond the three param.json fields.

Documented in docs/dev/BUILD.md (summary fields) and docs/user/USAGE.md (Benchmark reports).

Tested

  • Linux (Ubuntu 24.04): agc_performance_trace_tests and param_json_parser_tests, with the new cases, pass.
  • Windows (11 Pro 26H2): PPSA24156 with APS5_TRACE_SUMMARY_EVERY=10 and APS5_TRACE_BENCH=1 writes aps5-bench-<commit>-<pid>.json.gz and aps5-summary.jsonl.

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](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file
  • 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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 3080, driver 616.92 (Game Ready), Windows 11 Pro 26H2 (build 26300.9550)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4899350182 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7080). Originally posted by [Rengundom](https://github.com/Rengundom) on 2026-10-17T10:35:01Z. --- ### What Adds what a benchmark report needs to the trace summaries, so results from different machines can be compared and recomputed. - The summary line (`APS5_TRACE_SUMMARY_EVERY`, `APS5_TRACE_FRAMES`/`APS5_TRACE_SECONDS`) now also has the host's `cpu` (brand string), `cpu_threads` and `memory_mib`, and, when `app0/sce_sys/param.json` is present, `title_id`, `title` and `content_version`. `param.json`'s `contentVersion` is now read (empty when absent). - `APS5_TRACE_BENCH=1` together with `APS5_TRACE_SUMMARY_EVERY` rewrites `aps5-bench-<commit>-<pid>.json.gz` at each interval (in `APS5_TRACE_DIR` or the working directory): format `aps5-bench/1`, the summary's identity fields, and per interval `start_s`, `end_s`, `first_present`, `resolution`, `gpu_busy_ms` and `frame_us`, the whole microseconds between consecutive presents. The last 240 intervals are kept and `intervals_dropped` counts older ones. Frame times cost 4 bytes per present; the file is formatted and compressed on a writer thread. Any other value of the switch, or the switch without `APS5_TRACE_SUMMARY_EVERY`, fails the first present. - The file holds timings and host identity only: no guest memory, paths or title strings beyond the three `param.json` fields. Documented in `docs/dev/BUILD.md` (summary fields) and `docs/user/USAGE.md` (Benchmark reports). ### Tested - Linux (Ubuntu 24.04): `agc_performance_trace_tests` and `param_json_parser_tests`, with the new cases, pass. - Windows (11 Pro 26H2): PPSA24156 with `APS5_TRACE_SUMMARY_EVERY=10` and `APS5_TRACE_BENCH=1` writes `aps5-bench-<commit>-<pid>.json.gz` and `aps5-summary.jsonl`. ### 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)](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [[technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt)](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [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 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce RTX 3080, driver 616.92 (Game Ready), Windows 11 Pro 26H2 (build 26300.9550) - [x] AI-assisted: yes
copilot-pull-request-reviewer[bot] commented 2026-10-17 10:35:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-10-17T10:35:07Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5557407581 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7080#pullrequestreview-5557407581). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-10-17T10:35:07Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
github-actions[bot] commented 2026-10-17 10:51:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-17T10:51:39Z.


Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 674 docs/dev/BUILD.md
PR 1835 core/libs/prx/libkernel/AppMetadata/src/ParamJsonParser.cpp
core/libs/tests/ParamJsonParser.cpp
docs/dev/BUILD.md
PR 2434 docs/dev/debt/libSceAgcDriver.md
PR 4448 docs/dev/debt/libSceAgcDriver.md
PR 4449 docs/dev/debt/libSceAgcDriver.md
PR 5021 core/libs/prx/libkernel/AppMetadata/src/ParamJsonParser.cpp
core/libs/tests/ParamJsonParser.cpp
docs/dev/BUILD.md
docs/user/USAGE.md
PR 5058 docs/dev/debt/libSceAgcDriver.md
PR 5431 docs/dev/ENVIRONMENT.md
PR 5499 docs/dev/debt/libSceAgcDriver.md
PR 5925 docs/dev/debt/libSceAgcDriver.md
docs/user/USAGE.md
PR 6044 core/libs/tests/ParamJsonParser.cpp
PR 6146 docs/dev/debt/libSceAgcDriver.md
PR 6171 docs/user/USAGE.md
PR 6194 docs/dev/debt/libSceAgcDriver.md
PR 6223 docs/dev/debt/libSceAgcDriver.md
PR 6273 docs/dev/debt/libSceAgcDriver.md
PR 6280 docs/dev/debt/libSceAgcDriver.md
PR 6300 docs/dev/debt/libSceAgcDriver.md
PR 6412 docs/dev/debt/libSceAgcDriver.md
PR 6481 docs/dev/debt/libSceAgcDriver.md
PR 6498 docs/dev/debt/libSceAgcDriver.md
PR 6548 docs/dev/debt/libSceAgcDriver.md
PR 6549 docs/dev/debt/libSceAgcDriver.md
PR 6636 docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 6658 docs/dev/ENVIRONMENT.md
PR 6683 docs/dev/debt/libSceAgcDriver.md
PR 6727 docs/dev/debt/libSceAgcDriver.md
PR 6788 docs/user/USAGE.md
PR 6808 docs/dev/debt/libSceAgcDriver.md
PR 6867 docs/dev/debt/libSceAgcDriver.md
PR 6868 docs/dev/debt/libSceAgcDriver.md
PR 6879 docs/dev/BUILD.md
PR 6926 docs/dev/debt/libSceAgcDriver.md
PR 6946 docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
docs/user/USAGE.md
PR 6947 docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
docs/user/USAGE.md
PR 6951 docs/dev/ENVIRONMENT.md
PR 6977 core/libs/prx/libkernel/AppMetadata/src/AppMetadata.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7002 docs/dev/debt/libSceAgcDriver.md
PR 7085 docs/dev/debt/libSceAgcDriver.md
PR 7256 docs/dev/debt/libSceAgcDriver.md
PR 7332 docs/dev/BUILD.md
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
docs/user/USAGE.md
PR 7446 docs/dev/debt/libSceAgcDriver.md
PR 7449 docs/dev/debt/libSceAgcDriver.md
PR 7457 docs/dev/ENVIRONMENT.md
PR 7464 docs/dev/ENVIRONMENT.md
PR 7484 docs/dev/ENVIRONMENT.md
PR 7505 docs/dev/debt/libSceAgcDriver.md
PR 7604 docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 7618 docs/dev/debt/libSceAgcDriver.md
PR 7642 docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
docs/user/USAGE.md
PR 7668 docs/dev/debt/libSceAgcDriver.md
PR 7862 docs/dev/debt/libSceAgcDriver.md
docs/user/USAGE.md
PR 7922 docs/dev/ENVIRONMENT.md
PR 7948 docs/dev/debt/libSceAgcDriver.md
PR 8004 docs/dev/ENVIRONMENT.md
PR 8099 docs/dev/debt/libSceAgcDriver.md
PR 8145 docs/dev/debt/libSceAgcDriver.md
PR 8223 docs/dev/debt/libSceAgcDriver.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6233031884 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7080#issuecomment-6233031884). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-17T10:51:39Z. --- <!-- pr-overlap --> Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 674](https://www.github.com/boykopovar/AnyPS5/pull/674) | `docs/dev/BUILD.md` | | [PR 1835](https://www.github.com/boykopovar/AnyPS5/pull/1835) | `core/libs/prx/libkernel/AppMetadata/src/ParamJsonParser.cpp`<br>`core/libs/tests/ParamJsonParser.cpp`<br>`docs/dev/BUILD.md` | | [PR 2434](https://www.github.com/boykopovar/AnyPS5/pull/2434) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 4448](https://www.github.com/boykopovar/AnyPS5/pull/4448) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 4449](https://www.github.com/boykopovar/AnyPS5/pull/4449) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `core/libs/prx/libkernel/AppMetadata/src/ParamJsonParser.cpp`<br>`core/libs/tests/ParamJsonParser.cpp`<br>`docs/dev/BUILD.md`<br>`docs/user/USAGE.md` | | [PR 5058](https://www.github.com/boykopovar/AnyPS5/pull/5058) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 5431](https://www.github.com/boykopovar/AnyPS5/pull/5431) | `docs/dev/ENVIRONMENT.md` | | [PR 5499](https://www.github.com/boykopovar/AnyPS5/pull/5499) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 5925](https://www.github.com/boykopovar/AnyPS5/pull/5925) | `docs/dev/debt/libSceAgcDriver.md`<br>`docs/user/USAGE.md` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/tests/ParamJsonParser.cpp` | | [PR 6146](https://www.github.com/boykopovar/AnyPS5/pull/6146) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 6171](https://www.github.com/boykopovar/AnyPS5/pull/6171) | `docs/user/USAGE.md` | | [PR 6194](https://www.github.com/boykopovar/AnyPS5/pull/6194) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 6223](https://www.github.com/boykopovar/AnyPS5/pull/6223) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 6273](https://www.github.com/boykopovar/AnyPS5/pull/6273) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 6280](https://www.github.com/boykopovar/AnyPS5/pull/6280) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 6300](https://www.github.com/boykopovar/AnyPS5/pull/6300) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 6412](https://www.github.com/boykopovar/AnyPS5/pull/6412) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 6481](https://www.github.com/boykopovar/AnyPS5/pull/6481) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 6498](https://www.github.com/boykopovar/AnyPS5/pull/6498) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 6548](https://www.github.com/boykopovar/AnyPS5/pull/6548) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 6549](https://www.github.com/boykopovar/AnyPS5/pull/6549) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 6636](https://www.github.com/boykopovar/AnyPS5/pull/6636) | `docs/dev/ENVIRONMENT.md`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 6658](https://www.github.com/boykopovar/AnyPS5/pull/6658) | `docs/dev/ENVIRONMENT.md` | | [PR 6683](https://www.github.com/boykopovar/AnyPS5/pull/6683) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 6727](https://www.github.com/boykopovar/AnyPS5/pull/6727) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 6788](https://www.github.com/boykopovar/AnyPS5/pull/6788) | `docs/user/USAGE.md` | | [PR 6808](https://www.github.com/boykopovar/AnyPS5/pull/6808) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 6867](https://www.github.com/boykopovar/AnyPS5/pull/6867) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 6868](https://www.github.com/boykopovar/AnyPS5/pull/6868) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 6879](https://www.github.com/boykopovar/AnyPS5/pull/6879) | `docs/dev/BUILD.md` | | [PR 6926](https://www.github.com/boykopovar/AnyPS5/pull/6926) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 6946](https://www.github.com/boykopovar/AnyPS5/pull/6946) | `docs/dev/ENVIRONMENT.md`<br>`docs/dev/debt/libSceAgcDriver.md`<br>`docs/user/USAGE.md` | | [PR 6947](https://www.github.com/boykopovar/AnyPS5/pull/6947) | `docs/dev/ENVIRONMENT.md`<br>`docs/dev/debt/libSceAgcDriver.md`<br>`docs/user/USAGE.md` | | [PR 6951](https://www.github.com/boykopovar/AnyPS5/pull/6951) | `docs/dev/ENVIRONMENT.md` | | [PR 6977](https://www.github.com/boykopovar/AnyPS5/pull/6977) | `core/libs/prx/libkernel/AppMetadata/src/AppMetadata.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 7002](https://www.github.com/boykopovar/AnyPS5/pull/7002) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 7085](https://www.github.com/boykopovar/AnyPS5/pull/7085) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 7256](https://www.github.com/boykopovar/AnyPS5/pull/7256) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 7332](https://www.github.com/boykopovar/AnyPS5/pull/7332) | `docs/dev/BUILD.md`<br>`docs/dev/ENVIRONMENT.md`<br>`docs/dev/debt/libSceAgcDriver.md`<br>`docs/user/USAGE.md` | | [PR 7446](https://www.github.com/boykopovar/AnyPS5/pull/7446) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 7449](https://www.github.com/boykopovar/AnyPS5/pull/7449) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 7457](https://www.github.com/boykopovar/AnyPS5/pull/7457) | `docs/dev/ENVIRONMENT.md` | | [PR 7464](https://www.github.com/boykopovar/AnyPS5/pull/7464) | `docs/dev/ENVIRONMENT.md` | | [PR 7484](https://www.github.com/boykopovar/AnyPS5/pull/7484) | `docs/dev/ENVIRONMENT.md` | | [PR 7505](https://www.github.com/boykopovar/AnyPS5/pull/7505) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 7604](https://www.github.com/boykopovar/AnyPS5/pull/7604) | `docs/dev/ENVIRONMENT.md`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 7618](https://www.github.com/boykopovar/AnyPS5/pull/7618) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 7642](https://www.github.com/boykopovar/AnyPS5/pull/7642) | `docs/dev/ENVIRONMENT.md`<br>`docs/dev/debt/libSceAgcDriver.md`<br>`docs/user/USAGE.md` | | [PR 7668](https://www.github.com/boykopovar/AnyPS5/pull/7668) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 7862](https://www.github.com/boykopovar/AnyPS5/pull/7862) | `docs/dev/debt/libSceAgcDriver.md`<br>`docs/user/USAGE.md` | | [PR 7922](https://www.github.com/boykopovar/AnyPS5/pull/7922) | `docs/dev/ENVIRONMENT.md` | | [PR 7948](https://www.github.com/boykopovar/AnyPS5/pull/7948) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 8004](https://www.github.com/boykopovar/AnyPS5/pull/8004) | `docs/dev/ENVIRONMENT.md` | | [PR 8099](https://www.github.com/boykopovar/AnyPS5/pull/8099) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 8145](https://www.github.com/boykopovar/AnyPS5/pull/8145) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 8223](https://www.github.com/boykopovar/AnyPS5/pull/8223) | `docs/dev/debt/libSceAgcDriver.md` |
Rengundom commented 2026-10-17 11:06:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Rengundom on 2026-10-17T11:06:05Z.


Checked the pr-overlap list: none of these implement the same functions. #6044 moves tests/ParamJsonParser.cpp, so whichever of the two merges second rebases.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6233160666 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7080#issuecomment-6233160666). Originally posted by [Rengundom](https://github.com/Rengundom) on 2026-10-17T11:06:05Z. --- Checked the pr-overlap list: none of these implement the same functions. #6044 moves `tests/ParamJsonParser.cpp`, so whichever of the two merges second rebases.
ionut27001 commented 2026-10-19 09:41:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ionut27001 on 2026-10-19T09:41:07Z.


Thanks, this is useful for comparing runs across machines. I read the diff against current main (it still merges cleanly at 64e2a810a) and have four points, the first two about the benchmark file itself:

  1. The bench file is rewritten in place. FlushInterval hands each snapshot to TraceFile::WriteGzip, which opens the path with std::ios::trunc and then streams the compressed data. If the title crashes or is killed during a rewrite, the file is left truncated and every interval collected so far is lost, and a crash is a likely moment for that. Writing to a temporary name next to it and replacing the old file once the write is complete would keep the last good report.

  2. Two pending snapshots can end up in one file. ProfileOutput::run joins pending writes into one batch while the batch stays within 64 KiB (batch.size() + pending.front().size() <= 65536). That suits the append-only aps5-summary.jsonl, but each bench Write is a whole file, so if the writer falls one interval behind while the snapshots are still small (for example with APS5_TRACE_SUMMARY_EVERY=1 and a slow disk), WriteGzip receives two JSON objects back to back and the file is not valid JSON until the next rewrite. Keeping only the newest pending snapshot for this writer would avoid it.

  3. The file is formatted on the presenter thread. The PR body and docs/dev/BUILD.md say the file "is formatted and compressed on a writer thread", but TraceFormat::Bench(...) runs inside FlushInterval, before Write, so only the compression happens on the writer thread. I timed a standalone loop that does the same per-frame std::to_string appends as Bench, on a Ryzen 7 5800X3D with GCC 15.2 at -O2: 9.4 ms for a full file of 240 intervals × 1800 frames (30 s intervals at 60 fps, 2.6 MB of text) and 16.8 ms with 3600 frames per interval. The cost grows as intervals accumulate, so in a long run the present that closes an interval is delayed by that much, and the delay lands in the next interval's first frame_us, which is the data being recorded. Formatting on the writer thread (or correcting the docs) would settle it.

  4. Non-x86 hosts. Both the interval and the window summaries go through identity(), which now calls host(), and processorName() throws when the host is not x86 or reports no brand string. On such a host the existing summary lines and the window trace now fail where they worked before. Since TraceSummary::host is already optional, leaving it empty there would keep the old output.

Smaller notes:

  • contentVersion is read in parseParamJson, which every title-metadata call goes through (ensureTitleLoaded). A non-string value now fails the parse, and a value of 16 characters or more makes copyToFixedBuffer throw length_error, for every caller of the title metadata and not only the trace. Real values look like 01.002.000, so this is unlikely, but it is a new failure mode for a field only the trace uses.
  • No test covers the 240-interval rotation and the intervals_dropped count in FlushInterval; BenchFormat passes intervals_dropped directly.

The formatting test, the switch parsing and the param.json cases look good to me. I have not built or run the branch; the timing above comes from a standalone copy of the formatting loop.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6264273207 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7080#issuecomment-6264273207). Originally posted by [ionut27001](https://github.com/ionut27001) on 2026-10-19T09:41:07Z. --- Thanks, this is useful for comparing runs across machines. I read the diff against current `main` (it still merges cleanly at 64e2a810a) and have four points, the first two about the benchmark file itself: 1. **The bench file is rewritten in place.** `FlushInterval` hands each snapshot to `TraceFile::WriteGzip`, which opens the path with `std::ios::trunc` and then streams the compressed data. If the title crashes or is killed during a rewrite, the file is left truncated and every interval collected so far is lost, and a crash is a likely moment for that. Writing to a temporary name next to it and replacing the old file once the write is complete would keep the last good report. 2. **Two pending snapshots can end up in one file.** `ProfileOutput::run` joins pending writes into one batch while the batch stays within 64 KiB (`batch.size() + pending.front().size() <= 65536`). That suits the append-only `aps5-summary.jsonl`, but each bench `Write` is a whole file, so if the writer falls one interval behind while the snapshots are still small (for example with `APS5_TRACE_SUMMARY_EVERY=1` and a slow disk), `WriteGzip` receives two JSON objects back to back and the file is not valid JSON until the next rewrite. Keeping only the newest pending snapshot for this writer would avoid it. 3. **The file is formatted on the presenter thread.** The PR body and `docs/dev/BUILD.md` say the file "is formatted and compressed on a writer thread", but `TraceFormat::Bench(...)` runs inside `FlushInterval`, before `Write`, so only the compression happens on the writer thread. I timed a standalone loop that does the same per-frame `std::to_string` appends as `Bench`, on a Ryzen 7 5800X3D with GCC 15.2 at -O2: 9.4 ms for a full file of 240 intervals × 1800 frames (30 s intervals at 60 fps, 2.6 MB of text) and 16.8 ms with 3600 frames per interval. The cost grows as intervals accumulate, so in a long run the present that closes an interval is delayed by that much, and the delay lands in the next interval's first `frame_us`, which is the data being recorded. Formatting on the writer thread (or correcting the docs) would settle it. 4. **Non-x86 hosts.** Both the interval and the window summaries go through `identity()`, which now calls `host()`, and `processorName()` throws when the host is not x86 or reports no brand string. On such a host the existing summary lines and the window trace now fail where they worked before. Since `TraceSummary::host` is already optional, leaving it empty there would keep the old output. Smaller notes: - `contentVersion` is read in `parseParamJson`, which every title-metadata call goes through (`ensureTitleLoaded`). A non-string value now fails the parse, and a value of 16 characters or more makes `copyToFixedBuffer` throw `length_error`, for every caller of the title metadata and not only the trace. Real values look like `01.002.000`, so this is unlikely, but it is a new failure mode for a field only the trace uses. - No test covers the 240-interval rotation and the `intervals_dropped` count in `FlushInterval`; `BenchFormat` passes `intervals_dropped` directly. The formatting test, the switch parsing and the `param.json` cases look good to me. I have not built or run the branch; the timing above comes from a standalone copy of the formatting loop.
Rengundom commented 2026-10-19 11:25:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Rengundom on 2026-10-19T11:25:15Z.


Thanks @ionut27001, this was a really useful review. I've pushed a follow-up commit that addresses all of it:

  1. Bench file rewritten in place: the file is now written as <name>.tmp and then moved over the old one (MoveFileExW with MOVEFILE_REPLACE_EXISTING on Windows, std::filesystem::rename elsewhere). If the title crashes or is killed during a rewrite, the last complete report is kept.
  2. Two snapshots in one file: the bench file now has its own TraceBenchWriter instead of a ProfileOutput. It holds only the newest pending snapshot, so a newer snapshot replaces an older unwritten one instead of being appended to it. aps5-summary.jsonl still goes through ProfileOutput.
  3. Formatting on the presenter thread: TraceFormat::Bench now runs on the writer thread. Each interval is kept as a shared_ptr<const TraceBenchInterval>, so the presenter only hands over the list of pointers and doesn't copy any intervals. The only per-interval work left on the presenter is FrameMicroseconds over that interval's own presents, and that doesn't grow as intervals pile up. I've corrected BUILD.md to match.
  4. Non-x86 hosts: processorName() returns std::nullopt instead of throwing when there's no brand string or the host isn't x86. TraceSummary::host is then left empty, so the summary lines and the window trace print the same fields as before.

Smaller notes:

  • contentVersion: a value that isn't a string is ignored by parseParamJson, and a value too long for the 16-byte buffer is left empty. Neither one fails the title metadata anymore. I updated the parser test to match.
  • Tests: BenchRotation covers the 240-interval limit and intervals_dropped, now handled by TraceBench::Keep. I also added:
    • BenchWriterKeepsNewest: keeps the writer busy, sends three snapshots, and checks that only the newest one is written after the first.
    • BenchWriterStopWrites: checks that a snapshot still waiting when the writer stops gets written.
    • ReplaceGzipFile: includes a rewrite made to fail partway, and checks that the previous file is still intact.

The performance trace and param.json tests pass locally (Linux, clang), and the conventions check passes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6266087386 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7080#issuecomment-6266087386). Originally posted by [Rengundom](https://github.com/Rengundom) on 2026-10-19T11:25:15Z. --- Thanks @ionut27001, this was a really useful review. I've pushed a follow-up commit that addresses all of it: 1. **Bench file rewritten in place:** the file is now written as `<name>.tmp` and then moved over the old one (`MoveFileExW` with `MOVEFILE_REPLACE_EXISTING` on Windows, `std::filesystem::rename` elsewhere). If the title crashes or is killed during a rewrite, the last complete report is kept. 2. **Two snapshots in one file:** the bench file now has its own `TraceBenchWriter` instead of a `ProfileOutput`. It holds only the newest pending snapshot, so a newer snapshot replaces an older unwritten one instead of being appended to it. `aps5-summary.jsonl` still goes through `ProfileOutput`. 3. **Formatting on the presenter thread:** `TraceFormat::Bench` now runs on the writer thread. Each interval is kept as a `shared_ptr<const TraceBenchInterval>`, so the presenter only hands over the list of pointers and doesn't copy any intervals. The only per-interval work left on the presenter is `FrameMicroseconds` over that interval's own presents, and that doesn't grow as intervals pile up. I've corrected `BUILD.md` to match. 4. **Non-x86 hosts:** `processorName()` returns `std::nullopt` instead of throwing when there's no brand string or the host isn't x86. `TraceSummary::host` is then left empty, so the summary lines and the window trace print the same fields as before. Smaller notes: - **`contentVersion`:** a value that isn't a string is ignored by `parseParamJson`, and a value too long for the 16-byte buffer is left empty. Neither one fails the title metadata anymore. I updated the parser test to match. - **Tests:** `BenchRotation` covers the 240-interval limit and `intervals_dropped`, now handled by `TraceBench::Keep`. I also added: - `BenchWriterKeepsNewest`: keeps the writer busy, sends three snapshots, and checks that only the newest one is written after the first. - `BenchWriterStopWrites`: checks that a snapshot still waiting when the writer stops gets written. - `ReplaceGzipFile`: includes a rewrite made to fail partway, and checks that the previous file is still intact. The performance trace and `param.json` tests pass locally (Linux, clang), and the conventions check passes.
adriadam10 commented 2026-10-19 16:47:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T16:47:21Z.

Review: DISMISSED


The full Build fails on Windows for this head (run 39283488108, windows: agc_performance_trace, main does not fail it):

FATAL: C++ exception St13__ios_failure raised on thread 3988 cannot be delivered: agc_performance_trace_tests.exe+0xb0db has no unwind data

It comes from the new ReplaceGzipFile test (core/libs/prx/libSceAgcDriver/tests/PerformanceTrace.cpp, the std::filesystem::create_directory(temporary) case): with a directory at <name>.tmp, WriteGzip's ofstream (exceptions enabled) throws std::ios_base::failure out of libstdc++ and on Windows it never reaches the catch (const std::exception&).

Suggested direction: make the failure come from ReplaceGzip itself instead of the stream, e.g. create a directory at the destination path so that MoveFileExW/std::filesystem::rename fails and throws std::system_error from the exe, and check that the previous file and the .tmp handling are what you expect. Everything else in the diff looks good.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5574797054 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7080#pullrequestreview-5574797054). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-19T16:47:21Z. **Review:** DISMISSED --- The full Build fails on Windows for this head (run 39283488108, `windows: agc_performance_trace`, main does not fail it): ``` FATAL: C++ exception St13__ios_failure raised on thread 3988 cannot be delivered: agc_performance_trace_tests.exe+0xb0db has no unwind data ``` It comes from the new `ReplaceGzipFile` test (`core/libs/prx/libSceAgcDriver/tests/PerformanceTrace.cpp`, the `std::filesystem::create_directory(temporary)` case): with a directory at `<name>.tmp`, `WriteGzip`'s `ofstream` (exceptions enabled) throws `std::ios_base::failure` out of libstdc++ and on Windows it never reaches the `catch (const std::exception&)`. Suggested direction: make the failure come from `ReplaceGzip` itself instead of the stream, e.g. create a directory at the destination `path` so that `MoveFileExW`/`std::filesystem::rename` fails and throws `std::system_error` from the exe, and check that the previous file and the `.tmp` handling are what you expect. Everything else in the diff looks good.
Rengundom commented 2026-10-20 00:59:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Rengundom on 2026-10-20T00:59:27Z.


The Windows failure is fixed in 9abcd4586.

  • ReplaceGzip now does the final move with an error_code. If the move fails, it removes the temporary file and throws std::system_error, instead of relying on a stream exception that MinGW couldn't unwind.
  • The test now blocks the destination with a directory. It checks that:
    • std::system_error is thrown
    • the directory is still there
    • no .tmp file is left behind
    • the other file is untouched

I ran ctest -R agc_performance_trace locally on Windows (MinGW) and it passes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6280817967 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7080#issuecomment-6280817967). Originally posted by [Rengundom](https://github.com/Rengundom) on 2026-10-20T00:59:27Z. --- The Windows failure is fixed in 9abcd4586. - `ReplaceGzip` now does the final move with an `error_code`. If the move fails, it removes the temporary file and throws `std::system_error`, instead of relying on a stream exception that MinGW couldn't unwind. - The test now blocks the destination with a directory. It checks that: - `std::system_error` is thrown - the directory is still there - no `.tmp` file is left behind - the other file is untouched I ran `ctest -R agc_performance_trace` locally on Windows (MinGW) and it passes.
oneandonlydean commented 2026-10-20 07:23:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T07:23:53Z.


Thanks for the Windows fix. Moving the failure onto the final move with an error_code, then cleaning up .tmp and throwing std::system_error, looks right to me.

One gap in the test: the new blocked-destination case no longer covers what ReplaceGzip exists for, which is that a failed rewrite keeps the last good file. It blocks a different file's destination and checks that aps5-bench.json.gz is untouched, and any implementation passes that. To check, I swapped ReplaceGzip's body for a plain in-place WriteGzip(path, text) and ran both versions of ReplaceGzipFile on Linux:

ReplaceGzip as in 9abcd45861:  this head's case PASS | 19 Oct case PASS
ReplaceGzip = WriteGzip(path): this head's case PASS | 19 Oct case FAIL

The in-place version passes the current case because libstdc++'s std::ios_base::failure derives from std::system_error, so writing into the blocked directory is caught too.

Could you keep your new case and bring back the 19 Oct one (a directory at <name>.tmp, then check the previous file is unchanged) behind #ifndef _WIN32? Linux CI then catches a regression to in-place writes, and Windows still avoids the stream exception that MinGW couldn't deliver. A comment on the guard saying why it's there would help the next reader.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6285671570 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7080#issuecomment-6285671570). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-20T07:23:53Z. --- Thanks for the Windows fix. Moving the failure onto the final move with an `error_code`, then cleaning up `.tmp` and throwing `std::system_error`, looks right to me. One gap in the test: the new blocked-destination case no longer covers what `ReplaceGzip` exists for, which is that a failed rewrite keeps the last good file. It blocks a *different* file's destination and checks that `aps5-bench.json.gz` is untouched, and any implementation passes that. To check, I swapped `ReplaceGzip`'s body for a plain in-place `WriteGzip(path, text)` and ran both versions of `ReplaceGzipFile` on Linux: ``` ReplaceGzip as in 9abcd45861: this head's case PASS | 19 Oct case PASS ReplaceGzip = WriteGzip(path): this head's case PASS | 19 Oct case FAIL ``` The in-place version passes the current case because libstdc++'s `std::ios_base::failure` derives from `std::system_error`, so writing into the blocked directory is caught too. Could you keep your new case and bring back the 19 Oct one (a directory at `<name>.tmp`, then check the previous file is unchanged) behind `#ifndef _WIN32`? Linux CI then catches a regression to in-place writes, and Windows still avoids the stream exception that MinGW couldn't deliver. A comment on the guard saying why it's there would help the next reader.
Rengundom commented 2026-10-20 07:53:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Rengundom on 2026-10-20T07:53:35Z.


@oneandonlydean Thanks, good catch. The blocked-destination case only checked a different file, so it couldn't tell an atomic replace from an in-place write.

The 19 Oct case is back beside it in ReplaceGzipFile: a directory at <name>.tmp makes the write fail, and the test checks that the previous aps5-bench.json.gz is unchanged. It's behind #ifndef _WIN32, with a comment saying why: the std::ios_base::failure from inside MinGW's ofstream couldn't unwind to the test's catch. There's a matching debt entry in docs/dev/debt/libSceAgcDriver.md.

I ran your experiment on Linux. As committed, it passes. With ReplaceGzip replaced by an in-place WriteGzip(path, text), the restored case fails with "a failed rewrite damaged the previous benchmark file". On Windows (MinGW), agc_performance_trace passes and runs only the blocked-move case.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6286180647 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7080#issuecomment-6286180647). Originally posted by [Rengundom](https://github.com/Rengundom) on 2026-10-20T07:53:35Z. --- @oneandonlydean Thanks, good catch. The blocked-destination case only checked a different file, so it couldn't tell an atomic replace from an in-place write. The 19 Oct case is back beside it in `ReplaceGzipFile`: a directory at `<name>.tmp` makes the write fail, and the test checks that the previous `aps5-bench.json.gz` is unchanged. It's behind `#ifndef _WIN32`, with a comment saying why: the `std::ios_base::failure` from inside MinGW's ofstream couldn't unwind to the test's catch. There's a matching debt entry in `docs/dev/debt/libSceAgcDriver.md`. I ran your experiment on Linux. As committed, it passes. With `ReplaceGzip` replaced by an in-place `WriteGzip(path, text)`, the restored case fails with "a failed rewrite damaged the previous benchmark file". On Windows (MinGW), `agc_performance_trace` passes and runs only the blocked-move case.
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!7080
No description provided.