perf: add an optional performance report #1851

Closed
github-bot wants to merge 6 commits from gh-pr/1851/head into gh-pr/1851/base
Owner

@⁠MrBigBritches on GitHub · 2026-10-22 23:45 UTC · original
MrBigBritches:perf-report → main · +841 −23 · 23 files · 6 commits · closed without merging

Adds an opt-in, plain-text performance report for investigating low frame rates. While a game runs, the emulator writes a summary every 5 seconds. It shows which code path made the CPU wait for the GPU or submit work, and which guest memory causes write-tracking faults. Those are frequently the questions behind many slowdowns, and a sampling profiler like Tracy answers them poorly.

Usage

  • Launcher: Debugging & logs → Performance report, with the output path in Performance report file.
  • Command line: --perf-report, and optionally --perf-report-file <path>.
  • The default file is _kyty_perf.txt. A relative path is relative to the working directory, as with the printf output file. The report doesn't depend on logging settings.

What the report contains

  • Frames presented per second.
  • Share of time the GPU command thread was idle, and blocked on guest waits.
  • GPU waits and queue submits, in total and by call site. Flush, FlushAndWait, Finish, Wait and Submit take a defaulted std::source_location, so callers are unchanged.
  • Write-tracking faults:
    • handler time, split between the buffer cache and the texture cache;
    • faults that had to download GPU data first;
    • pages that fault again within an interval;
    • the busiest threads and 1 MiB regions;
    • for download faults, the shader whose buffer write owns the page.
  • Time spent on tracking protection changes; buffer uploads; BDA sync requests; buffer cache size.

docs/performance-report.md explains each line with a real example, and describes how to add a measurement. The README links to it.

Cost

  • Disabled (default): each instrumented event costs a relaxed atomic load and a branch, the same pattern as DebugCounters.
  • Enabled: events that need maps take a lock. In A/B runs at a game's main menu, measured with Tracy flip counts, the frame rate stayed within run-to-run noise: 3.5 fps off vs 3.7 fps on.

Files

  • New: src/common/perfReport.h/.cpp, docs/performance-report.md.
  • Instrumentation: command scheduler, master semaphore, GPU command thread, fault handler (RenderContext::HandleFault), buffer cache, memory tracker, descriptors (GPU-written bindings), address-space protection, video-out flips.
  • Config and launcher: emulatorConfig, main.cpp, launcher configuration, dialog and .ui.

Testing

  • Built on Windows (clang-cl). shader_cfg_tests and memory_tracker_tests pass.
  • Ran a game with the report enabled: intervals are written about every 5 s, and the frame count matches Tracy's game-flip count.
  • Default output path verified.
**@⁠MrBigBritches** on GitHub · 2026-10-22 23:45 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1851) `MrBigBritches:perf-report` → `main` · +841 −23 · 23 files · 6 commits · closed without merging Adds an opt-in, plain-text performance report for investigating low frame rates. While a game runs, the emulator writes a summary every 5 seconds. It shows *which code path* made the CPU wait for the GPU or submit work, and *which guest memory* causes write-tracking faults. Those are frequently the questions behind many slowdowns, and a sampling profiler like Tracy answers them poorly. ### Usage - **Launcher:** *Debugging & logs* → **Performance report**, with the output path in **Performance report file**. - **Command line:** `--perf-report`, and optionally `--perf-report-file <path>`. - The default file is `_kyty_perf.txt`. A relative path is relative to the working directory, as with the printf output file. The report doesn't depend on logging settings. ### What the report contains - Frames presented per second. - Share of time the GPU command thread was idle, and blocked on guest waits. - GPU waits and queue submits, in total and **by call site**. `Flush`, `FlushAndWait`, `Finish`, `Wait` and `Submit` take a defaulted `std::source_location`, so callers are unchanged. - Write-tracking faults: - handler time, split between the buffer cache and the texture cache; - faults that had to download GPU data first; - pages that fault again within an interval; - the busiest threads and 1 MiB regions; - for download faults, the shader whose buffer write owns the page. - Time spent on tracking protection changes; buffer uploads; BDA sync requests; buffer cache size. `docs/performance-report.md` explains each line with a real example, and describes how to add a measurement. The README links to it. ### Cost - **Disabled (default):** each instrumented event costs a relaxed atomic load and a branch, the same pattern as `DebugCounters`. - **Enabled:** events that need maps take a lock. In A/B runs at a game's main menu, measured with Tracy flip counts, the frame rate stayed within run-to-run noise: 3.5 fps off vs 3.7 fps on. ### Files - **New:** `src/common/perfReport.h/.cpp`, `docs/performance-report.md`. - **Instrumentation:** command scheduler, master semaphore, GPU command thread, fault handler (`RenderContext::HandleFault`), buffer cache, memory tracker, descriptors (GPU-written bindings), address-space protection, video-out flips. - **Config and launcher:** `emulatorConfig`, `main.cpp`, launcher configuration, dialog and `.ui`. ### Testing - Built on Windows (clang-cl). `shader_cfg_tests` and `memory_tracker_tests` pass. - Ran a game with the report enabled: intervals are written about every 5 s, and the frame count matches Tracy's game-flip count. - Default output path verified.
Add a plain-text performance report for investigating low frame rates.
With --perf-report (launcher: Debugging & logs > Performance report),
the emulator writes a summary every 5 seconds to the file given by
--perf-report-file (launcher: Performance report file), _kyty_perf.txt
by default:

- frames presented per second;
- how much of the time the GPU command thread was idle or blocked on
  guest waits;
- GPU waits and queue submits, in total and by the command-scheduler
  call site that caused them (Flush, FlushAndWait, Finish, Wait and
  Submit take a defaulted std::source_location);
- write-tracking faults: time in the buffer and texture caches, faults
  that had to download GPU data first, repeat faults on the same page,
  the busiest threads and 1 MiB regions, and the shader whose buffer
  write owns each downloaded page;
- time spent on tracking protection changes, buffer uploads, BDA
  synchronization requests and buffer cache size.

When the option is off, each instrumented event costs a relaxed atomic
load and a branch, as with the debug counters behind the performance
panel.

docs/performance-report.md describes each line and how to add a
measurement; the README links to it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- The emulator normally exits through quick_exit, which runs only
  emergency shutdown, and Config had no emergency callback, so the
  report lost everything after its last 5-second block, and a session
  shorter than one interval wrote only the header. Config now has an
  emergency shutdown that stops the report, and stopping it writes the
  time since the last block as a final block marked "last, partial"
  (skipped if shorter than 100 ms). This also covers fatal errors.
- README: only GPU waits and queue submits are grouped by call site.
- docs: in the example, most (not nearly all) queue submits come from
  buffer downloads.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- virtual_memory_allocation_tests aborted on macOS with "mutex lock
  failed: Invalid argument". The test's static Subsystems is created
  before the report's function-local state, so it is destroyed after
  it, and its Config::Shutdown then locked the destroyed mutex (which
  libc++ on macOS reports; Windows does not). The report state is now
  allocated once and never destroyed.
- Note* calls recheck that the report is enabled after taking the lock,
  so an event that raced with stopping the report is not recorded after
  the last block was written.
- A write fault on a page the buffer cache no longer tracks returns
  before any download, but was still reported as one. ReadMemory now
  counts a download only after that check.
- docs: the final partial block needs at least 100 ms, and the
  write-tracking fault total includes read faults.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
DownloadBufferMemory returns false when no GPU-written range needed
copying. ReadMemory now uses that result for the performance report as
well as for unmarking the region, so a fault that copied nothing is no
longer reported as a download.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
NoteDownload now checks Enabled() like the other entry points, so
buffer downloads do no report work when the report is disabled.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- The GPU thread waits at most 100 ms while idle when the report is on,
  so a block is written on time even when no work arrives.
- A download fault is attributed to the most recently bound overlapping
  GPU-written binding, not the one with the highest base.
- The launcher saves the default report file when the field holds only
  spaces.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:07:06 +00:00
github-bot closed this pull request 2026-11-26 10:07:06 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-22 23:53 UTC · original · edited 2026-10-23 06:03 UTC

Review in Change Stack →

📝 Walkthrough

The change adds optional performance reporting with five-second intervals and a configurable output path. Launcher settings and command-line options control reporting. Instrumentation records GPU waits and submits, GPU activity, frame flips, buffer operations, memory-protection timing, and memory-tracking faults. Reports include call-site and memory-region details. The README and a new guide document how to enable and interpret reports.

Suggested reviewers: nmzik

Priority: ➖ Normal

Change: Feature

Merge Risk: 🔵 Low · up to 5ebbd

