fix(agc): keep capture trace output nonfatal #10760

Merged
lgqdaxia merged 5 commits from upstream-pr/10760 into main 2026-11-02 10:24:20 +00:00
lgqdaxia commented 2026-10-24 23:06:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by lgqdaxia on 2026-10-24T23:06:07Z.


What

Capture tracing can throw when its 16 MiB pending queue fills, or stop the process when file output fails. This implements the drop-and-count policy requested in #10753.

  • A full queue drops new records and counts them. The next drained batch writes capture-trace-dropped records=N; normal shutdown writes capture-trace-summary dropped=N. Accepted records and loss markers keep their order. After a drop, new records remain rejected until the next drain.
  • A failed write or flush disables tracing, clears the pending queue and reports one error to stderr. Later calls return without queueing output. Direct stream-state checks also cover the project's runtime without relying on exception unwinding. Oversized formatted records count as lost.
  • The pending queue remains bounded at 16 MiB; the writer can hold another batch plus marker overhead. A native file I/O call that never returns can still delay shutdown while it joins the writer. That limitation remains in the debt entry; no I/O cancellation is claimed.

This rebase resolves a context conflict in the technical-debt list and retains both the new upstream entry and this PR's trace-output limitation. The capture header, both C++ fixtures, failure wrapper and tests/cmake/agc_capture_trace_tests.cmake are byte-identical to previous published head 6d26a5b8eb. All five topic commits are retained; the production behavior is unchanged. The AGC root CMake file and all upstream debt content are retained.

AI-assisted: Codex

Tested

Current local validation is for head b2ab7b2dc61b35a3b2db107341b3c4ef624fbe9d, based on main e53aff3f560e05730a608f7fb3084f2010abfacb.

  • Windows 11, WinLibs GCC 15.2.0/UCRT r7, CMake 4.3.1, Ninja Release: regenerated the real project configuration with BUILD_TESTING=ON. tools/check_test_registration.py passes, checking 1,694 test executables. Built all three capture-trace targets and their dependencies, including the project's libc.
  • 16 capture-trace CTests plus public_headers pass (17/17), zero skipped. This includes host-runtime and project-runtime write/flush failure cases. Total CTest time was 44.42 s. This is a focused build/test run, not a full product build or complete CTest suite. These CPU fixtures do not initialize Vulkan; no GPU execution or performance result is claimed.
  • All five implementation/test/registration files are byte-identical to old head 6d26a5b8ebaa75a2e3c517c809ea045b1b6b47b4. Removing this PR's single trace-output debt entry reproduces main's debt file byte-for-byte. Conventions, whitespace checks and a merge-tree check against the stated main pass.

The earlier isolated host-runtime comparison remains pinned to main 9fe758d7520eb0c33f3df8bef539064b40bd523f and head 6d26a5b8eb: eight common capture tests passed 8/8 on each. That is historical comparison evidence, separate from the current configured project-runtime tests above.

Historical hosted evidence remains pinned to its original versions: Build 40572948350 tested old head c4ad483347 merged into main d13b3d7c55. Both platforms built the product/libraries and passed all 16 capture tests. Linux recorded 2483 passed / 97 skipped; Windows recorded 1848 passed / 832 skipped / 1 failed (guest_raise_exception). The overall run failed.

