perf(agc): skip unused retire registry snapshots without unit shadows #25963

Merged
malekaifa merged 1 commit from upstream-pr/25963 into main 2026-11-23 09:44:24 +00:00
malekaifa commented 2026-11-23 01:26:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by malekaifa on 2026-11-23T01:26:03Z.


What

When unit shadows are disabled (APS5_NO_UNIT_SHADOW=1, or write watching makes UnitShadowEnabled() false), WaitForLeasesAndImports still builds a whole-registry GuestAllocationsAcquireRegistered() snapshot before retiring an overlapping host import. RetireShadow immediately returns in that configuration, so its coverage predicate never observes that lease.

Pass an empty GuestAllocations::Lease{} at the two pin-waiter retirement sites when unit shadows are off. The default unit-shadow-on path is unchanged, as are recorder waits, import retirement, and the broader whole-registry lease design.

This addresses the measured registry-copy hot path reported in #6453 when unit shadows are disabled. It does not claim to fix the issue's default unit-shadow-on stall.

Tested

  • Dell Windows checkout on current main d32e21402929: git diff --check passed and py -3 tools/check_conventions.py --base origin/main --head HEAD passed.
  • The published fork commit is byte-identical to that local candidate: GuestBufferMemory.cpp blob 9eb0a5ef5f719817ab9ad97f4638f6538d107267, one file, +2/-2.
  • No local C++ build was run on the Dell checkout because its compiler/Ninja toolchain is not available in PATH; CI is expected to provide compile coverage.
  • The #6453 reporter independently tested this exact conditional locally on Ubuntu 24.04 / AMD Radeon Pro V620 (RADV, Mesa 25.2.8), with APS5_NO_UNIT_SHADOW=1, in the Ratchet & Clank scene described there. Across two runs per arm, main-thread samples in _Rb_tree_increment / GuestAllocationsAcquireRegistered fell from 14.3% / 4.3% and 14.4% / 4.0% to 0.5% / none and 0.4% / none. Presents in the first 60 s after the flash went from 34/35 to 51/46; in the first 100 s from 73/77 to 93/89. The longest frame stayed about 5.2-5.8 s, so this PR does not claim to remove the separate longest freeze.
  • Open-PR overlap review: #13863 also edits WaitForLeasesAndImports, but only its recorder finish/sync path; it does not touch or replace these two registry-snapshot acquisitions. #24510 and #19351 touch other GuestBufferMemory/unit-shadow paths, not these lines.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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: none
  • Unblocks: none
  • GPUs tested: AMD Radeon Pro V620 (RADV, Mesa 25.2.8, Ubuntu 24.04 VM) by the #6453 reporter on the matching local conditional; no local GPU run of this exact fork commit
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5445516483 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25963). Originally posted by [malekaifa](https://github.com/malekaifa) on 2026-11-23T01:26:03Z. --- ### What When unit shadows are disabled (`APS5_NO_UNIT_SHADOW=1`, or write watching makes `UnitShadowEnabled()` false), `WaitForLeasesAndImports` still builds a whole-registry `GuestAllocationsAcquireRegistered()` snapshot before retiring an overlapping host import. `RetireShadow` immediately returns in that configuration, so its coverage predicate never observes that lease. Pass an empty `GuestAllocations::Lease{}` at the two pin-waiter retirement sites when unit shadows are off. The default unit-shadow-on path is unchanged, as are recorder waits, import retirement, and the broader whole-registry lease design. This addresses the measured registry-copy hot path reported in #6453 when unit shadows are disabled. It does **not** claim to fix the issue's default unit-shadow-on stall. ### Tested - Dell Windows checkout on current `main` `d32e21402929`: `git diff --check` passed and `py -3 tools/check_conventions.py --base origin/main --head HEAD` passed. - The published fork commit is byte-identical to that local candidate: `GuestBufferMemory.cpp` blob `9eb0a5ef5f719817ab9ad97f4638f6538d107267`, one file, +2/-2. - No local C++ build was run on the Dell checkout because its compiler/Ninja toolchain is not available in PATH; CI is expected to provide compile coverage. - The #6453 reporter independently tested this exact conditional locally on Ubuntu 24.04 / AMD Radeon Pro V620 (RADV, Mesa 25.2.8), with `APS5_NO_UNIT_SHADOW=1`, in the Ratchet & Clank scene described there. Across two runs per arm, main-thread samples in `_Rb_tree_increment` / `GuestAllocationsAcquireRegistered` fell from 14.3% / 4.3% and 14.4% / 4.0% to 0.5% / none and 0.4% / none. Presents in the first 60 s after the flash went from 34/35 to 51/46; in the first 100 s from 73/77 to 93/89. The longest frame stayed about 5.2-5.8 s, so this PR does not claim to remove the separate longest freeze. - Open-PR overlap review: #13863 also edits `WaitForLeasesAndImports`, but only its recorder finish/sync path; it does not touch or replace these two registry-snapshot acquisitions. #24510 and #19351 touch other `GuestBufferMemory`/unit-shadow paths, not these lines. ### Checklist - [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 and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's technical 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: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: AMD Radeon Pro V620 (RADV, Mesa 25.2.8, Ubuntu 24.04 VM) by the #6453 reporter on the matching local conditional; no local GPU run of this exact fork commit - [x] AI-assisted: yes
copilot-pull-request-reviewer[bot] commented 2026-11-23 01:26:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-23T01:26:12Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6015618025 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25963#pullrequestreview-6015618025). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-11-23T01:26:12Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
MarcZX10 commented 2026-11-23 01:38:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T01:38:48Z.

Review: APPROVED


Reviewed — looks good

Nothing in the inspected changes blocks merging; the reported performance improvement still needs independent verification.

What I ran

Reviewed head 86765d3651680b86403a8ff577a6b5fdfbb850a8; base main. No build or tests were run. I read description.md, commits.md, manifest.json, diff.patch, and the changed lines and relevant functions through repo_read.py.

Results

Check Result Note
Diff and affected code passed Both changed call sites and their retirement path inspected
Build and tests not run No execution performed
Reported performance data not run Author and issue reporter results were not independently reproduced

Findings

Blocking

None.

Non-blocking

  • GuestBufferMemory.cpp:4266 and GuestBufferMemory.cpp:4332: the condition matches the documented intent. With unit shadows disabled, the lease is empty; RetireShadow immediately returns in that configuration, and the registry snapshot is avoided. The default unit-shadow-enabled path still acquires the registered lease. Consider adding regression coverage for the disabled path and measuring the change on the PR head; the supplied measurements describe a matching local conditional, not this exact fork commit.

Not verified

No build, automated tests, or independent performance reproduction was run. The full changed file was excluded from the review folder; I read its changed lines and relevant ranges via repo_read.py. files.json was not present in the review folder listing; the manifest marks the one changed file as excluded for size.

To get this to a good state

Nothing is required. Optional: add coverage for the no-unit-shadow retirement path and verify the performance result on the PR head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6015679357 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25963#pullrequestreview-6015679357). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-23T01:38:48Z. **Review:** APPROVED --- # Reviewed — looks good Nothing in the inspected changes blocks merging; the reported performance improvement still needs independent verification. ## What I ran Reviewed head `86765d3651680b86403a8ff577a6b5fdfbb850a8`; base `main`. No build or tests were run. I read `description.md`, `commits.md`, `manifest.json`, `diff.patch`, and the changed lines and relevant functions through `repo_read.py`. ## Results | Check | Result | Note | |---|---|---| | Diff and affected code | passed | Both changed call sites and their retirement path inspected | | Build and tests | not run | No execution performed | | Reported performance data | not run | Author and issue reporter results were not independently reproduced | ## Findings ### Blocking None. ### Non-blocking - `GuestBufferMemory.cpp:4266` and `GuestBufferMemory.cpp:4332`: the condition matches the documented intent. With unit shadows disabled, the lease is empty; `RetireShadow` immediately returns in that configuration, and the registry snapshot is avoided. The default unit-shadow-enabled path still acquires the registered lease. Consider adding regression coverage for the disabled path and measuring the change on the PR head; the supplied measurements describe a matching local conditional, not this exact fork commit. ## Not verified No build, automated tests, or independent performance reproduction was run. The full changed file was excluded from the review folder; I read its changed lines and relevant ranges via `repo_read.py`. `files.json` was not present in the review folder listing; the manifest marks the one changed file as excluded for size. ## To get this to a good state Nothing is required. Optional: add coverage for the no-unit-shadow retirement path and verify the performance result on the PR head.
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!25963
No description provided.