The report can misidentify the GPU write responsible for an overlapping download fault. This is a bounded diagnostic error; the PR remains mergeable with follow-up.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 8.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 72 functions across 19 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: an optional performance report.
Description check Passed The description directly explains the performance report, its usage, contents, instrumentation, cost, and testing. It is fully related to the changeset.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-22 23:53 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1851#issuecomment-6353929053) · edited 2026-10-23 06:03 UTC <!-- coderabbit-ai-generated:v1 --> <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/1851?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- walkthrough_start --> <details> <summary><strong>📝 Walkthrough</strong></summary> <dl> <dd> The change adds optional performance reporting with five-second intervals and a configurable output path. Launcher settings and command-line options control reporting. Instrumentation records GPU waits and submits, GPU activity, frame flips, buffer operations, memory-protection timing, and memory-tracking faults. Reports include call-site and memory-region details. The README and a new guide document how to enable and interpret reports. **Suggested reviewers:** `nmzik` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"5ebbd5c56a8f9dd9fb233d87a15fbfe5a592a4f7" --> **Change:** Feature <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong>🔵 Low</strong> · up to <code>5ebbd</code></summary> <dl> <dd> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **🔵 Low** · up to `5ebbd` --> <!-- final_review_risk_coverage:{"sourceCommitId":"5ebbd5c56a8f9dd9fb233d87a15fbfe5a592a4f7","coveredCommitId":"5ebbd5c56a8f9dd9fb233d87a15fbfe5a592a4f7","kind":"reviewed"} --> The report can misidentify the GPU write responsible for an overlapping download fault. This is a bounded diagnostic error; the PR remains mergeable with follow-up. <!-- final_review_risk_end --> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4 · <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> 1</strong></summary> <dl> <dd> <strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> Failed checks: 1 warning</strong> | Check name | Status | Explanation | Resolution | | :---------------- | :----------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :--------------------------------------------------------------------------------- | | Docstring Coverage | ![Warning](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-warning.svg) | Docstring coverage is 8.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 72 functions across 19 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> Passed checks: 4 passed</strong></summary> <dl> <dd> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------- | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly and concisely identifies the main change: an optional performance report. | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description directly explains the performance report, its usage, contents, instrumentation, cost, and testing. It is fully related to the changeset. | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | </dd> </dl> </details> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autofix</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts <!-- autopilot:end --> <!-- tips_start --> Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=1851)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>❤️ Share</strong></summary> <dl> <dd> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </dd> </dl> </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-22 23:53 UTC · original · edited 2026-10-23 00:31 UTC
On docs/performance-report.md line 65 (outdated):

@@ -0,0 +1,101 @@
+# Performance report
+
+The performance report is a plain-text summary of where the emulator spends time on the CPU,
+written every 5 seconds while a game runs. It complements the Tracy profiler: Tracy shows what
+each thread was doing, and the report answers *which code path* made the CPU wait for the GPU or
+submit work, and *which guest memory* caused write-tracking faults. These are the questions that
+usually explain a low frame rate.
+
+## Enabling it
+
+- **Launcher:** game settings → *Debugging & logs* → **Performance report**, with the file in
+  **Performance report file**.
+- **Command line:** `--perf-report`, and optionally `--perf-report-file <path>`.
+
+The report is written to `_kyty_perf.txt` by default. A relative path is relative to the
+emulator's working directory, as for the printf output file. The report doesn't depend on the
+logging settings, and the file is replaced each time the emulator starts.
+
+When the option is off, the instrumentation costs a relaxed atomic load and a branch per event.
+When it is on, each GPU wait, queue submit and fault takes a lock to be recorded. In testing, the
+frame rate with the report on was within run-to-run noise of the frame rate with it off.
+
+The GPU command thread writes each block between commands. While it is stuck in one long
+command an interval stretches, so check the interval length printed on each block's first line.
+
+## Reading it
+
+Each block covers one interval. Rates are per second of wall time. `ms/s` is time spent per
+second, so `1000 ms/s` keeps one thread fully busy. Here is an abridged block from a game's main menu:
+
+```
+=== 82.4 s (interval 5.1 s)
+  frames: 3.7/s
+  GPU command thread: idle 4.7%, blocked on guest waits 0.0%
+  GPU waits: 1510.4/s, 136.2 ms/s
+  queue submits: 1775.1/s, 25.3 ms/s
+  write-tracking faults: 16133/s, 385.4 ms/s in the handler (buffer cache 312.6 ms/s, texture cache 1.4 ms/s)
+    read faults: 559/s, 71.4 ms/s
+    faults that downloaded GPU data first: 1516/s, 309.9 ms/s
+    pages: 2/s faulting for the first time, 11296/s faulting again within an interval
+    by thread (19): 3190/s 73.5 ms/s; 504/s 54.3 ms/s; 1136/s 31.4 ms/s; 1136/s 30.6 ms/s;
+  tracking protection changes: 17121/s, 20.9 ms/s waiting for the address-space lock, 23.9 ms/s changing protection
+  buffer uploads: 559/s, 58.3 MB/s
+  BDA synchronization queued: 16541/s, 84.0 MB/s
+  buffer cache: 1418 buffers, 5004.6 MB; 3.7 GC ticks/s
+  GPU waits by call site:
+      1501.7/s     98.4 ms/s  gpu   bufferCache.cpp:238 bool __cdecl Libs::Graphics::BufferCache::DownloadBufferMemory(...) [async = false]
+         7.4/s     37.7 ms/s  other (outside an instrumented scheduler call)
+  queue submits by call site:
+      1503.2/s     20.5 ms/s  gpu   bufferCache.cpp:238 bool __cdecl Libs::Graphics::BufferCache::DownloadBufferMemory(...) [async = false]
+       262.9/s      4.6 ms/s  gpu   graphicsRun.cpp:240 void __cdecl Libs::Graphics::CommandProcessor::BufferFlush(void)
+         3.7/s      0.0 ms/s  gpu   graphicsRun.cpp:1313 void __cdecl Libs::Graphics::CommandProcessor::Flip(void)
+  write-tracking faults by 1 MiB region:
+       133.5/s     57.3 ms/s  0x117b600000
+        70.1/s     31.1 ms/s  0x1176900000
+        ...
+  download faults by the shader write that owns the page:
+       396.6/s    158.2 ms/s  write in 0x1171258040+0xe7fffc0 written by shader 0x11aabeec56222407
+       342.3/s     44.5 ms/s  write in 0x1137c90000+0x1980000 written by shader 0xfe937637dd9037bf
+        ...
+```
+
+In this example the game presents 3.7 frames per second and the GPU command thread is almost never
+idle. Nearly every GPU wait and queue submit comes from synchronous buffer downloads, and the
+faults behind them repeat on the same pages within each interval: guest code keeps writing to

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Use accurate proportions in the example.

The sample shows nearly every GPU wait from synchronous buffer downloads, but only about 85% of queue submits. BufferFlush accounts for 262.9 submits per second. Replace “nearly every GPU wait and queue submit” with “nearly every GPU wait and most queue submits.”

Proposed wording
-Nearly every GPU wait and queue submit comes from synchronous buffer downloads, and the
+Nearly every GPU wait and most queue submits come from synchronous buffer downloads, and the

✅ Addressed in commit f32e7a8

