Skip to content

fix(agc): move periodic profiling writes off GPU workers - #798

Merged
oneandonlydean merged 2 commits into
boykopovar:mainfrom
nicolasabosch:fix/agc-profile-output
Oct 6, 2026
Merged

oneandonlydean merged 2 commits into
boykopovar:mainfrom
nicolasabosch:fix/agc-profile-output

Conversation

@nicolasabosch

@nicolasabosch nicolasabosch commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

What

Periodic AGC profiling reports currently write to stderr on GPU queue and presentation threads, sometimes while holding GuestMemory::GpuMutex. With APS5_PROFILE_DRAW=1, a slow diagnostic destination can delay submitting otherwise ready GPU work.

Format and copy periodic profiling output into a bounded 4 MiB queue and write it from a separate thread. The writer batches output, drains accepted chunks on shutdown, propagates write failures, and explicitly reports dropped chunks if the destination falls behind. The capacity includes in-flight output. Existing report formats and profiling switches are retained; error and assertion reporting remains synchronous.

Tested

  • Windows 11, MinGW, NVIDIA RTX 4070. Libraries and relinker built successfully.
  • GitHub Actions: 343/343 CTest cases passed on both Linux and Windows with --repeat until-fail:3; all three PR checks passed.
  • 10 distinct focused CTest cases passed: agc_profile_output, agc_register_command_tests, agc_shader_disk_cache, agc_write_tracking, agc_driver, agc_driver_pm4, agc_driver_graphics, agc_driver_flat_store, agc_driver_image_store_packed, agc_driver_lds_atomics.
  • The new writer test covers formatting, shutdown drain, concurrent producers, a deliberately blocked destination, bounded overflow including in-flight output, and failure propagation. It also passed 10 consecutive repetitions before the final integration checks.
  • DOOM Shareware homebrew PPSA99666 01.001.000 was tested in a separate local integration with feat(libs): implement homebrew libc and kernel runtime exports #683, fix(relinker): bind Windows imports to their declared modules #684, feat(agc): support version initialization and raw compute programs #685 and feat(userservice): implement foreground user, registered list, user colour and NP account id #553. These are game prerequisites, not dependencies of this PR.
  • In an earlier controlled prototype experiment using the same instrumented binary, two 25-second synchronous-output runs had maximum late dispatch durations of 282.883 / 333.904 ms; deferring diagnostic output reduced them to 33.863 / 29.935 ms. Individual synchronous writes took up to 106.917 ms. This established the logging-induced CPU stall; it is not an FPS benchmark.
  • Final implementation: a 30-second empty-cache run, a 60-second warm-cache run, and a 45-second warm-cache trace run completed without frame timeouts, CPU scaler fallback or dropped profiling chunks. The traced run contained 1,840 dispatch-to-next-packet intervals after the first two seconds: maximum 0.711 ms, p99 0.577 ms. This interval is a CPU packet-trace observation, not GPU execution time.
  • A further interactive run reached E1M1 and accepted firing input while still using GPU presentation. Fresh screenshots were captured outside the source repository.

Known limits: another interactive run still timed out at frame 112 and switched to the CPU scaler. This PR removes measured diagnostic-output stalls, but does not claim to resolve every frame timeout, improve FPS, or eliminate Vulkan instance/device initialization cost. A pre-existing UCRT invalid-parameter diagnostic also occurs during startup and remains unchanged.

Checklist

  • Based on current main (b10f5701); no other open PR implements the same change
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; no silent stubs added
  • No notes, investigation files or images added to the repository
  • No new third-party code
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

In-game screenshots

Fresh captures from the final implementation in the separate DOOM integration. The interactive session ran for 213 seconds, completed more than 7,400 dispatches and reported no frame timeouts, CPU fallback or dropped profiling chunks.

E1M1

Firing in E1M1

@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#494 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCacheStatistics.cpp L0-1, L15-17

@oneandonlydean
oneandonlydean merged commit 9ee9f8f into boykopovar:main Oct 6, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants