feat: add an in-game performance panel #1090
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!1090
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1090/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@juanfariasdev on GitHub · 2026-10-05 23:43 UTC · original
juanfariasdev:feat/perf-overlay→main· +1788 −34 · 35 files · 1 commits · merged 2026-10-17 12:47 UTCSummary
Adds an optional in-game performance panel in the top-right corner of the game window, with a compact view and a detailed view for real-time debugging.
Compact view: FPS, average frame time, a graph of the last 120 frame times (green ≤ 17.5 ms, yellow ≤ 34 ms, red above), the worst frame, emulator CPU, GPU utilization, GPU memory against the Vulkan budget, emulator and system RAM, swap and memory pressure.
Detailed view, in three columns:
It is off by default. Enable it with
--perf-overlay trueor the launcher's Show performance panel checkbox. In game, F2 toggles the panel and Shift+F2 switches to the detailed view. Mac keyboards send brightness for F2 unless fn is held, so Cmd+P and Cmd+Shift+P do the same on macOS.How it works
performanceOverlay.cpp): reuses the ImGui context and Vulkan backend of the existing system overlay. The panel is drawn only on presents that already happen, so it does not change frame pacing. While the guest stops flipping (loading screens), it asks for one repaint per second. Tables are sized to their content, so the panel shrinks and grows with the window.common/debugCounters.h): relaxed atomic counters at the existing hot spots (draw recording, dispatch, queue submit, semaphore waits, shader and pipeline creation, texture and buffer caches, flips, the host exception handler, guest file I/O, audio). The panel reads them once per second and turns them into rates.Memory::GetDebugStats): read once per second under the memory subsystem's bookkeeping locks only, neverg_memory_operation_mutex, so it cannot wait on the GPU. Graphics shuts down before memory, so the present thread can call it safely.common/hostStats.cpp): sampled once per second on a background thread, since thread enumeration and the IOAccelerator registry can take a few milliseconds.getrusage/host_statisticsgetrusage//proc/statGetProcessTimes/GetSystemTimestask_threads/proc/self/tasktask_vm_info/proc/self/statushost_statistics64,vm.swapusage/proc/meminfoGlobalMemoryStatusExkern.memorystatus_vm_pressure_levelsome avg10, else available memorydwMemoryLoadproc_pid_rusage/proc/self/ioGetProcessIoCountersPerformanceStatisticscom.apple.system.thermalpressurelevelOther changes
Testing
Apple M4 Pro, macOS, x86_64 build. Games need #1083 to boot on macOS, so I tested on a local branch with #1083 merged:
top), swap (vm.swapusage), memory pressure, GPU (ioreg), disk writes.--keymap Cross=F2boots with the warning instead of exiting.shader_cfg_testspass.I did not build on Linux or Windows locally; that code follows the documented APIs and relies on CI for compilation.
🤖 Generated with Claude Code
@coderabbitai[bot] on GitHub · 2026-10-05 23:52 UTC · original · edited 2026-10-17 12:32 UTC
📝 Walkthrough
This change adds a configurable performance panel with compact and detailed views. It samples host and guest metrics, records runtime counters, and connects panel rendering to the presentation path. The launcher and command line can set the panel option, and keyboard shortcuts toggle the panel and its detail view.
Suggested reviewers:
nmzikPriority: ➖ Normal
Change: Feature
Merge Risk: 🟡 Moderate · up to
fc0a8Existing F2 key mappings can prevent games from starting, and the detailed panel can report the wrong guest resolution. Fix the startup failure before merging.
Security architecture risk: 🔵 Low · up to
45836The inspected paths keep diagnostics local and do not grant additional permissions. No concrete security weakness was established, but incomplete lifecycle coverage prevents a minimal-risk assessment.
Retained concerns
No architecture-level concerns identified.
Security review details
Security Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Pre-merge checks:
4 ·
1
Full details: Docstring Coverage
Explanation
Docstring coverage is 6.87% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 131 functions across 35 files. (2 skipped: 2 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
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 helpto get the list of available commands.@coderabbitai[bot] on GitHub · 2026-10-05 23:52 UTC · original · edited 2026-10-06 00:30 UTC
On
src/graphics/presentation/window/hostInput.cppline 150 (outdated):🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 6257
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 14726
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 6681
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 4318
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 2371
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 12079
Handle existing F2 mappings before rejecting them.
InputMap::InputMap()now rejects F2 duringHostInputInit(). The launcher still accepts F2 in its mapping editor and passes saved mappings through--keymap. Existing mappings such asCross=F2can therefore terminate the emulator before the game starts.Reject F2 in the editor and ignore existing reserved-key mappings with a warning:
Suggested fix
✅ Confirmed as addressed by @juanfariasdev
@coderabbitai[bot] on GitHub · 2026-10-05 23:52 UTC · original · reviewed
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
2f12db70-4337-4f3b-8a88-9ca53f3d5cf1📥 Commits
Reviewing files that changed from the base of the PR and between
cdb64bfd4fand 2f8ccdbba47c9cf74c4bd304c44cafcfa69421c8.📒 Files selected for processing (17)
src/common/CMakeLists.txtsrc/common/emulatorConfig.cppsrc/common/emulatorConfig.hsrc/common/hostStats.cppsrc/common/hostStats.hsrc/graphics/presentation/performanceOverlay.cppsrc/graphics/presentation/performanceOverlay.hsrc/graphics/presentation/systemOverlay.cppsrc/graphics/presentation/videoOut.cppsrc/graphics/presentation/window/hostInput.cppsrc/graphics/presentation/window/swapchain.cppsrc/graphics/presentation/window/window.cppsrc/launcher/forms/configuration_edit_dialog.uisrc/launcher/include/configuration.hsrc/launcher/src/configurationEditDialog.cppsrc/launcher/src/mainDialog.cppsrc/main.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.
@juanfariasdev on GitHub · 2026-10-06 00:30 UTC · original
On
src/graphics/presentation/window/hostInput.cppline 150 (outdated):Good catch, thanks. Fixed in 90f863c as suggested:
InputMapnow ignores a mapping on a reserved key with a log line (Ignoring input mapping on reserved key: Cross=F2) instead of exiting. This also covers Esc, F1, F7 and F11, which the editor already rejected, so it only changes behavior for hand-written--keymapvalues.Tested with
--keymap Cross=F2: the game boots and the warning is logged; before the fix it exited withInvalid input mapping.@coderabbitai[bot] on GitHub · 2026-10-06 00:30 UTC · original
On
src/graphics/presentation/window/hostInput.cppline 150 (outdated):@juanfariasdevThanks for fixing both paths. Ignoring saved reserved-key mappings prevents the startup failure. Rejecting F2 in the launcher prevents new conflicting mappings. Your--keymap Cross=F2test confirms the reported failure is addressed.If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!
✅ Review thread resolved.
You are interacting with an AI system.
@juanfariasdev on GitHub · 2026-10-06 00:40 UTC · original
@coderabbitai[bot] on GitHub · 2026-10-06 01:00 UTC · original
On
src/common/hostStats.cppline 415 (outdated):🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Catch parse failures in the Linux thread sampler.
std::stoullthrowsstd::invalid_argumentorstd::out_of_rangewhen a/proc/self/task/<tid>/statfield is malformed. A thread can exit afterdirectory_iteratorlists it. In that casestatis empty or truncated, and the read can produce a partial field. The sampler runs on a backgroundstd::jthreadwithout atryblock. An uncaught exception in that thread callsstd::terminateand ends the emulator. Usestd::from_chars, or wrap the parse in atryblock and skip the thread on failure. Apply the same fix tostd::stodat Line 477.Proposed fix
📝 Committable suggestion
@coderabbitai[bot] on GitHub · 2026-10-06 01:00 UTC · original · reviewed
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
0967deb9-3042-4cdb-965a-3f8ae8088f95📥 Commits
Reviewing files that changed from the base of the PR and between 2f8ccdbba47c9cf74c4bd304c44cafcfa69421c8 and 4583663d5c007b71bf8b258342ad1524f85b4469.
📒 Files selected for processing (29)
src/common/debugCounters.hsrc/common/hostStats.cppsrc/common/hostStats.hsrc/common/profiler.cppsrc/graphics/guest_gpu/graphicsRun.cppsrc/graphics/host_gpu/graphicContext.hsrc/graphics/host_gpu/renderer/cache/bufferCache.cppsrc/graphics/host_gpu/renderer/cache/textureCache.cppsrc/graphics/host_gpu/renderer/commandScheduler.cppsrc/graphics/host_gpu/renderer/masterSemaphore.cppsrc/graphics/host_gpu/renderer/pipeline/pipelineCache.cppsrc/graphics/host_gpu/renderer/renderCompute.cppsrc/graphics/host_gpu/renderer/renderDraw.cppsrc/graphics/host_gpu/vma.cppsrc/graphics/presentation/performanceOverlay.cppsrc/graphics/presentation/performanceOverlay.hsrc/graphics/presentation/videoOut.cppsrc/graphics/presentation/window/hostInput.cppsrc/graphics/presentation/window/swapchain.cppsrc/graphics/presentation/window/window.cppsrc/kernel/fileSystem.cppsrc/kernel/memory.cppsrc/kernel/memory.hsrc/kernel/pthread.cppsrc/launcher/forms/configuration_edit_dialog.uisrc/launcher/include/configuration.hsrc/launcher/src/inputMappingDialog.cppsrc/libs/audio.cppsrc/loader/runtimeLinker.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
@ -1245,1 +1252,4 @@m_presenter.Present(std::span(layers.data(), count));if (requests[0].cfg->bus == 0) {Graphics::PerformanceOverlayRecordFlip(requests[0].cfg->width, requests[0].cfg->height);}@coderabbitai[bot] on GitHub · 2026-10-17 12:32 UTC · original
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Report the guest frame size, not the port's configured size.
VideoOutConfig::widthandheightcome fromImpl::Init. That function stores the emulator screen size for every port. Guest buffer registration never updates these fields. The detailed panel's "Guest output" row therefore shows the window size, not the guest resolution.The presented frame already holds the guest surface extent.
Presenter::PrepareFrameconfigures the frame from the texture-cache backing extent. Use that frame's image extent.Proposed fix
📝 Committable suggestion
@ -257,2 +257,2 @@binding.key == SDLK_F7 || binding.key == SDLK_F8 ||binding.key == SDLK_F11;binding.key == SDLK_F2 || binding.key == SDLK_F7 ||binding.key == SDLK_F8 || binding.key == SDLK_F11;@coderabbitai[bot] on GitHub · 2026-10-17 12:32 UTC · original
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 2295
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 10376
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 6139
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 2335
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 3048
Ignore saved mappings on reserved keys instead of exiting.
A saved
Cross=F2mapping reachesInputMapduringHostInputInit()and triggersEXIT, which terminates the emulator. Warn and skip valid mappings that use reserved keys.F8 was already reserved before this PR, so this change does not introduce a new F8 regression.
Suggested fix
@coderabbitai[bot] on GitHub · 2026-10-17 12:32 UTC · original · reviewed
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
550fff19-753d-406a-b7cc-495263498845📥 Commits
Reviewing files that changed from the base of the PR and between 4583663d5c007b71bf8b258342ad1524f85b4469 and
fc0a85eea1.📒 Files selected for processing: 34
src/common/CMakeLists.txtsrc/common/debugCounters.hsrc/common/emulatorConfig.cppsrc/common/emulatorConfig.hsrc/common/hostStats.cppsrc/graphics/guest_gpu/graphicsRun.cppsrc/graphics/host_gpu/graphicContext.hsrc/graphics/host_gpu/renderer/cache/bufferCache.cppsrc/graphics/host_gpu/renderer/cache/textureCache.cppsrc/graphics/host_gpu/renderer/commandScheduler.cppsrc/graphics/host_gpu/renderer/masterSemaphore.cppsrc/graphics/host_gpu/renderer/pipeline/pipelineCache.cppsrc/graphics/host_gpu/renderer/renderCompute.cppsrc/graphics/host_gpu/renderer/renderDraw.cppsrc/graphics/host_gpu/vma.cppsrc/graphics/presentation/performanceOverlay.cppsrc/graphics/presentation/performanceOverlay.hsrc/graphics/presentation/systemOverlay.cppsrc/graphics/presentation/videoOut.cppsrc/graphics/presentation/window/hostInput.cppsrc/graphics/presentation/window/swapchain.cppsrc/graphics/presentation/window/window.cppsrc/kernel/fileSystem.cppsrc/kernel/memory.cppsrc/kernel/memory.hsrc/launcher/forms/configuration_edit_dialog.uisrc/launcher/include/configuration.hsrc/launcher/src/configuration.cppsrc/launcher/src/configurationEditDialog.cppsrc/launcher/src/inputMappingDialog.cppsrc/launcher/src/mainDialog.cppsrc/libs/audio.cppsrc/loader/runtimeLinker.cppsrc/main.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.