**@⁠coderabbitai[bot]** on GitHub · 2026-10-22 23:53 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1851#discussion_r4354741857) · edited 2026-10-23 00:31 UTC On `docs/performance-report.md` line 65 (outdated): ```diff @@ -0,0 +1,101 @@ +# Performance report + +The performance report is a plain-text summary of where the emulator spends time on the CPU, +written every 5 seconds while a game runs. It complements the Tracy profiler: Tracy shows what +each thread was doing, and the report answers *which code path* made the CPU wait for the GPU or +submit work, and *which guest memory* caused write-tracking faults. These are the questions that +usually explain a low frame rate. + +## Enabling it + +- **Launcher:** game settings → *Debugging & logs* → **Performance report**, with the file in + **Performance report file**. +- **Command line:** `--perf-report`, and optionally `--perf-report-file <path>`. + +The report is written to `_kyty_perf.txt` by default. A relative path is relative to the +emulator's working directory, as for the printf output file. The report doesn't depend on the +logging settings, and the file is replaced each time the emulator starts. + +When the option is off, the instrumentation costs a relaxed atomic load and a branch per event. +When it is on, each GPU wait, queue submit and fault takes a lock to be recorded. In testing, the +frame rate with the report on was within run-to-run noise of the frame rate with it off. + +The GPU command thread writes each block between commands. While it is stuck in one long +command an interval stretches, so check the interval length printed on each block's first line. + +## Reading it + +Each block covers one interval. Rates are per second of wall time. `ms/s` is time spent per +second, so `1000 ms/s` keeps one thread fully busy. Here is an abridged block from a game's main menu: + +``` +=== 82.4 s (interval 5.1 s) + frames: 3.7/s + GPU command thread: idle 4.7%, blocked on guest waits 0.0% + GPU waits: 1510.4/s, 136.2 ms/s + queue submits: 1775.1/s, 25.3 ms/s + write-tracking faults: 16133/s, 385.4 ms/s in the handler (buffer cache 312.6 ms/s, texture cache 1.4 ms/s) + read faults: 559/s, 71.4 ms/s + faults that downloaded GPU data first: 1516/s, 309.9 ms/s + pages: 2/s faulting for the first time, 11296/s faulting again within an interval + by thread (19): 3190/s 73.5 ms/s; 504/s 54.3 ms/s; 1136/s 31.4 ms/s; 1136/s 30.6 ms/s; + tracking protection changes: 17121/s, 20.9 ms/s waiting for the address-space lock, 23.9 ms/s changing protection + buffer uploads: 559/s, 58.3 MB/s + BDA synchronization queued: 16541/s, 84.0 MB/s + buffer cache: 1418 buffers, 5004.6 MB; 3.7 GC ticks/s + GPU waits by call site: + 1501.7/s 98.4 ms/s gpu bufferCache.cpp:238 bool __cdecl Libs::Graphics::BufferCache::DownloadBufferMemory(...) [async = false] + 7.4/s 37.7 ms/s other (outside an instrumented scheduler call) + queue submits by call site: + 1503.2/s 20.5 ms/s gpu bufferCache.cpp:238 bool __cdecl Libs::Graphics::BufferCache::DownloadBufferMemory(...) [async = false] + 262.9/s 4.6 ms/s gpu graphicsRun.cpp:240 void __cdecl Libs::Graphics::CommandProcessor::BufferFlush(void) + 3.7/s 0.0 ms/s gpu graphicsRun.cpp:1313 void __cdecl Libs::Graphics::CommandProcessor::Flip(void) + write-tracking faults by 1 MiB region: + 133.5/s 57.3 ms/s 0x117b600000 + 70.1/s 31.1 ms/s 0x1176900000 + ... + download faults by the shader write that owns the page: + 396.6/s 158.2 ms/s write in 0x1171258040+0xe7fffc0 written by shader 0x11aabeec56222407 + 342.3/s 44.5 ms/s write in 0x1137c90000+0x1980000 written by shader 0xfe937637dd9037bf + ... +``` + +In this example the game presents 3.7 frames per second and the GPU command thread is almost never +idle. Nearly every GPU wait and queue submit comes from synchronous buffer downloads, and the +faults behind them repeat on the same pages within each interval: guest code keeps writing to ``` <!-- coderabbit-ai-generated:v1 --> **🎯 Functional Correctness** | **🟡 Minor** | **⚡ Quick win** **Use accurate proportions in the example.** The sample shows nearly every GPU wait from synchronous buffer downloads, but only about 85% of queue submits. `BufferFlush` accounts for 262.9 submits per second. Replace “nearly every GPU wait and queue submit” with “nearly every GPU wait and most queue submits.” <details> <summary>Proposed wording</summary> ```diff -Nearly every GPU wait and queue submit comes from synchronous buffer downloads, and the +Nearly every GPU wait and most queue submits come from synchronous buffer downloads, and the ``` </details> <!-- fingerprinting:phantom:triton:caracal --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:39619dadb32a147bb11c161f --> <!-- This is an auto-generated comment by CodeRabbit --> ✅ Addressed in commit f32e7a8
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-22 23:53 UTC · original · edited 2026-10-23 00:31 UTC
On README.md line 422 (outdated):

@@ -418,6 +418,9 @@ SDL_VULKAN_LIBRARY=/path/to/libMoltenVK.dylib ./kyty_emulator --game "/games/Exa
 Run `kyty_emulator --help` to see the available graphics, logging, validation, profiling, and
 debugging options.
 
+To investigate a low frame rate, the [performance report](docs/performance-report.md)
+(`--perf-report`) summarizes GPU waits, queue submits, and memory-tracking faults by call site.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Correct the attribution scope.

The report does not summarize memory-tracking faults by call site. It groups faults by 1 MiB region and shader write. Only GPU waits and queue submits have call-site lists.

Proposed wording
--- "a/README.md"
+++ "b/README.md"
@@ -419,7 +419,7 @@
 debugging options.
 
 To investigate a low frame rate, the [performance report](docs/performance-report.md)
-(`--perf-report`) summarizes GPU waits, queue submits, and memory-tracking faults by call site.
+(`--perf-report`) summarizes GPU waits and queue submits by call site, plus memory-tracking fault details.
 
 ### AI Use
 
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

(`--perf-report`) summarizes GPU waits and queue submits by call site, plus memory-tracking fault details.

✅ Addressed in commit f32e7a8

**@⁠coderabbitai[bot]** on GitHub · 2026-10-22 23:53 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1851#discussion_r4354741869) · edited 2026-10-23 00:31 UTC On `README.md` line 422 (outdated): ```diff @@ -418,6 +418,9 @@ SDL_VULKAN_LIBRARY=/path/to/libMoltenVK.dylib ./kyty_emulator --game "/games/Exa Run `kyty_emulator --help` to see the available graphics, logging, validation, profiling, and debugging options. +To investigate a low frame rate, the [performance report](docs/performance-report.md) +(`--perf-report`) summarizes GPU waits, queue submits, and memory-tracking faults by call site. ``` <!-- coderabbit-ai-generated:v1 --> **🎯 Functional Correctness** | **🟡 Minor** | **⚡ Quick win** **Correct the attribution scope.** The report does not summarize memory-tracking faults by call site. It groups faults by 1 MiB region and shader write. Only GPU waits and queue submits have call-site lists. <details> <summary>Proposed wording</summary> ```diff --- "a/README.md" +++ "b/README.md" @@ -419,7 +419,7 @@ debugging options. To investigate a low frame rate, the [performance report](docs/performance-report.md) -(`--perf-report`) summarizes GPU waits, queue submits, and memory-tracking faults by call site. +(`--perf-report`) summarizes GPU waits and queue submits by call site, plus memory-tracking fault details. ### AI Use ``` </details> <!-- suggestion_start --> <details> <summary>📝 Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. ```suggestion (`--perf-report`) summarizes GPU waits and queue submits by call site, plus memory-tracking fault details. ``` </details> <!-- suggestion_end --> <!-- fingerprinting:phantom:triton:caracal --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:4fdbf637fa3189df4cca1ed5 --> <!-- This is an auto-generated comment by CodeRabbit --> ✅ Addressed in commit f32e7a8
@ -0,0 +238,4 @@
}
std::fclose(s.file);
s.file = nullptr;
}
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-22 23:53 UTC · original · edited 2026-10-23 00:31 UTC

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '40,90p' src/emulator.cpp
sed -n '135,190p' src/emulator.cpp
sed -n '1,100p' src/common/subsystems.cpp
rg -n 'at_quick_exit|quick_exit|atexit|EmergencyShutdownActive' src

Repository: KytyPS5/KytyPS5

Length of output: 8627


Write the final partial interval when the report stops.

Normal exit does not write the final partial interval. Execute() ends with std::quick_exit(0), which skips the Subsystems destructor. The at_quick_exit handler runs only Common::Subsystems::EmergencyShutdownActive(), and Config::Lifecycle registers no emergency callback. Explicit Configure(false, ...) also closes s.file without calling WriteInterval. A session shorter than 5 s writes only the header.

Write any non-empty final interval in Configure(false, ...). Register a report-only emergency callback in Config so normal exit reaches it.

Proposed change
--- a/src/common/perfReport.cpp
+++ b/src/common/perfReport.cpp
@@
 	Detail::g_enabled.store(false, std::memory_order_relaxed);
 	if (s.file != nullptr) {
+		const auto now = Detail::NowNs();
+		if (now > s.interval_start) {
+			WriteInterval(s, now);
+		}
 		std::fclose(s.file);
 		s.file = nullptr;
 	}
--- a/src/common/emulatorConfig.h
+++ b/src/common/emulatorConfig.h
@@
 void Initialize();
 void Shutdown();
+void EmergencyShutdown();
 
 struct Lifecycle {
 	static constexpr const char* name       = "Config";
 	static constexpr auto        initialize = Config::Initialize;
 	static constexpr auto        shutdown   = Config::Shutdown;
+	static constexpr auto        emergency_shutdown = Config::EmergencyShutdown;
 };