The independent Windows comparison and NVIDIA contributor report in this discussion also concern old head c4ad483347. They are not new-head validation or full upstream CI approval. No full hosted CI, new Linux/macOS runtime, game capture, real SMB throughput or cancellation of permanently blocked native I/O is claimed for this rebase.

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
  • Fixes: Fixes #10753
  • Unblocks: none
  • GPUs tested: n/a; current validation is CPU-only capture logging
  • AI-assisted: yes; Codex
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4999972331 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10760). Originally posted by [lgqdaxia](https://github.com/lgqdaxia) on 2026-10-24T23:06:07Z. --- ### What Capture tracing can throw when its 16 MiB pending queue fills, or stop the process when file output fails. This implements the drop-and-count policy requested in [#10753](https://github.com/boykopovar/AnyPS5/issues/10753#issuecomment-6404591066). - A full queue drops new records and counts them. The next drained batch writes `capture-trace-dropped records=N`; normal shutdown writes `capture-trace-summary dropped=N`. Accepted records and loss markers keep their order. After a drop, new records remain rejected until the next drain. - A failed write or flush disables tracing, clears the pending queue and reports one error to stderr. Later calls return without queueing output. Direct stream-state checks also cover the project's runtime without relying on exception unwinding. Oversized formatted records count as lost. - The pending queue remains bounded at 16 MiB; the writer can hold another batch plus marker overhead. A native file I/O call that never returns can still delay shutdown while it joins the writer. That limitation remains in the debt entry; no I/O cancellation is claimed. This rebase resolves a context conflict in the technical-debt list and retains both the new upstream entry and this PR's trace-output limitation. The capture header, both C++ fixtures, failure wrapper and `tests/cmake/agc_capture_trace_tests.cmake` are byte-identical to previous published head `6d26a5b8eb`. All five topic commits are retained; the production behavior is unchanged. The AGC root CMake file and all upstream debt content are retained. AI-assisted: Codex ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Current local validation is for head `b2ab7b2dc61b35a3b2db107341b3c4ef624fbe9d`, based on main `e53aff3f560e05730a608f7fb3084f2010abfacb`. - Windows 11, WinLibs GCC 15.2.0/UCRT r7, CMake 4.3.1, Ninja Release: regenerated the real project configuration with `BUILD_TESTING=ON`. `tools/check_test_registration.py` passes, checking **1,694 test executables**. Built all three capture-trace targets and their dependencies, including the project's `libc`. - **16 capture-trace CTests plus `public_headers` pass (17/17), zero skipped.** This includes host-runtime and project-runtime write/flush failure cases. Total CTest time was 44.42 s. This is a focused build/test run, not a full product build or complete CTest suite. These CPU fixtures do not initialize Vulkan; no GPU execution or performance result is claimed. - All five implementation/test/registration files are byte-identical to old head `6d26a5b8ebaa75a2e3c517c809ea045b1b6b47b4`. Removing this PR's single trace-output debt entry reproduces main's debt file byte-for-byte. Conventions, whitespace checks and a merge-tree check against the stated main pass. The earlier isolated host-runtime comparison remains pinned to main `9fe758d7520eb0c33f3df8bef539064b40bd523f` and head `6d26a5b8eb`: eight common capture tests passed 8/8 on each. That is historical comparison evidence, separate from the current configured project-runtime tests above. Historical hosted evidence remains pinned to its original versions: [Build 40572948350](https://github.com/boykopovar/AnyPS5/actions/runs/40572948350) tested old head `c4ad483347` merged into main `d13b3d7c55`. Both platforms built the product/libraries and passed all 16 capture tests. Linux recorded 2483 passed / 97 skipped; Windows recorded 1848 passed / 832 skipped / 1 failed (`guest_raise_exception`). The overall run failed. The independent [Windows comparison](https://github.com/boykopovar/AnyPS5/pull/10760#issuecomment-6505982532) and [NVIDIA contributor report](https://github.com/boykopovar/AnyPS5/pull/10760#issuecomment-6517552901) in this discussion also concern old head `c4ad483347`. They are not new-head validation or full upstream CI approval. No full hosted CI, new Linux/macOS runtime, game capture, real SMB throughput or cancellation of permanently blocked native I/O is claimed for this rebase. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> Fixes #10753 - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a; current validation is CPU-only capture logging - [x] AI-assisted: <!-- yes / no --> yes; Codex
MarcZX10 commented 2026-10-24 23:13:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T23:13:38Z.

Review: CHANGES_REQUESTED


The happy-path backpressure test is useful, and I verified that the worker’s 100 ms timed wait drains a full queue even when it is below the normal 64 KiB notify threshold. I found an unhandled writer-error path in the new wait protocol:

  1. run() swaps pending into batch and notifies spaceAvailable.
  2. A waiting producer wakes and can fill pending back to the limit.
  3. If output.write() or output.flush() then throws, the catch calls std::terminate() and the worker exits without notifying spaceAvailable again.
  4. The producer’s predicate only checks queue size, so it can remain blocked forever; the destructor can also wait indefinitely if this occurs during shutdown.

The PR says file-write errors retain their existing behavior, but the new condition-variable wait adds a stranded-waiter case on that existing fatal path. Please either make writer failure a synchronized terminal predicate that wakes all waiters (and ensure shutdown handles it consistently), or demonstrate with a deterministic failing stream test that this state cannot occur. Please add a focused regression for writer failure; the current test only exercises a recovering sink. I have not modified your branch.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5640542529 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10760#pullrequestreview-5640542529). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T23:13:38Z. **Review:** CHANGES_REQUESTED --- The happy-path backpressure test is useful, and I verified that the worker’s 100 ms timed wait drains a full queue even when it is below the normal 64 KiB notify threshold. I found an unhandled writer-error path in the new wait protocol: 1. `run()` swaps `pending` into `batch` and notifies `spaceAvailable`. 2. A waiting producer wakes and can fill `pending` back to the limit. 3. If `output.write()` or `output.flush()` then throws, the catch calls `std::terminate()` and the worker exits without notifying `spaceAvailable` again. 4. The producer’s predicate only checks queue size, so it can remain blocked forever; the destructor can also wait indefinitely if this occurs during shutdown. The PR says file-write errors retain their existing behavior, but the new condition-variable wait adds a stranded-waiter case on that existing fatal path. Please either make writer failure a synchronized terminal predicate that wakes all waiters (and ensure shutdown handles it consistently), or demonstrate with a deterministic failing stream test that this state cannot occur. Please add a focused regression for writer failure; the current test only exercises a recovering sink. I have not modified your branch.
MarcZX10 commented 2026-10-24 23:43:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T23:43:45Z.

Review: APPROVED


Rechecked exact head 58afe4560099d805edf020ae603e84a5fec063d6. The added writer-failure tests address the stranded-producer concern: they fill the bounded queue, verify four producers remain blocked, then trigger both a short write and a failed flush through the production CaptureTrace::run() catch and require the saved terminate handler to abort. The fixture distinguishes setup failure, watchdog exit, handler return, and the abort control result. The PR also clearly limits this evidence: the failure target uses the host C++ runtime; the separate probe with the project's Windows libc did not reach the catch, and that path is not claimed as covered.

I independently compiled CaptureTrace.cpp and CaptureTraceFailure.cpp from this exact head on Linux with g++ -std=c++20 -Wall -Wextra -Werror -pthread. The queue-backpressure case passed, and the CMake failure harness passed both write and flush modes. tools/check_conventions.py --base upstream/main --head upstream/pr/10760 and git diff --check pass. Hosted conventions and labels pass; the product build/test jobs are skipped by path filters, so I am not claiming hosted product coverage. The author reports the full Windows library/relinker builds and focused Windows suite in the PR description.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5640630588 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10760#pullrequestreview-5640630588). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T23:43:45Z. **Review:** APPROVED --- Rechecked exact head `58afe4560099d805edf020ae603e84a5fec063d6`. The added writer-failure tests address the stranded-producer concern: they fill the bounded queue, verify four producers remain blocked, then trigger both a short write and a failed flush through the production `CaptureTrace::run()` catch and require the saved terminate handler to abort. The fixture distinguishes setup failure, watchdog exit, handler return, and the abort control result. The PR also clearly limits this evidence: the failure target uses the host C++ runtime; the separate probe with the project's Windows libc did not reach the catch, and that path is not claimed as covered. I independently compiled `CaptureTrace.cpp` and `CaptureTraceFailure.cpp` from this exact head on Linux with `g++ -std=c++20 -Wall -Wextra -Werror -pthread`. The `queue-backpressure` case passed, and the CMake failure harness passed both `write` and `flush` modes. `tools/check_conventions.py --base upstream/main --head upstream/pr/10760` and `git diff --check` pass. Hosted conventions and labels pass; the product build/test jobs are skipped by path filters, so I am not claiming hosted product coverage. The author reports the full Windows library/relinker builds and focused Windows suite in the PR description.
MarcZX10 commented 2026-10-31 21:38:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T21:38:48Z.

Review: APPROVED


Reviewed — looks good

The exact head bounds capture-trace queue growth, records losses in order, and disables tracing after output failures; the relevant focused tests are registered, and I found no blocking issue.

What I ran

Reviewed head 6d26a5b8ebaa75a2e3c517c809ea045b1b6b47b4. The PR's API base is 684dfc1d561d09a8c35c7c153c95bcfed7e49896; a merge preview against current main 6190e0efeb2e686e763a00518547b593f23ff163 was clean. Environment: Debian Linux x86_64, Python 3.11.2, GCC 12.2.0. No build or C++ test binary was run locally.

git diff --check 684dfc1d561d09a8c35c7c153c95bcfed7e49896...6d26a5b8ebaa75a2e3c517c809ea045b1b6b47b4
python3 tools/check_conventions.py --base 684dfc1d561d09a8c35c7c153c95bcfed7e49896 --head 6d26a5b8ebaa75a2e3c517c809ea045b1b6b47b4
python3 tools/pr_stack_check.py 10760 --repo boykopovar/AnyPS5
python3 tools/pr_test_quality.py --root /marc/AnyPS5 --json core/libs/prx/libSceAgcDriver/tests/CaptureTrace.cpp core/libs/prx/libSceAgcDriver/tests/CaptureTraceFailure.cmake core/libs/prx/libSceAgcDriver/tests/CaptureTraceFailure.cpp core/libs/prx/libSceAgcDriver/tests/cmake/agc_capture_trace_tests.cmake

Results

Check Result
Diff and conventions Passed.
Current-main merge preview Clean; no declared dependency.
Test registration and assertions The heuristic flagged two C++ test paths because it searches for literal source paths. I verified the fragment is included through the tests/cmake/*.cmake CMake glob and registers both executables; queue tests check bounds, loss counts, record ordering, recovery and shutdown.
Hosted CI Current-head conventions and labels checks pass. No product build/test job is present in the hosted snapshot.
Focused Windows validation The PR description reports the three capture targets built and 17/17 capture/header CTests passed on this head; it also reports eight common capture tests passing on both main and this head. These are author-reported, not runs I independently performed.
Precheck helper availability The precheck's isolated snapshot did not contain workspace-only pr_abi_audit.py and pr_test_quality.py; those two helper invocations failed to start. ABI auditing is not applicable to these non-export changes.
Test-quality heuristic output
{
  "findings": [
    {
      "path": "core/libs/prx/libSceAgcDriver/tests/CaptureTrace.cpp",
      "line": 1,
      "kind": "possible-unregistered-cpp-test",
      "message": "Changed C++ test source path was not found literally in CMake files; inspect registration, generated source lists, and workflow coverage."
    },
    {
      "path": "core/libs/prx/libSceAgcDriver/tests/CaptureTraceFailure.cpp",
      "line": 1,
      "kind": "possible-unregistered-cpp-test",
      "message": "Changed C++ test source path was not found literally in CMake files; inspect registration, generated source lists, and workflow coverage."
    }
  ],
  "negative_control_candidates": [],
  "limits": [
    "Heuristics can miss weak assertions and can flag valid tests; inspect every finding.",
    "A test that passes against base is not by itself proof that the PR test is inadequate.",
    "Negative controls are only candidates until the test actually runs against base and fails by assertion rather than import/setup error."
  ]
}

Sources

Not verified

I did not build locally or run the C++ tests, and did not independently verify Linux/macOS, GPU, or console behavior. The author-reported Windows and paired common-test results above remain unverified by me.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5725025714 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10760#pullrequestreview-5725025714). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-31T21:38:48Z. **Review:** APPROVED --- # Reviewed — looks good The exact head bounds capture-trace queue growth, records losses in order, and disables tracing after output failures; the relevant focused tests are registered, and I found no blocking issue. ## What I ran Reviewed head `6d26a5b8ebaa75a2e3c517c809ea045b1b6b47b4`. The PR's API base is `684dfc1d561d09a8c35c7c153c95bcfed7e49896`; a merge preview against current `main` `6190e0efeb2e686e763a00518547b593f23ff163` was clean. Environment: Debian Linux x86_64, Python 3.11.2, GCC 12.2.0. No build or C++ test binary was run locally. ```sh git diff --check 684dfc1d561d09a8c35c7c153c95bcfed7e49896...6d26a5b8ebaa75a2e3c517c809ea045b1b6b47b4 python3 tools/check_conventions.py --base 684dfc1d561d09a8c35c7c153c95bcfed7e49896 --head 6d26a5b8ebaa75a2e3c517c809ea045b1b6b47b4 python3 tools/pr_stack_check.py 10760 --repo boykopovar/AnyPS5 python3 tools/pr_test_quality.py --root /marc/AnyPS5 --json core/libs/prx/libSceAgcDriver/tests/CaptureTrace.cpp core/libs/prx/libSceAgcDriver/tests/CaptureTraceFailure.cmake core/libs/prx/libSceAgcDriver/tests/CaptureTraceFailure.cpp core/libs/prx/libSceAgcDriver/tests/cmake/agc_capture_trace_tests.cmake ``` ## Results | Check | Result | |---|---| | Diff and conventions | Passed. | | Current-main merge preview | Clean; no declared dependency. | | Test registration and assertions | The heuristic flagged two C++ test paths because it searches for literal source paths. I verified the fragment is included through the `tests/cmake/*.cmake` CMake glob and registers both executables; queue tests check bounds, loss counts, record ordering, recovery and shutdown. | | Hosted CI | Current-head conventions and labels checks pass. No product build/test job is present in the hosted snapshot. | | Focused Windows validation | The PR description reports the three capture targets built and 17/17 capture/header CTests passed on this head; it also reports eight common capture tests passing on both main and this head. These are author-reported, not runs I independently performed. | | Precheck helper availability | The precheck's isolated snapshot did not contain workspace-only `pr_abi_audit.py` and `pr_test_quality.py`; those two helper invocations failed to start. ABI auditing is not applicable to these non-export changes. | <details><summary>Test-quality heuristic output</summary> ```text { "findings": [ { "path": "core/libs/prx/libSceAgcDriver/tests/CaptureTrace.cpp", "line": 1, "kind": "possible-unregistered-cpp-test", "message": "Changed C++ test source path was not found literally in CMake files; inspect registration, generated source lists, and workflow coverage." }, { "path": "core/libs/prx/libSceAgcDriver/tests/CaptureTraceFailure.cpp", "line": 1, "kind": "possible-unregistered-cpp-test", "message": "Changed C++ test source path was not found literally in CMake files; inspect registration, generated source lists, and workflow coverage." } ], "negative_control_candidates": [], "limits": [ "Heuristics can miss weak assertions and can flag valid tests; inspect every finding.", "A test that passes against base is not by itself proof that the PR test is inadequate.", "Negative controls are only candidates until the test actually runs against base and fails by assertion rather than import/setup error." ] } ``` </details> ## Sources - [Queue drop policy and writer failure handling at this head](https://github.com/boykopovar/AnyPS5/blob/6d26a5b8ebaa75a2e3c517c809ea045b1b6b47b4/core/libs/prx/libSceAgcDriver/Execution/include/CaptureTrace.hpp#L77-L143) - [Queue-loss and ordering assertions at this head](https://github.com/boykopovar/AnyPS5/blob/6d26a5b8ebaa75a2e3c517c809ea045b1b6b47b4/core/libs/prx/libSceAgcDriver/tests/CaptureTrace.cpp#L232-L385) - [CMake test-fragment registration at this head](https://github.com/boykopovar/AnyPS5/blob/6d26a5b8ebaa75a2e3c517c809ea045b1b6b47b4/core/libs/prx/libSceAgcDriver/tests/cmake/agc_capture_trace_tests.cmake#L54-L78) ## Not verified I did not build locally or run the C++ tests, and did not independently verify Linux/macOS, GPU, or console behavior. The author-reported Windows and paired common-test results above remain unverified by me.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!10760
No description provided.