Skip to content

feat(agc): configure trace event buffers - #5808

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
Ondra97:codex/feat-configurable-trace-capacity
Oct 14, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
Ondra97:codex/feat-configurable-trace-capacity

Conversation

@Ondra97

@Ondra97 Ondra97 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

What

#5786 reports that Hades II's queue-worker trace buffer fills about 3.3 seconds into a 30-second window, leaving most worker slices out of the trace. Add APS5_TRACE_EVENTS=<count> to size the queue-worker and presenter buffers from 1 through 4,194,304 events. The default remains 262,144; invalid values throw before the thread binds. Document the memory cost and add capacity and validation regressions.

Shader preparation retains its explicitly sized buffers, the GPU range limit stays unchanged, and summary-only sessions allocate no event buffers. This addresses the configurable-capacity part of #5786; per-thread drop reasons and cutoff markers remain open.

Tested

Windows 11 Pro 10.0.26300, WinLibs MinGW-w64 GCC 15.2.0, Release, bundled dependencies. Full build passed after rebase on 344afad05. Four focused CTest cases passed in 1.34 s: agc_performance_trace, agc_profile_output, agc_driver_draw_cache_reuse, and agc_driver_prepared_graphics. GPU tests required Vulkan. Conventions and whitespace checks passed.

The capacity regression retains 262,145 slices, bounds the next append, and preserves totals past the limit. Parser tests cover the unchanged default, minimum, maximum, larger values, malformed values, and integer overflow.

Visible VLC v0.4 homebrew runs (PPSA85300, public release), with a 5:5 seconds window. Counts were read from the resulting compressed trace files:

Driver Requested events Queue-worker events Presenter events trace_dropped
main 23be5a02b075 16 19,272 7,019 false
this change 16 16 16 true
final head 1effd67b7012 3,145,728 19,613 6,910 false

Every run used APS5_NO_DRAW_SRT_ENTRIES=1 to isolate tracing from the VLC draw-cache issue addressed by #5791. The executable was relinked locally, runtime libraries were copied and SHA-256 verified, and runs were intentionally stopped after 20 s. The changed 16-event capture used aa84bef8b43d; the trace implementation and capacity tests are identical in the final head. The larger-buffer capture carries commit=1effd67b7012 and dirty=false, from the final host build. Hades II, Linux, and other GPUs were not run; no speed improvement is claimed.

Before starting, checked current open-PR heads and shared implementations. Refreshed 449 open PR file lists before publication; #5046 and #5047 add batch IDs to traces and #5238 documents shader-address tracing, with no implementation of configurable event capacity.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 4070 Ti SUPER, NVIDIA 617.14 (Windows driver 32.0.16.1714), Windows 11 Pro 10.0.26300
  • AI-assisted: yes, Codex

@MarcZX10

Copy link
Copy Markdown
Contributor

One overlap to coordinate before merge: open PR #5813 also adds APS5_TRACE_EVENTS in PerformanceTrace.hpp, with a different accepted range and shader-prepare sizing, alongside the per-thread drop reporting. This PR is the capacity-only piece; #5813 includes that same setting while completing the diagnostics requested in #5786. Please compare with Eli and agree which PR carries the shared parser/capacity behavior; the second branch will need a rebase or an explicit dependency.

@eliyarson

Copy link
Copy Markdown
Contributor

@Ondra97 I opened #5813 for the same issue a few minutes after this, without having seen it. Since this one came first and is the capacity-only piece, I'll let it carry APS5_TRACE_EVENTS: I'm rebasing #5813 on top of this branch, dropping my parser, bounds and capacity tests, and marking it Depends on #5808. #5813 will then only add the per-thread drop details (trace_dropped_threads, the trace buffer full marker) and, if it fits your parser without changes, the shader-prepare buffer following the setting at an eighth. Thanks @MarcZX100 for spotting it.

@Ondra97

Ondra97 commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, I compared both patches. I propose landing #5808 as the capacity-only change first, then rebasing #5813 on it for the drop diagnostics.

The 4,194,304-event limit accommodates the roughly 2.5 million events reported in #5786 while bounding the event buffer to 128 MiB per thread. Buffers are allocated before the capture window opens, and formatting requires additional memory, so I chose a conservative upper bound. Allowing small capacities also makes buffer exhaustion easy to reproduce in runtime checks.

I kept shader-prepare buffers at their existing explicit size so increasing queue-worker capture capacity does not also increase allocations across shader workers. Extending that behavior and raising the maximum to 512 MiB per thread can be reviewed separately.

This keeps the capacity change small and independently reviewable, while #5813 adds the complementary per-thread loss reporting and cutoff markers.

@eliyarson, would this merge order work for you?

AI-assisted: yes. — Codex

@Ondra97

Ondra97 commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @eliyarson, that works for me — our comments crossed. For shader-prepare sizing in #5813, please keep the parser unchanged and ensure the one-eighth share remains at least one event for accepted capacities below eight.

AI-assisted: yes. — Codex