--- a/src/common/emulatorConfig.cpp
+++ b/src/common/emulatorConfig.cpp
@@
+void EmergencyShutdown() {
+	Common::PerfReport::Configure(false, {});
+}
+
 void Shutdown() {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

void Configure(bool enabled, const std::filesystem::path& file) {
	auto&            s = Get();
	std::scoped_lock guard {s.lock};
	Detail::g_enabled.store(false, std::memory_order_relaxed);
	if (s.file != nullptr) {
		const auto now = Detail::NowNs();
		if (now > s.interval_start) {
			WriteInterval(s, now);
		}
		std::fclose(s.file);
		s.file = nullptr;
	}

✅ Addressed in commit f32e7a8

**@⁠coderabbitai[bot]** on GitHub · 2026-10-22 23:53 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1851#discussion_r4354741888) · edited 2026-10-23 00:31 UTC <!-- coderabbit-ai-generated:v1 --> **🎯 Functional Correctness** | **🟡 Minor** | **⚡ Quick win** <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash sed -n '40,90p' src/emulator.cpp sed -n '135,190p' src/emulator.cpp sed -n '1,100p' src/common/subsystems.cpp rg -n 'at_quick_exit|quick_exit|atexit|EmergencyShutdownActive' src ``` Repository: KytyPS5/KytyPS5 Length of output: 8627 --- </details> **Write the final partial interval when the report stops.** Normal exit does not write the final partial interval. `Execute()` ends with `std::quick_exit(0)`, which skips the `Subsystems` destructor. The `at_quick_exit` handler runs only `Common::Subsystems::EmergencyShutdownActive()`, and `Config::Lifecycle` registers no emergency callback. Explicit `Configure(false, ...)` also closes `s.file` without calling `WriteInterval`. A session shorter than 5 s writes only the header. Write any non-empty final interval in `Configure(false, ...)`. Register a report-only emergency callback in `Config` so normal exit reaches it. <details> <summary>Proposed change</summary> ```diff --- a/src/common/perfReport.cpp +++ b/src/common/perfReport.cpp @@ Detail::g_enabled.store(false, std::memory_order_relaxed); if (s.file != nullptr) { + const auto now = Detail::NowNs(); + if (now > s.interval_start) { + WriteInterval(s, now); + } std::fclose(s.file); s.file = nullptr; } ``` ```diff --- a/src/common/emulatorConfig.h +++ b/src/common/emulatorConfig.h @@ void Initialize(); void Shutdown(); +void EmergencyShutdown(); struct Lifecycle { static constexpr const char* name = "Config"; static constexpr auto initialize = Config::Initialize; static constexpr auto shutdown = Config::Shutdown; + static constexpr auto emergency_shutdown = Config::EmergencyShutdown; }; ``` ```diff --- a/src/common/emulatorConfig.cpp +++ b/src/common/emulatorConfig.cpp @@ +void EmergencyShutdown() { + Common::PerfReport::Configure(false, {}); +} + void Shutdown() { ``` </details> <!-- suggestion_start --> <details> <summary>📝 Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. ```suggestion void Configure(bool enabled, const std::filesystem::path& file) { auto& s = Get(); std::scoped_lock guard {s.lock}; Detail::g_enabled.store(false, std::memory_order_relaxed); if (s.file != nullptr) { const auto now = Detail::NowNs(); if (now > s.interval_start) { WriteInterval(s, now); } std::fclose(s.file); s.file = nullptr; } ``` </details> <!-- suggestion_end --> <!-- fingerprinting:phantom:medusa:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:aab5e375412ef63341430782 --> <!-- This is an auto-generated comment by CodeRabbit --> ✅ Addressed in commit f32e7a8
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-22 23:53 UTC · original · reviewed

Actionable comments posted: 3


ℹ️ Review info
⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between 79837b423d and c23cc2b7df.

📒 Files selected for processing: 23
  • README.md
  • docs/performance-report.md
  • src/common/emulatorConfig.cpp
  • src/common/emulatorConfig.h
  • src/common/perfReport.cpp
  • src/common/perfReport.h
  • src/graphics/guest_gpu/graphicsRun.cpp
  • src/graphics/host_gpu/memoryTracker.cpp
  • src/graphics/host_gpu/renderer/cache/bufferCache.cpp
  • src/graphics/host_gpu/renderer/commandScheduler.cpp
  • src/graphics/host_gpu/renderer/commandScheduler.h
  • src/graphics/host_gpu/renderer/masterSemaphore.cpp
  • src/graphics/host_gpu/renderer/pipeline/descriptors.cpp
  • src/graphics/host_gpu/renderer/renderContext.cpp
  • src/graphics/presentation/videoOut.cpp
  • src/kernel/memory.cpp
  • src/kernel/memoryAddressSpace.inc
  • src/launcher/forms/configuration_edit_dialog.ui
  • src/launcher/include/configuration.h
  • src/launcher/src/configuration.cpp
  • src/launcher/src/configurationEditDialog.cpp
  • src/launcher/src/mainDialog.cpp
  • src/main.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-22 23:53 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1851#pullrequestreview-5622322397) · **reviewed** <!-- coderabbit-ai-generated:v1 --> **Actionable comments posted: 3** --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/79837b423dd035b34b2dc476e1d2dce8ae0d18bf/.coderabbit.yaml>) - **Commit**: [79837b4](<https://github.com/KytyPS5/KytyPS5/commit/79837b423dd035b34b2dc476e1d2dce8ae0d18bf>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `7d60ebbe-5415-4c31-8741-dd37bbd62c82` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 79837b423dd035b34b2dc476e1d2dce8ae0d18bf and c23cc2b7df735482658229e02fdbc49f494eb513. </details> <details> <summary>📒 Files selected for processing: 23</summary> * `README.md` * `docs/performance-report.md` * `src/common/emulatorConfig.cpp` * `src/common/emulatorConfig.h` * `src/common/perfReport.cpp` * `src/common/perfReport.h` * `src/graphics/guest_gpu/graphicsRun.cpp` * `src/graphics/host_gpu/memoryTracker.cpp` * `src/graphics/host_gpu/renderer/cache/bufferCache.cpp` * `src/graphics/host_gpu/renderer/commandScheduler.cpp` * `src/graphics/host_gpu/renderer/commandScheduler.h` * `src/graphics/host_gpu/renderer/masterSemaphore.cpp` * `src/graphics/host_gpu/renderer/pipeline/descriptors.cpp` * `src/graphics/host_gpu/renderer/renderContext.cpp` * `src/graphics/presentation/videoOut.cpp` * `src/kernel/memory.cpp` * `src/kernel/memoryAddressSpace.inc` * `src/launcher/forms/configuration_edit_dialog.ui` * `src/launcher/include/configuration.h` * `src/launcher/src/configuration.cpp` * `src/launcher/src/configurationEditDialog.cpp` * `src/launcher/src/mainDialog.cpp` * `src/main.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=85123b89-2680-4ae6-bc42-158e6e811231 attempt=74a6dd68-796c-42c2-8ad4-6095949d3c2d batch=1/1 -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-23 00:40 UTC · original · reviewed

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (5)

🟡 Minor · Recheck reporting after acquiring s.lock. · perfReport.cpp:223-236

src/common/perfReport.cpp:223-236
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Recheck reporting after acquiring s.lock.

NoteGpuWait checks Enabled() before acquiring s.lock. During emergency shutdown, Configure(false, {}) can write and close the final interval before a previously admitted call acquires the lock. The call then updates report state after the final block, so the event is lost. It does not access s.file, so this does not cause a closed-file access.

Apply the same guard to the other lock-taking Note* functions.

Suggested fix
 	std::scoped_lock guard {s.lock};
+	if (!Enabled()) {
+		return;
+	}
 	s.waits[std::move(name)].Add(elapsed);
🟡 Minor · Make fault reporting failure-safe. · renderContext.cpp:58-76

src/graphics/host_gpu/renderer/renderContext.cpp:58-76
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Make fault reporting failure-safe.

When reporting is enabled, NoteFault performs allocating map operations. A mapped fault reaches this call from HandleFault, which is noexcept. If an allocation throws, the exception escapes HandleFault and calls std::terminate, terminating the emulator. Catch reporting exceptions and preserve fault handling when the optional report cannot record the event.

Suggested fix
-	Common::PerfReport::NoteFault(fault_vaddr, access == PageFaultAccess::Write, start, buffer_done,
-	                              Common::PerfReport::DownloadCount() != downloads);
+	try {
+		Common::PerfReport::NoteFault(fault_vaddr, access == PageFaultAccess::Write, start, buffer_done,
+		                              Common::PerfReport::DownloadCount() != downloads);
+	} catch (...) {
+		// Optional performance reporting must not terminate fault handling.
+	}
🟡 Minor · Count downloads only after the write-range guard. · bufferCache.cpp:305-325

src/graphics/host_gpu/renderer/cache/bufferCache.cpp:305-325
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Count downloads only after the write-range guard.

ReadMemory increments the fault thread's counter before the GPU callback checks is_write && !IsRegionRegistered(...). When the guard returns, HandleFault still sees the counter increase and reports the write fault as a GPU download. Keep the counter update on the calling thread, because HandleFault reads its thread-local value.

Suggested fix
 void BufferCache::ReadMemory(uint64_t vaddr, uint64_t size, bool is_write) {
-	// Lets a fault handler on this thread report that it waited for a download.
-	Common::PerfReport::NoteDownload();
 	if (!GuestGpu::IsGpuThread() && CommandScheduler::InDeferredOperation()) {
 		EXIT("unsupported buffer readback from an asynchronous GPU completion, "
 		     "addr=0x%016" PRIx64 " size=0x%016" PRIx64 "\n",
 		     vaddr, size);
 	}
-	m_scheduler.Context().GetGpu().SendCommandSync([this, vaddr, size, is_write] {
+	bool note_download = !is_write;
+	m_scheduler.Context().GetGpu().SendCommandSync([this, vaddr, size, is_write, &note_download] {
 		if (is_write && !IsRegionRegistered(vaddr, size)) {
 			return;
 		}
+		note_download = true;
 		auto& buffer = m_slot_buffers[FindBuffer(vaddr, size)];
 
 		if (DownloadBufferMemory<false>(buffer, vaddr, size)) {
 			m_memory_tracker.UnmarkRegionAsGpuModified(vaddr, size);
@@
 			m_memory_tracker.MarkRegionAsCpuModified(vaddr, size);
 		}
 	});
+	if (note_download) {
+		// Lets a fault handler on this thread report that it waited for a download.
+		Common::PerfReport::NoteDownload();
+	}
 }
🟡 Minor · Document the 100 ms exception for the final block. · performance-report.md:25-26

docs/performance-report.md:25-26
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Document the 100 ms exception for the final block.

Configure(false, ...) writes the final block only when at least 100 ms have elapsed since the last block. A session that ends sooner produces no final block, so the current wording overstates the behavior.

Suggested fix
-When the emulator exits, including on a fatal error, the time since the last block is written as
-a final block marked "last, partial", so even a session shorter than one interval gets a report.
+When the emulator exits, including on a fatal error, the time since the last block is written as
+a final block marked "last, partial" if at least 100 ms have elapsed. A session that ends sooner
+does not get a final block.
🟡 Minor · Describe the total fault metric as guest reads and writes. · performance-report.md:78

docs/performance-report.md:78
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Describe the total fault metric as guest reads and writes.

NoteFault adds every handled fault to the total, then records read faults separately. The documentation currently says that write-tracking faults measures guest writes only. Change the description to “Guest reads and writes...” so readers interpret the total correctly.

Suggested fix
-| `write-tracking faults` | Guest writes to memory the GPU caches track, and the time spent in the fault handler. | The handler runs on the faulting game thread, so this time blocks the game directly. |
+| `write-tracking faults` | Guest reads and writes to memory the GPU caches track, and the time spent in the fault handler. | The handler runs on the faulting game thread, so this time blocks the game directly. |

ℹ️ Review info
⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between c23cc2b7df and f32e7a8488.

📒 Files selected for processing: 6
  • README.md
  • docs/performance-report.md
  • src/common/emulatorConfig.cpp
  • src/common/emulatorConfig.h
  • src/common/perfReport.cpp
  • src/common/perfReport.h
🚧 Files skipped from review as they are similar to previous changes: 5
  • README.md
  • src/common/emulatorConfig.h
  • docs/performance-report.md
  • src/common/emulatorConfig.cpp
  • src/common/perfReport.h

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-23 00:40 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1851#pullrequestreview-5622615536) · **reviewed** <!-- coderabbit-ai-generated:v1 --> > [!CAUTION] > Some comments are outside the diff and can’t be posted inline due to GitHub limitations. > > **⚠️ Outside diff range comments (5)** > > <details> > <summary><strong>🟡 Minor</strong> · Recheck reporting after acquiring <code>s.lock</code>. · <code>perfReport.cpp:223-236</code></summary><blockquote> > > `src/common/perfReport.cpp:223-236` > **🎯 Functional Correctness** | **🟡 Minor** | **⚡ Quick win** > > **Recheck reporting after acquiring `s.lock`.** > > `NoteGpuWait` checks `Enabled()` before acquiring `s.lock`. During emergency shutdown, `Configure(false, {})` can write and close the final interval before a previously admitted call acquires the lock. The call then updates report state after the final block, so the event is lost. It does not access `s.file`, so this does not cause a closed-file access. > > Apply the same guard to the other lock-taking `Note*` functions. > > <details> > <summary>Suggested fix</summary> > > ```diff > std::scoped_lock guard {s.lock}; > + if (!Enabled()) { > + return; > + } > s.waits[std::move(name)].Add(elapsed); > ``` > > </details> > > <!-- cr-comment:v1:274b5746732c58bd82c58568 --> > > </blockquote></details> > <details> > <summary><strong>🟡 Minor</strong> · Make fault reporting failure-safe. · <code>renderContext.cpp:58-76</code></summary><blockquote> > > `src/graphics/host_gpu/renderer/renderContext.cpp:58-76` > **🩺 Stability & Availability** | **🟡 Minor** | **⚡ Quick win** > > **Make fault reporting failure-safe.** > > When reporting is enabled, `NoteFault` performs allocating map operations. A mapped fault reaches this call from `HandleFault`, which is `noexcept`. If an allocation throws, the exception escapes `HandleFault` and calls `std::terminate`, terminating the emulator. Catch reporting exceptions and preserve fault handling when the optional report cannot record the event. > > <details> > <summary>Suggested fix</summary> > > ```diff > - Common::PerfReport::NoteFault(fault_vaddr, access == PageFaultAccess::Write, start, buffer_done, > - Common::PerfReport::DownloadCount() != downloads); > + try { > + Common::PerfReport::NoteFault(fault_vaddr, access == PageFaultAccess::Write, start, buffer_done, > + Common::PerfReport::DownloadCount() != downloads); > + } catch (...) { > + // Optional performance reporting must not terminate fault handling. > + } > ``` > > </details> > > <!-- cr-comment:v1:f42cb18dab47f15a53f64dd6 --> > > </blockquote></details> > <details> > <summary><strong>🟡 Minor</strong> · Count downloads only after the write-range guard. · <code>bufferCache.cpp:305-325</code></summary><blockquote> > > `src/graphics/host_gpu/renderer/cache/bufferCache.cpp:305-325` > **🎯 Functional Correctness** | **🟡 Minor** | **⚡ Quick win** > > **Count downloads only after the write-range guard.** > > `ReadMemory` increments the fault thread's counter before the GPU callback checks `is_write && !IsRegionRegistered(...)`. When the guard returns, `HandleFault` still sees the counter increase and reports the write fault as a GPU download. Keep the counter update on the calling thread, because `HandleFault` reads its thread-local value. > > <details> > <summary>Suggested fix</summary> > > ```diff > void BufferCache::ReadMemory(uint64_t vaddr, uint64_t size, bool is_write) { > - // Lets a fault handler on this thread report that it waited for a download. > - Common::PerfReport::NoteDownload(); > if (!GuestGpu::IsGpuThread() && CommandScheduler::InDeferredOperation()) { > EXIT("unsupported buffer readback from an asynchronous GPU completion, " > "addr=0x%016" PRIx64 " size=0x%016" PRIx64 "\n", > vaddr, size); > } > - m_scheduler.Context().GetGpu().SendCommandSync([this, vaddr, size, is_write] { > + bool note_download = !is_write; > + m_scheduler.Context().GetGpu().SendCommandSync([this, vaddr, size, is_write, &note_download] { > if (is_write && !IsRegionRegistered(vaddr, size)) { > return; > } > + note_download = true; > auto& buffer = m_slot_buffers[FindBuffer(vaddr, size)]; > > if (DownloadBufferMemory<false>(buffer, vaddr, size)) { > m_memory_tracker.UnmarkRegionAsGpuModified(vaddr, size); > @@ > m_memory_tracker.MarkRegionAsCpuModified(vaddr, size); > } > }); > + if (note_download) { > + // Lets a fault handler on this thread report that it waited for a download. > + Common::PerfReport::NoteDownload(); > + } > } > ``` > > </details> > > <!-- cr-comment:v1:8b1b8c72c95aa478ff3898c2 --> > > </blockquote></details> > <details> > <summary><strong>🟡 Minor</strong> · Document the 100 ms exception for the final block. · <code>performance-report.md:25-26</code></summary><blockquote> > > `docs/performance-report.md:25-26` > **🎯 Functional Correctness** | **🟡 Minor** | **⚡ Quick win** > > **Document the 100 ms exception for the final block.** > > `Configure(false, ...)` writes the final block only when at least 100 ms have elapsed since the last block. A session that ends sooner produces no final block, so the current wording overstates the behavior. > > <details> > <summary>Suggested fix</summary> > > ```diff > -When the emulator exits, including on a fatal error, the time since the last block is written as > -a final block marked "last, partial", so even a session shorter than one interval gets a report. > +When the emulator exits, including on a fatal error, the time since the last block is written as > +a final block marked "last, partial" if at least 100 ms have elapsed. A session that ends sooner > +does not get a final block. > ``` > > </details> > > <!-- cr-comment:v1:122613300507c4ce56de19af --> > > </blockquote></details> > <details> > <summary><strong>🟡 Minor</strong> · Describe the total fault metric as guest reads and writes. · <code>performance-report.md:78</code></summary><blockquote> > > `docs/performance-report.md:78` > **📐 Maintainability & Code Quality** | **🟡 Minor** | **⚡ Quick win** > > **Describe the total fault metric as guest reads and writes.** > > `NoteFault` adds every handled fault to the total, then records read faults separately. The documentation currently says that `write-tracking faults` measures guest writes only. Change the description to “Guest reads and writes...” so readers interpret the total correctly. > > <details> > <summary>Suggested fix</summary> > > ```diff > -| `write-tracking faults` | Guest writes to memory the GPU caches track, and the time spent in the fault handler. | The handler runs on the faulting game thread, so this time blocks the game directly. | > +| `write-tracking faults` | Guest reads and writes to memory the GPU caches track, and the time spent in the fault handler. | The handler runs on the faulting game thread, so this time blocks the game directly. | > ``` > > </details> > > <!-- cr-comment:v1:3e7771bbc2ff3e7362cb82d5 --> > > </blockquote></details> --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/79837b423dd035b34b2dc476e1d2dce8ae0d18bf/.coderabbit.yaml>) - **Commit**: [79837b4](<https://github.com/KytyPS5/KytyPS5/commit/79837b423dd035b34b2dc476e1d2dce8ae0d18bf>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `9aab107a-4fd9-4ddc-b5d7-1d8e25f8d2a8` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between c23cc2b7df735482658229e02fdbc49f494eb513 and f32e7a8488c02fe3da81ef21ed9fbdedab36d1c6. </details> <details> <summary>📒 Files selected for processing: 6</summary> * `README.md` * `docs/performance-report.md` * `src/common/emulatorConfig.cpp` * `src/common/emulatorConfig.h` * `src/common/perfReport.cpp` * `src/common/perfReport.h` </details> <details> <summary>🚧 Files skipped from review as they are similar to previous changes: 5</summary> * README.md * src/common/emulatorConfig.h * docs/performance-report.md * src/common/emulatorConfig.cpp * src/common/perfReport.h </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=3467f996-84ad-4adf-b78f-5df6bf46e19a attempt=692a1de4-ebf5-4cc0-9be9-5a8d2cc073f5 batch=1/1 -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-23 01:12 UTC · original · edited 2026-10-23 01:42 UTC
On src/graphics/host_gpu/renderer/cache/bufferCache.cpp line 316 (outdated):

@@ -307,10 +308,12 @@ void BufferCache::ReadMemory(uint64_t vaddr, uint64_t size, bool is_write) {
 		     "addr=0x%016" PRIx64 " size=0x%016" PRIx64 "\n",
 		     vaddr, size);
 	}
-	m_scheduler.Context().GetGpu().SendCommandSync([this, vaddr, size, is_write] {
+	bool downloaded = false;
+	m_scheduler.Context().GetGpu().SendCommandSync([this, vaddr, size, is_write, &downloaded] {
 		if (is_write && !IsRegionRegistered(vaddr, size)) {
 			return;
 		}
+		downloaded = true;

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Count a download only when buffer data was copied.

If DownloadBufferMemory<false>() finds no copies, it returns false. This assignment still causes NoteDownload() to run after the callback. RenderContext::HandleFault() then reports a downloaded fault even though no buffer download occurred. Assign the return value of DownloadBufferMemory<false>() to downloaded, and use that value for both the unmark operation and NoteDownload().

✅ Addressed in commit b57a503

**@⁠coderabbitai[bot]** on GitHub · 2026-10-23 01:12 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1851#discussion_r4355155178) · edited 2026-10-23 01:42 UTC On `src/graphics/host_gpu/renderer/cache/bufferCache.cpp` line 316 (outdated): ```diff @@ -307,10 +308,12 @@ void BufferCache::ReadMemory(uint64_t vaddr, uint64_t size, bool is_write) { "addr=0x%016" PRIx64 " size=0x%016" PRIx64 "\n", vaddr, size); } - m_scheduler.Context().GetGpu().SendCommandSync([this, vaddr, size, is_write] { + bool downloaded = false; + m_scheduler.Context().GetGpu().SendCommandSync([this, vaddr, size, is_write, &downloaded] { if (is_write && !IsRegionRegistered(vaddr, size)) { return; } + downloaded = true; ``` <!-- coderabbit-ai-generated:v1 --> **🎯 Functional Correctness** | **🟡 Minor** | **⚡ Quick win** **Count a download only when buffer data was copied.** If `DownloadBufferMemory<false>()` finds no copies, it returns `false`. This assignment still causes `NoteDownload()` to run after the callback. `RenderContext::HandleFault()` then reports a downloaded fault even though no buffer download occurred. Assign the return value of `DownloadBufferMemory<false>()` to `downloaded`, and use that value for both the unmark operation and `NoteDownload()`. <!-- fingerprinting:phantom:poseidon:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:614922dcb54140c734d42432 --> <!-- This is an auto-generated comment by CodeRabbit --> ✅ Addressed in commit b57a503
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-23 01:12 UTC · original · reviewed

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between f32e7a8488 and 284607f0f4.

📒 Files selected for processing: 3
  • docs/performance-report.md
  • src/common/perfReport.cpp
  • src/graphics/host_gpu/renderer/cache/bufferCache.cpp
🚧 Files skipped from review as they are similar to previous changes: 1
  • docs/performance-report.md

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-23 01:12 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1851#pullrequestreview-5622797390) · **reviewed** <!-- coderabbit-ai-generated:v1 --> **Actionable comments posted: 1** --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/79837b423dd035b34b2dc476e1d2dce8ae0d18bf/.coderabbit.yaml>) - **Commit**: [79837b4](<https://github.com/KytyPS5/KytyPS5/commit/79837b423dd035b34b2dc476e1d2dce8ae0d18bf>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `6282cddf-dbd8-4c26-b8db-f0dad86e6af5` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between f32e7a8488c02fe3da81ef21ed9fbdedab36d1c6 and 284607f0f4d5b04e99ade80ae2e1f6a94c8d969c. </details> <details> <summary>📒 Files selected for processing: 3</summary> * `docs/performance-report.md` * `src/common/perfReport.cpp` * `src/graphics/host_gpu/renderer/cache/bufferCache.cpp` </details> <details> <summary>🚧 Files skipped from review as they are similar to previous changes: 1</summary> * docs/performance-report.md </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=114538f8-418a-498e-95fb-e845008961d2 attempt=b7e791a0-4a93-4a09-8f77-5b4bb0e710bf batch=1/1 -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-23 01:47 UTC · original · reviewed

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟡 Minor · Guard NoteDownload() when reporting is disabled. · perfReport.h:81-83

src/common/perfReport.h:81-83
🚀 Performance & Scalability | 🟡 Minor | ⚡ Quick win

Guard NoteDownload() when reporting is disabled.

NoteDownload() is called for each successful buffer download, but it always performs ++Detail::g_downloads. This adds one atomic counter increment per download even when Enabled() is false, which violates the documented disabled-instrumentation contract and adds avoidable overhead to the download path. Guard the shared function so enabled reporting and the existing fault/download distinction remain unchanged.

Suggested fix
 inline void NoteDownload() noexcept {
-	++Detail::g_downloads;
+	if (Enabled()) {
+		++Detail::g_downloads;
+	}
 }

ℹ️ Review info
⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between 284607f0f4 and b57a503034.

📒 Files selected for processing: 1
  • src/graphics/host_gpu/renderer/cache/bufferCache.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-23 01:47 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1851#pullrequestreview-5622993491) · **reviewed** <!-- coderabbit-ai-generated:v1 --> > [!CAUTION] > Some comments are outside the diff and can’t be posted inline due to GitHub limitations. > > **⚠️ Outside diff range comments (1)** > > <details> > <summary><strong>🟡 Minor</strong> · Guard <code>NoteDownload()</code> when reporting is disabled. · <code>perfReport.h:81-83</code></summary><blockquote> > > `src/common/perfReport.h:81-83` > **🚀 Performance & Scalability** | **🟡 Minor** | **⚡ Quick win** > > **Guard `NoteDownload()` when reporting is disabled.** > > `NoteDownload()` is called for each successful buffer download, but it always performs `++Detail::g_downloads`. This adds one atomic counter increment per download even when `Enabled()` is false, which violates the documented disabled-instrumentation contract and adds avoidable overhead to the download path. Guard the shared function so enabled reporting and the existing fault/download distinction remain unchanged. > > <details> > <summary>Suggested fix</summary> > > ```diff > inline void NoteDownload() noexcept { > - ++Detail::g_downloads; > + if (Enabled()) { > + ++Detail::g_downloads; > + } > } > ``` > > </details> > > <!-- cr-comment:v1:be92e7de0af5e2d0c53c4949 --> > > </blockquote></details> --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/79837b423dd035b34b2dc476e1d2dce8ae0d18bf/.coderabbit.yaml>) - **Commit**: [79837b4](<https://github.com/KytyPS5/KytyPS5/commit/79837b423dd035b34b2dc476e1d2dce8ae0d18bf>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `fead853e-a40a-490f-892a-ab4b03586e5c` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 284607f0f4d5b04e99ade80ae2e1f6a94c8d969c and b57a503034b89eee5129cdee71b96d440ff2ac55. </details> <details> <summary>📒 Files selected for processing: 1</summary> * `src/graphics/host_gpu/renderer/cache/bufferCache.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=3695ce80-0fec-4564-a139-3d04a7caa93c attempt=e902052e-b3c5-4649-98ab-367590e4d946 batch=1/1 -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-23 02:19 UTC · original · reviewed

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (3)

🟡 Minor · Use the default for whitespace-only launcher paths. · configurationEditDialog.cpp:522-523

src/launcher/src/configurationEditDialog.cpp:522-523
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Use the default for whitespace-only launcher paths.

When the report is enabled, a user can replace the default with spaces after the toggle handler runs. save() accepts that value because it checks only isEmpty(). The launcher then passes it unchanged to Configure. On Windows, _wfopen receives an all-space filename and cannot open it, so the enabled report produces no file. Normalize only in the launcher UI path so direct --perf-report-file values keep their existing CLI behavior.

Suggested fix
 	info.perf_report_enabled = ui.checkBox_perf_report->isChecked();
-	info.perf_report_file    = ui.lineEdit_perf_report_file->text();
+	const auto perf_report_file = ui.lineEdit_perf_report_file->text();
+	info.perf_report_file = info.perf_report_enabled && perf_report_file.trimmed().isEmpty()
+	                          ? QString::fromLatin1(Configuration::DEFAULT_PERF_REPORT_FILE)
+	                          : perf_report_file;
🟡 Minor · Wake the report check during GPU idle waits. · graphicsRun.cpp:443-456

src/graphics/guest_gpu/graphicsRun.cpp:443-456
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Wake the report check during GPU idle waits.

When reporting is enabled, an idle GPU thread can remain in m_work_available.Wait() past the five-second report deadline. The next block is then delayed until work or shutdown wakes the thread, and its interval includes measurements from that extra idle time. The documented long-command exception does not cover this case because no command is running.

Use a bounded wait only while reporting is enabled, then call MaybeWrite() after releasing m_queue_mutex.

Suggested fix
 	for (;;) {
 		Common::PerfReport::MaybeWrite();
 		Submission                   submission;
 		Common::UniqueFunction<void> command;
 		bool                         has_submission = false;
 		bool                         should_stop    = false;
+		bool                         idle_timeout   = false;
 		{
 			Common::LockGuard lock(gpu->m_queue_mutex);
 			while (gpu->m_commands.empty() && gpu->m_submission_count == 0 && !gpu->m_stopping) {
 				gpu->m_processing = false;
 				gpu->m_idle.Signal();
 				const auto idle_start = Common::PerfReport::Now();
-				gpu->m_work_available.Wait(&gpu->m_queue_mutex);
+				if (Common::PerfReport::Enabled()) {
+					idle_timeout = !gpu->m_work_available.WaitFor(&gpu->m_queue_mutex, 100'000);
+				} else {
+					gpu->m_work_available.Wait(&gpu->m_queue_mutex);
+				}
 				Common::PerfReport::NoteGpuIdle(idle_start);
+				if (idle_timeout) {
+					break;
+				}
 			}
-			if (gpu->m_stopping && gpu->m_commands.empty() && gpu->m_submission_count == 0) {
+			if (idle_timeout) {
+				// Check the report after releasing m_queue_mutex.
+			} else if (gpu->m_stopping && gpu->m_commands.empty() && gpu->m_submission_count == 0) {
 				gpu->m_processing = false;
 				gpu->m_idle.SignalAll();
 				should_stop = true;
 			} else if (!gpu->m_commands.empty()) {
 				command = std::move(gpu->m_commands.front());
@@
 				gpu->m_processing = true;
 				has_submission    = true;
 			}
 		}
+		if (idle_timeout) {
+			Common::PerfReport::MaybeWrite();
+			continue;
+		}
 		if (should_stop) {
🟡 Minor · Select the most recent covering GPU binding. · perfReport.cpp:349-369

src/common/perfReport.cpp:349-369
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Select the most recent covering GPU binding.

FindBuffers can record overlapping writable descriptors. If an older binding starts at 0x2000 and a newer binding starts at 0x1000, a fault at 0x2800 is covered by both bindings. NoteFault checks the higher base first, so it reports the older shader instead of the most recent binding. This makes the performance report attribute the download fault to the wrong shader. Fix the lookup in perfReport.cpp; changing the documentation would not correct the report.

Suggested fix
 struct GpuWrite {
 	uint64_t size        = 0;
 	uint64_t shader_hash = 0;
+	uint64_t order       = 0;
 };
@@
 	std::map<uint64_t, GpuWrite>          gpu_writes;   // by base address
+	uint64_t                              gpu_write_order = 0;
@@
-	// Find the GPU-written binding that covers the page. Bindings can nest, so look back a few.
+	// Find the most recent GPU-written binding that covers the page. Bindings can nest.
 	const GpuWrite* owner = nullptr;
 	uint64_t        base  = 0;
-	auto            it    = s.gpu_writes.upper_bound(address);
-	for (int i = 0; i < 64 && it != s.gpu_writes.begin(); i++) {
-		--it;
-		if (address < it->first + it->second.size) {
-			owner = &it->second;
-			base  = it->first;
-			break;
+	for (const auto& [candidate_base, candidate] : s.gpu_writes) {
+		if (candidate_base <= address && address - candidate_base < candidate.size &&
+		    (owner == nullptr || candidate.order > owner->order)) {
+			owner = &candidate;
+			base  = candidate_base;
 		}
 	}
@@
 	auto& entry       = s.gpu_writes[address];
 	entry.size        = std::max(entry.size, size);
 	entry.shader_hash = shader_hash;
+	entry.order       = ++s.gpu_write_order;
 }

ℹ️ Review info
⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between b57a503034 and 9b9afc9979.

📒 Files selected for processing: 1
  • src/common/perfReport.h

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-23 02:19 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1851#pullrequestreview-5623168792) · **reviewed** <!-- coderabbit-ai-generated:v1 --> > [!CAUTION] > Some comments are outside the diff and can’t be posted inline due to GitHub limitations. > > **⚠️ Outside diff range comments (3)** > > <details> > <summary><strong>🟡 Minor</strong> · Use the default for whitespace-only launcher paths. · <code>configurationEditDialog.cpp:522-523</code></summary><blockquote> > > `src/launcher/src/configurationEditDialog.cpp:522-523` > **🩺 Stability & Availability** | **🟡 Minor** | **⚡ Quick win** > > **Use the default for whitespace-only launcher paths.** > > When the report is enabled, a user can replace the default with spaces after the toggle handler runs. `save()` accepts that value because it checks only `isEmpty()`. The launcher then passes it unchanged to `Configure`. On Windows, `_wfopen` receives an all-space filename and cannot open it, so the enabled report produces no file. Normalize only in the launcher UI path so direct `--perf-report-file` values keep their existing CLI behavior. > > <details> > <summary>Suggested fix</summary> > > ```diff > info.perf_report_enabled = ui.checkBox_perf_report->isChecked(); > - info.perf_report_file = ui.lineEdit_perf_report_file->text(); > + const auto perf_report_file = ui.lineEdit_perf_report_file->text(); > + info.perf_report_file = info.perf_report_enabled && perf_report_file.trimmed().isEmpty() > + ? QString::fromLatin1(Configuration::DEFAULT_PERF_REPORT_FILE) > + : perf_report_file; > ``` > > </details> > > <!-- cr-comment:v1:aa9077b2e04b0411419ded21 --> > > </blockquote></details> > <details> > <summary><strong>🟡 Minor</strong> · Wake the report check during GPU idle waits. · <code>graphicsRun.cpp:443-456</code></summary><blockquote> > > `src/graphics/guest_gpu/graphicsRun.cpp:443-456` > **🎯 Functional Correctness** | **🟡 Minor** | **⚡ Quick win** > > **Wake the report check during GPU idle waits.** > > When reporting is enabled, an idle GPU thread can remain in `m_work_available.Wait()` past the five-second report deadline. The next block is then delayed until work or shutdown wakes the thread, and its interval includes measurements from that extra idle time. The documented long-command exception does not cover this case because no command is running. > > Use a bounded wait only while reporting is enabled, then call `MaybeWrite()` after releasing `m_queue_mutex`. > > <details><summary>Suggested fix</summary> > > ```diff > for (;;) { > Common::PerfReport::MaybeWrite(); > Submission submission; > Common::UniqueFunction<void> command; > bool has_submission = false; > bool should_stop = false; > + bool idle_timeout = false; > { > Common::LockGuard lock(gpu->m_queue_mutex); > while (gpu->m_commands.empty() && gpu->m_submission_count == 0 && !gpu->m_stopping) { > gpu->m_processing = false; > gpu->m_idle.Signal(); > const auto idle_start = Common::PerfReport::Now(); > - gpu->m_work_available.Wait(&gpu->m_queue_mutex); > + if (Common::PerfReport::Enabled()) { > + idle_timeout = !gpu->m_work_available.WaitFor(&gpu->m_queue_mutex, 100'000); > + } else { > + gpu->m_work_available.Wait(&gpu->m_queue_mutex); > + } > Common::PerfReport::NoteGpuIdle(idle_start); > + if (idle_timeout) { > + break; > + } > } > - if (gpu->m_stopping && gpu->m_commands.empty() && gpu->m_submission_count == 0) { > + if (idle_timeout) { > + // Check the report after releasing m_queue_mutex. > + } else if (gpu->m_stopping && gpu->m_commands.empty() && gpu->m_submission_count == 0) { > gpu->m_processing = false; > gpu->m_idle.SignalAll(); > should_stop = true; > } else if (!gpu->m_commands.empty()) { > command = std::move(gpu->m_commands.front()); > @@ > gpu->m_processing = true; > has_submission = true; > } > } > + if (idle_timeout) { > + Common::PerfReport::MaybeWrite(); > + continue; > + } > if (should_stop) { > ``` > > </details> > > <!-- cr-comment:v1:4fa0b26ee885f10334f28489 --> > > </blockquote></details> > <details> > <summary><strong>🟡 Minor</strong> · Select the most recent covering GPU binding. · <code>perfReport.cpp:349-369</code></summary><blockquote> > > `src/common/perfReport.cpp:349-369` > **🎯 Functional Correctness** | **🟡 Minor** | **⚡ Quick win** > > **Select the most recent covering GPU binding.** > > `FindBuffers` can record overlapping writable descriptors. If an older binding starts at `0x2000` and a newer binding starts at `0x1000`, a fault at `0x2800` is covered by both bindings. `NoteFault` checks the higher base first, so it reports the older shader instead of the most recent binding. This makes the performance report attribute the download fault to the wrong shader. Fix the lookup in `perfReport.cpp`; changing the documentation would not correct the report. > > <details> > <summary>Suggested fix</summary> > > ```diff > struct GpuWrite { > uint64_t size = 0; > uint64_t shader_hash = 0; > + uint64_t order = 0; > }; > @@ > std::map<uint64_t, GpuWrite> gpu_writes; // by base address > + uint64_t gpu_write_order = 0; > @@ > - // Find the GPU-written binding that covers the page. Bindings can nest, so look back a few. > + // Find the most recent GPU-written binding that covers the page. Bindings can nest. > const GpuWrite* owner = nullptr; > uint64_t base = 0; > - auto it = s.gpu_writes.upper_bound(address); > - for (int i = 0; i < 64 && it != s.gpu_writes.begin(); i++) { > - --it; > - if (address < it->first + it->second.size) { > - owner = &it->second; > - base = it->first; > - break; > + for (const auto& [candidate_base, candidate] : s.gpu_writes) { > + if (candidate_base <= address && address - candidate_base < candidate.size && > + (owner == nullptr || candidate.order > owner->order)) { > + owner = &candidate; > + base = candidate_base; > } > } > @@ > auto& entry = s.gpu_writes[address]; > entry.size = std::max(entry.size, size); > entry.shader_hash = shader_hash; > + entry.order = ++s.gpu_write_order; > } > ``` > > </details> > > <!-- cr-comment:v1:369cc933f153b2016c7a9ec0 --> > > </blockquote></details> --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/79837b423dd035b34b2dc476e1d2dce8ae0d18bf/.coderabbit.yaml>) - **Commit**: [79837b4](<https://github.com/KytyPS5/KytyPS5/commit/79837b423dd035b34b2dc476e1d2dce8ae0d18bf>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `8c5be271-c0fa-4743-a1c0-14fcbf237de5` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between b57a503034b89eee5129cdee71b96d440ff2ac55 and 9b9afc99792e183f7d79a4d5b57c49cc41162f78. </details> <details> <summary>📒 Files selected for processing: 1</summary> * `src/common/perfReport.h` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=d4d8e753-9f31-46cd-8bdb-3dcb4dfba8d0 attempt=6502f580-b3f5-4a0f-b013-97ba31cb4fb7 batch=1/1 -->
Author
Owner

@⁠MrBigBritches on GitHub · 2026-10-23 05:59 UTC · original

@⁠coderabbitai resume

**@⁠MrBigBritches** on GitHub · 2026-10-23 05:59 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1851#issuecomment-6358523702) @⁠coderabbitai resume
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-23 05:59 UTC · original · edited 2026-10-23 06:03 UTC

✅ Action performed

Reviews resumed and review finished.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-23 05:59 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1851#issuecomment-6358525496) · edited 2026-10-23 06:03 UTC <!-- coderabbit-ai-generated:v1 --> <!-- This is an auto-generated reply by CodeRabbit --> <!-- CodeRabbit review command invocation: 768d6c2a-0c97-4a32-8fe8-0a57fec9640b --> <details> <summary>✅ Action performed</summary> Reviews resumed and review finished. </details>
@ -0,0 +387,4 @@
auto& entry = s.gpu_writes[address];
entry.size = std::max(entry.size, size);
entry.shader_hash = shader_hash;
entry.order = ++s.gpu_write_order;
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-23 06:03 UTC · original

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Keep the binding order with its actual range.

If an address is rebound with a smaller size, entry.size keeps the earlier, larger size, while this line gives the new shader the latest order. For example, after a large binding at 0x1000, a binding at 0x1800, and a small rebind at 0x1000, a fault at 0x1900 can be attributed to the small rebind instead of the binding at 0x1800. Store the range associated with each shader and order, or replace the retained size when recording the new binding.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-23 06:03 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1851#discussion_r4356623840) <!-- coderabbit-ai-generated:v1 --> **🎯 Functional Correctness** | **🟡 Minor** | **⚡ Quick win** **Keep the binding order with its actual range.** If an address is rebound with a smaller size, `entry.size` keeps the earlier, larger size, while this line gives the new shader the latest order. For example, after a large binding at `0x1000`, a binding at `0x1800`, and a small rebind at `0x1000`, a fault at `0x1900` can be attributed to the small rebind instead of the binding at `0x1800`. Store the range associated with each shader and order, or replace the retained size when recording the new binding. <!-- fingerprinting:phantom:poseidon:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:fa53a4f5fd3b58ea77bd7e72 --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-23 06:03 UTC · original · reviewed

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between 9b9afc9979 and 5ebbd5c56a.

📒 Files selected for processing: 3
  • src/common/perfReport.cpp
  • src/graphics/guest_gpu/graphicsRun.cpp
  • src/launcher/src/configurationEditDialog.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-23 06:03 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1851#pullrequestreview-5624531469) · **reviewed** <!-- coderabbit-ai-generated:v1 --> **Actionable comments posted: 1** --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/79837b423dd035b34b2dc476e1d2dce8ae0d18bf/.coderabbit.yaml>) - **Commit**: [79837b4](<https://github.com/KytyPS5/KytyPS5/commit/79837b423dd035b34b2dc476e1d2dce8ae0d18bf>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `69d0adae-cfb9-447a-8262-9b3e42d64b9c` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 9b9afc99792e183f7d79a4d5b57c49cc41162f78 and 5ebbd5c56a8f9dd9fb233d87a15fbfe5a592a4f7. </details> <details> <summary>📒 Files selected for processing: 3</summary> * `src/common/perfReport.cpp` * `src/graphics/guest_gpu/graphicsRun.cpp` * `src/launcher/src/configurationEditDialog.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=d1824375-601e-4b4f-b6a6-ec9709a7bd06 attempt=15e669a8-2a6f-4da4-935b-3d450324c90b batch=1/1 -->

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.