Repository navigation
Conversation
|
SWAG (PPSA22102) check: the untracked population is small here, no hot-path reduction Stack tested: #6187 + #6209 combined at Measured Setup: Squirrel with a Gun Worker sampler, inclusive share of samples (function anywhere in the stack, all PCs aggregated, counted once per stack). Baseline final/mid2 -> stack final/mid2:
Method note: this aggregates every PC of a function. My earlier #7947 comment quoted only the hottest PC, which understates multi-PC functions there (e.g. Untracked population, per 10 s window: Timing, same setup, steady tail medians (last 20 x 10 s windows): AI-generated analysis (not measured) The proof only pays when target key ranges are not write-watched. On SWAG nearly all sub-1 MiB host imports are back in the write watch (6223-6332 of ~6240), so there is almost nothing for the memo/proof to elide, unlike the MGS4 ranges in ps54all's comment. What changes instead is when the worker blocks: DCC path counts that do involve untracked comparisons go down ( Artifacts (I will drag them in): |
|
swag-run26-baseline-symbolized.txt |
|
@TheAggie This PR now conflicts with main in |
cachedTexture scans its sampled texture's DCC keys before the storage-source choice, after a keys reset and after a pending flush. Route those scans through ProvedClearKeys and keep the proof in a small per-thread table so a lookup reuses it instead of rereading the same key range. The proof is still validated by ProvedClearKeys, so a write between scans scans again. On Windows, untracked host imports continue to scan until boykopovar#6209 supplies their proof.
cachedTexture scans its sampled texture's DCC keys before the storage-source choice, after a keys reset and after a pending flush. Route those scans through ProvedClearKeys and keep the proof in a small per-thread table so a lookup reuses it instead of rereading the same key range. The proof is still validated by ProvedClearKeys, so a write between scans scans again. On Windows, untracked host imports continue to scan until boykopovar#6209 supplies their proof.
cachedTexture scans its sampled texture's DCC keys before the storage-source choice, after a keys reset and after a pending flush. Route those scans through ProvedClearKeys and keep the proof in a small per-thread table so a lookup reuses it instead of rereading the same key range. The proof is still validated by ProvedClearKeys, so a write between scans scans again. Key the table by the DCC address, surface bytes, guest format and alpha position: textureClearKeys can return a clear for one view and Uncompressed for another view of the same range when FillDccClear cannot encode it. Add a two-format DccKeyPresync case that samples one range as R16_UNORM, then as R5G6B5, and checks the second view reads its stored texels. On Windows, untracked host imports continue to scan until boykopovar#6209 supplies their proof.
cachedTexture scans its sampled texture's DCC keys before the storage-source choice, after a keys reset and after a pending flush. Route those scans through ProvedClearKeys and keep the proof in a small per-thread table so a lookup reuses it instead of rereading the same key range. The proof is still validated by ProvedClearKeys, so a write between scans scans again. Key the table by the DCC address, surface bytes, guest format and alpha position: textureClearKeys can return a clear for one view and Uncompressed for another view of the same range when FillDccClear cannot encode it. Add a two-format DccKeyPresync case that samples one range as R16_UNORM, then as R5G6B5, and checks the second view reads its stored texels. On Windows, untracked host imports continue to scan until boykopovar#6209 supplies their proof.
cachedTexture scans its sampled texture's DCC keys before the storage-source choice, after a keys reset and after a pending flush. Route those scans through ProvedClearKeys and keep the proof in a small per-thread table so a lookup reuses it instead of rereading the same key range. The proof is still validated by ProvedClearKeys, so a write between scans scans again. Key the table by the DCC address, surface bytes, guest format and alpha position: textureClearKeys can return a clear for one view and Uncompressed for another view of the same range when FillDccClear cannot encode it. Add a two-format DccKeyPresync case that samples one range as R16_UNORM, then as R5G6B5, and checks the second view reads its stored texels. On Windows, untracked host imports continue to scan until boykopovar#6209 supplies their proof.
|
stale+rebase 1. Freshness Envelope
2. Findings
3. Cross-PR Ledger
|
|
@TheAggie, #6187 is closed: it landed on main through #14261 (merged 4 Nov) with your commits and authorship, and #14262 carries #6192 the same way. This branch still contains #6187's commits and conflicts with main in If you want to continue this change, please rebase it onto current main so that only the DCC key proof commit remains, and reconcile it with the untracked-memory proof tracking main now has. The earlier request for perf numbers also still stands: the two reports so far (an MGS4 run on a local stack, and PPSA22102 showing a small untracked population and no hot-path reduction) do not show a gain for this head. A paired run on PPSA21564 or another title that shows a difference above the noise floor would settle whether it is worth carrying. |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — changes requested
Changes are required before merge: guard the address-range arithmetic in ForgetPages and ForgetStamp against overflow.
What I ran
Reviewed head b00f936b31fe9ba4946ee35dd3fd9f9bc707806c from the prepared diff and pinned reader. I did not run tests or a build.
No commands run; review bundle inspected through reader tools.
Results
| Check | Result | Note |
|---|---|---|
| Diff and changed code | passed | Reviewed included changed files and relevant ranges |
| Build and tests | not run | No execution environment available |
Findings
Blocking
GuestMemory::ForgetPagesandForgetStampcomputeaddress + bytes - 1without checking overflow. If a nonempty range ends pastUINT64_MAX, this wraps and computes an invalid last block;ForgetPagesmay then fail to invalidate the range stamp, andForgetStampmay report a stale stamp. This can leave a cached comparison or DCC key proof valid after memory in its range was forgotten. Validate the range before derivinglast, or use checked/saturating range arithmetic. Changed lines:core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp:487andcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp:81.
Non-blocking
None.
Sources
- The arithmetic is used in
ForgetPagesandForgetStampin the reviewed changed code atcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp.
Not verified
- No build or tests were run. Runtime behavior on Windows and Linux was not verified.
files.jsonwas unavailable through the reader, so the exclusions list could not be checked. All seven changed paths listed inmanifest.jsonwere included; the final manifest entry,core/libs/prx/libSceAgcDriver/tests/Recorder.cpp, was not read in full, only the changed test hunks from the diff were inspected.
To get this to a good state
- Add overflow-safe range validation to both calculations, then rerun the relevant recorder tests and build on the new head.
What
Stacked on #6187; only the last two commits are this PR. Independent of #6192, except that both add a test at the same place in
CMakeLists.txtandtests/Recorder.cpp, a trivial conflict for whichever lands second.ProvedClearKeysandProvedCurrentDccKeysskip the scan of a surface's DCC keys while the key range is unchanged since the last scan, proved byCollectWritesandUnchangedSince. Over keys the write watch does not cover (on Windows, every host-pointer import of the guest mapping, #1441),CollectWritesreturns 0, so no proof is ever kept and every use scans the keys again.In RetroArch's Flycast core (PPSA99169) on Windows: 3.7 million key scans per 10 s (72 GB read, 2.2 s), with 0 proved and every one counted unstable.
NewestStamp(driver stores into the keys),ForgetStamp(perf(agc): an untracked comparison memo holds until memory it covers is forgotten #6187) and the recorder's newest pending write note over the keys. A scan that is otherwise stable becomes the proof with that stamp, and a later call with the same stamp returns the proved keys without scanning.compareUntracked,docs/dev/ARCHITECTURE.md): a CPU store into untracked memory is seen at the next ordering point. Pending GPU writes still make a scan unstable, as before.Tested
Windows 11, NVIDIA GeForce RTX 5070 Ti, MinGW-w64 GCC 15.2.0, on main
8cd937e29with #6187; rebased onto main92e50418fwith #6187 (only a CMake test list conflicted), where the full suite passes 1276 of 1296, 14 skipped, failing only the known tests below andagc_driver_multisample_fill_host_only, which passes when run alone.ctest: 1233 of 1249 pass, 14 skipped.guest_call_trace_abortandwindows_backtrace_reportfail, and fail the same way on plain main here.agc_driver_prepared_graphics_prebuild_0/_1andundeliverable_host_exceptionfail under my test runner because it skips their environment changes and pass pattern; run with those, they pass.agc_untracked_key_proofs(agc_driver_recorder_tests --untracked-key-proofs-only): keys in an untracked allocation. In one collect epoch the secondProvedClearKeysand the secondProvedCurrentDccKeyscome from the proof; after a store into the keys and a new epoch the keys are scanned again and read as changed. Without this change the test fails with "a second key proof over untracked memory in the same collect epoch scanned the keys again".ProvedClearKeyschange alone did not move it measurably; with theProvedCurrentDccKeyschange as well, 65.3% and 66.9% of real time against 68.0% and 68.0% (that stack also had perf(agc): fast revalidation over untracked memory proves a surface by its stamp until the next ordering point #6192). I have no measurement ofmainalone.Related: #6060 keeps Windows imports of private write-watched memory on
GetWriteWatchwhen a start-up probe allows it; key ranges it keeps watched never reach this path.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code