@adriadam10 adriadam10 self-assigned this Oct 14, 2026
eliyarson added a commit to eliyarson/AnyPS5 that referenced this pull request Oct 14, 2026
…buffers filled

The trace summary line keeps `trace_dropped` as before: true when any
thread lost a slice, any thread's totals table was full, or the gpu
track was full. When it is true, the line now also carries
`trace_dropped_threads`, one entry per affected thread name, so the reader
can tell which thread lost data and how much. Threads that share a
name, such as the shader prepare threads, share one entry: losses are
summed, the earliest fill is kept and totals_full is true if any is.

Each entry has `events_full_after_s`, the seconds from the first
present of the window to the start of the first lost slice. It is
absent for `gpu` and in every summary line (windowed frames/seconds
and APS5_TRACE_SUMMARY_EVERY) whenever the first lost slice starts
outside the line's span of presents, including a slice whose scope
began before the window opened or one lost after the last present.
`events_lost` is the number of slices not recorded and is absent when
0; in interval lines it counts the buffer's losses since it started.
`totals_full` is true when the thread's totals table overflowed, which
makes the summary numbers incomplete; a thread with only `events_lost`
has complete totals.

The Chrome trace gets a `trace buffer full` instant event on a thread
at the point where its buffer filled.

BUILD.md documents the new fields and the event.

`trace_dropped` is unchanged, and when nothing drops the default output
is byte-identical to before.

Refs boykopovar#5786
Depends on boykopovar#5808
@eliyarson

Copy link
Copy Markdown
Contributor

@Ondra97 Thanks. I took the shader-prepare sizing out of #5813 for now: it is #5808 plus one commit with only the drop details, and your parser and sizes are untouched. I'll propose the eighth share, kept at no less than one event, in a separate PR once #5808 is in.

@adriadam10

Copy link
Copy Markdown
Collaborator

Checked the build and the scoped ctest (agc_performance_trace passes; the new CapacitySettings case fails to build without the change), the parser edge cases (empty, 0, signs, spaces, max+1, overflow) and the docs against the code; shader prepare keeps its 32,768-event buffers. Merging once the full Build is green.

@adriadam10
adriadam10 merged commit 69e7138 into boykopovar:main Oct 14, 2026
9 checks passed
adriadam10 pushed a commit to eliyarson/AnyPS5 that referenced this pull request Oct 14, 2026
…buffers filled

The trace summary line keeps `trace_dropped` as before: true when any
thread lost a slice, any thread's totals table was full, or the gpu
track was full. When it is true, the line now also carries
`trace_dropped_threads`, one entry per affected thread name, so the reader
can tell which thread lost data and how much. Threads that share a
name, such as the shader prepare threads, share one entry: losses are
summed, the earliest fill is kept and totals_full is true if any is.

Each entry has `events_full_after_s`, the seconds from the first
present of the window to the start of the first lost slice. It is
absent for `gpu` and in every summary line (windowed frames/seconds
and APS5_TRACE_SUMMARY_EVERY) whenever the first lost slice starts
outside the line's span of presents, including a slice whose scope
began before the window opened or one lost after the last present.
`events_lost` is the number of slices not recorded and is absent when
0; in interval lines it counts the buffer's losses since it started.
`totals_full` is true when the thread's totals table overflowed, which
makes the summary numbers incomplete; a thread with only `events_lost`
has complete totals.

The Chrome trace gets a `trace buffer full` instant event on a thread
at the point where its buffer filled.

BUILD.md documents the new fields and the event.

`trace_dropped` is unchanged, and when nothing drops the default output
is byte-identical to before.

Refs boykopovar#5786
Depends on boykopovar#5808
adriadam10 pushed a commit to eliyarson/AnyPS5 that referenced this pull request Oct 14, 2026
…buffers filled

The trace summary line keeps `trace_dropped` as before: true when any
thread lost a slice, any thread's totals table was full, or the gpu
track was full. When it is true, the line now also carries
`trace_dropped_threads`, one entry per affected thread name, so the reader
can tell which thread lost data and how much. Threads that share a
name, such as the shader prepare threads, share one entry: losses are
summed, the earliest fill is kept and totals_full is true if any is.

Each entry has `events_full_after_s`, the seconds from the first
present of the window to the start of the first lost slice. It is
absent for `gpu` and in every summary line (windowed frames/seconds
and APS5_TRACE_SUMMARY_EVERY) whenever the first lost slice starts
outside the line's span of presents, including a slice whose scope
began before the window opened or one lost after the last present.
`events_lost` is the number of slices not recorded and is absent when
0; in interval lines it counts the buffer's losses since it started.
`totals_full` is true when the thread's totals table overflowed, which
makes the summary numbers incomplete; a thread with only `events_lost`
has complete totals.

The Chrome trace gets a `trace buffer full` instant event on a thread
at the point where its buffer filled.

BUILD.md documents the new fields and the event.

`trace_dropped` is unchanged, and when nothing drops the default output
is byte-identical to before.

Refs boykopovar#5786
Depends on boykopovar#5808
@Ondra97
Ondra97 deleted the codex/feat-configurable-trace-capacity branch October 17, 2026 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants