Repository navigation
Conversation
|
@TheAggie I had a variant of this running locally when #6192 went up, and measured it at Astro Bot's title (PPSA21567, the Design difference. Instead of a stamp taken in
On a microbenchmark (16 untracked sampled surfaces) this took At the title it saved nothing. Setup:
The one window of the title intro before the press agrees:
So the proof does what the counters promise:
But a revalidation costs the same either way. Solving the two rows, a full walk costs only about 7 µs more than a fast proof here, and the other ~580 µs of each On safety, both runs show the same three I'm not opening this as a competing PR: at this title it doesn't buy anything over #6192, and #6192 has measured gains on Flycast. If you do want the stamp to outlive the epoch for hinted ranges, the test I used ( AI-assisted: yes |
|
@TheAggie a heads-up: we'd like to open a PR stacked on this one shortly, with "Depends on: #6192", merging after yours. In Resident Evil Village (PPSA01556)'s static menu, collect epochs advance about 80 times a second, so a proof this PR accepts by its stamp rarely outlives its epoch. On Windows, an unwatched range also has a write-watch hint, and our commit uses it. While the hint hasn't moved, an untracked fast proof holds across epochs.
The branch is perf/agc-untracked-proof-hint-key-on-6192 on our fork (fdc7004). Your four commits are unchanged. On top of them it has:
|
|
GTA V (PPSA04263, 01.011.001) data point on Windows, from tibzejoker's port: +28% FPS at story start. The proof self-check found 0 disagreements. Setup
Results
Correctness
AI-assisted (Claude Code). All numbers come from runs on the machine above. |
|
stale+rebase Findings
Freshness Envelope
Cross-PR Ledger
|
|
Thank you @TheAggie for this change, and @tibzejoker for the port onto current We've carried it forward in #14262, stacked on #14261 (the carry of #6187), so both can land on today's I'm closing this one in favour of #14262 so there's only one place to review. If you'd rather keep this PR and pick up those additions yourself, say so and we'll do it that way instead. |
The counter commit below reads APS5_COUNT_WALKS without a row in docs/dev/ENVIRONMENT.md, which the conventions check refuses. This adds the row. It goes with the counter and is not for a pull request either. The report of this branch follows, as in the counter commit fb0be86. Report (v2) Branch draft/revalidate-walks-v2, based on upstream main 4ac683f. Commits: - 3e89f8a perf(agc): look up only the changed textures when a template's memory moved (unchanged from v1) - 795405a perf(agc): fail a template on a released texture without the full walk (unchanged from v1) - 3ac1c0d perf(agc): find a template's changed elements in one tracker query - 983e273 perf(agc): relook changed elements from lookup recipes captured once - this counter v1's report (draft/revalidate-walks, aefbec8) still holds for every reason a walk runs and for the relook and replaced arguments. What each addition costs, per call and per frame: - ChangedSince, proof passes: the same single tracker lock and one range check per query as UnchangedSinceAll, plus a clear of a thread-local vector and one branch per query. Nothing measurable per Revalidate. - ChangedSince, 'memory changed': v1 took UnchangedSinceAll's lock, then one more lock, covers check and range check for each of Q queries to name the changed ones. Now one lock and Q range checks. That is Q lock round trips saved per failure. Calls per frame: the [walks] relook counts (same + differing + fell back). - Recipes, capture: once per template, on its first relook. One pass over its bindings and table elements, which is what v1's relook did on every call, plus about 64 bytes per element held by the template. - Recipes, each later relook: v1 re-enumerated all bindings and table elements (narrowing and null-checking every sampled descriptor) to reach k changed elements. Now k recipe reads, a sort of k entries by build order, and the k lookups. Calls per frame: as above. - Neither adds work to a proof that passes. Why the recipes are the walk's lookups: - The walk derives each lookup from the bindings it is passed. ShaderResources::ContentKey puts every non-data binding's descriptor words, image shapes and compare bits into the cache key, so a template found under that key has its build's descriptors. - The recipe holds those raw words. Sampled elements are narrowed by firstLayerWords at each lookup, as the walk does. Components and multisample view type are derived as the walk derives them. Storage elements keep the build's mip, written flag and dedupe (index - 1). - Lookups run in the walk's order: bindings stage by stage, then tables. - A layout the walk would refuse (no program, more than 8 words per element, a table index out of step, counts not matching textures[] or storageTextures[]) marks the recipes refused. Those templates take the full walk. Conservative fallbacks, unchanged and tested: - The relook starts only when 'memory changed' is the fast proof's sole failure. That check runs after the pending-registry, key and metadata, depth and cache checks. - The rerun repeats all of those. - Import identity, the serial loop and staging checks of revalidateFull's steps 2 and 3 run after either path, as before. - A DCC key change fails on keys, and the test shows it takes the full walk with no relook. Lookup-induced eviction: a sampled cache hit never evicts. admitTexture evicts only on inserting a new texture, and a lookup that inserts has returned a new object, so the relook returns Differs at that element. It fails before any rerun, and no evicted object is proved. The test shows it: a one-byte budget, the changed texture's new copy evicts the other bound texture, and the proof fails after one relooked lookup. Tests: ChangedRelook, now two ctest entries. - agc_driver_changed_relook (imported memory): the 96-texture table cases from v1, plus the layered, DCC and eviction cases. - agc_driver_changed_relook_copied (APS5_NO_HOST_IMPORT=1, APS5_VERIFY_PROOFS=1): the same synthetic cases plus a storage image and its sampled view over one surface. The table set is not reusable without imports, so it runs only in the first entry. - Results: - Storage and sampled alias, same bytes: relooked, 2 lookups, current. Changed bytes: relooked, not current. - First layer of a 2D array: same bytes relooked with 1 lookup and current; changed not current. - DCC: same bytes under uncompressed keys relooked, 1 lookup, current. Keys cleared to 0x00: full walk, 0 relooked, not current. - Eviction: relooked, 1 lookup, not current, the other bound texture released. - Every outcome's current flag matched a run with APS5_NO_CHANGED_RELOOK=1 (the full walk alone), checked by hand. The copied entry also runs the walk beside every relooked proof that passes, through APS5_VERIFY_PROOFS. Mutations, all caught: - Recipe without the image shape (no first-layer narrowing): "a same-byte store in the sampled first layer of a 2D array took the relook ... not current", in both modes. - ChangedSince stopping at the first changed query: "stores over 2 textures looked 1 textures up again" (imported); the storage alias case "took the full walk" (copied). - v1's mutations still apply. Also run on lavapipe (Mesa 25.2.8 llvmpipe, LLVM 20.1.2, Ubuntu 24.04), ANYPS5_NO_SHADER_CACHE=1, 33 of 33 passing with 3 skipped by their own checks: agc_driver_graphics (with maps fallback), agc_driver_recorder, agc_copy_guest_bytes, alpha_to_coverage, array_layer_target, cached_image_multisample_guard, changed_relook (both), image_table_reuse, lookup_log_fits_build, multisample_fill_host_only, native_multisample_depth, own_refresh_repack_alias, packed_mip_tail_target, partially_resident_*, sample_multisample_target, sampled_cache_budget_*, storage_cache_budget, storage_one_slice_alias, list_restart, quad_list_index_overflow. check_conventions passes. Not reached: - Storage images and views over imported memory: lavapipe compares imports instead of write-watching them, so their collect refuses and they always take the full walk there. Open boykopovar#14262, boykopovar#6192 and boykopovar#12921 address that reason. - Views whose source is a storage image in an image table. - Depth surfaces, which never produce a changed query. - A hardware GPU, the validation layer, and the title's real cost. Run APS5_COUNT_WALKS=1 on GTA V for calls per frame. Overlaps as in v1: boykopovar#10894, boykopovar#9012, boykopovar#11444, boykopovar#14262, boykopovar#12575. No speed claims. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011mLh2cdhBwJrK5hBZGnNyy Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011mLh2cdhBwJrK5hBZGnNyy
…for boykopovar#6187/boykopovar#6192 The per-block walk of untracked texture snapshots (drawcpu r2) walked each run of watched or hinted blocks with one collect. A run with uncommitted or no-access pages makes the Windows collector refuse the whole walk, so every block of the run was hashed ('walk refused', ~490k blocks / 30 GB per 10 s in the open world). The walk now takes the range's readable runs (DescribeCommitted) and collects only those pages. The entry keeps the layout it was proved at; a block is clean only when its clipped readable runs equal the baseline's and no stamp or hint is newer, so the hash (zeros for unreadable pages) cannot differ. The compare hashes with the same layout. [texhash] adds 'partly readable' and 'layout changed'. APS5_NO_UNTRACKED_LAYOUT=1 restores the whole-run walk. APS5_NO_UNTRACKED_FAST_PROOF=1 turns off boykopovar#6192's stamp proof, APS5_NO_FORGET_STAMPS=1 makes boykopovar#6187's ForgetStamp the global serial again. AI-assisted: yes
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
Nothing blocks this change; the reviewed code and supplied validation evidence support merging.
What I ran
Reviewed head 2d030407eb8f3ac7fb8078e1fd0d48d95acf450f using the prepared diff and repo_read.py at the pinned head. No tests or build commands were run in this review; the Windows test and performance results below are author-reported.
Results
| Check | Result | Note |
|---|---|---|
| Changed code review | passed | Six changed files read |
| Tests in this review | not run | Author reports new test and suite results |
| Linux behavior | not run | Author reports Linux untested |
Findings
Blocking
None.
Non-blocking
None.
Not verified
The changed lines in core/libs/prx/libSceAgcDriver/tests/Recorder.cpp were not read; the file was excluded from the review folder as too large. Its diff was reviewed. The supplied Windows suite, targeted test, and Flycast measurements were not independently run. Linux behavior was not tested.
To get this to a good state
Nothing is required.
What
Stacked on #6187; only the last two commits are this PR.
A cached resource template is reused only after
ShaderResources::Revalidateproves its textures and storage images current. The fast proof (fastRevalidate) answers from write stamps; a surface in memory the write watch does not cover (on Windows, every host-pointer import of the guest mapping, #1441) has none, soCollectWritesreturns 0, the fast proof fails withcollect, and the full walk repeats every texture lookup.In RetroArch's Flycast core (PPSA99169) on Windows: 2.06 million of 2.2 million revalidations per 10 s took the full walk for that reason, and revalidation took 15.2 s of thread time per 10 s in all.
captureValidation), each surface over untracked memory also records a stamp: the collect epoch,NewestStamp(driver stores into the range),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 range. Storage images get the same, instorageUntracked.fastRevalidateaccepts such a surface while its stamp is unchanged, instead of failing withcollect, and leaves it out of theUnchangedSinceAllquery. Everything else in the fast proof is as before: the keys, the pending-image scan and the cache checks still run.compareUntrackedalready uses for untracked memory: a CPU store there is seen at the next ordering point (docs/dev/ARCHITECTURE.md, "Untracked storage image comparisons"). A collect epoch of 0 or a forget in progress gives no stamp, so the full walk runs.APS5_VERIFY_UNTRACKED_PROOFS=1runs the full walk beside every fast proof that involved an untracked surface and reports how often it disagreed.Tested
Windows 11, NVIDIA GeForce RTX 5070 Ti, MinGW-w64 GCC 15.2.0, on main
8cd937e29with #6187; rebased onto main92e50418f(only a CMake test list conflicted), where the full suite passes 1277 of 1296, 14 skipped, failing only the known tests below.ctest: 1229 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_driver_multisample_fill_host_onlyfailed once in the parallel run and passed three times out of three run alone.agc_untracked_revalidate(agc_driver_recorder_tests --untracked-revalidate-only): a sampled template over an untracked allocation proves on the fast path twice in one collect epoch; after a CPU store and a new epoch it takes the full walk. Without this change the test fails with "a sampled template over untracked memory took the full walk in the same collect epoch".APS5_VERIFY_UNTRACKED_PROOFS=1: 1,600,000 fast proofs over untracked memory checked by the full walk, 0 disagreed.ANYPS5_PRESENT_MODE=immediate, unprofiled, on the local stack described in perf(agc): an untracked comparison memo holds until memory it covers is forgotten #6187 with perf(agc): an untracked comparison memo holds until memory it covers is forgotten #6187 included: two runs each, audio produced at 63.1% and 62.6% of real time without this change against 65.3% and 66.9% with it. Fast proofs per 10 s went from 0.13 million of 2.2 million revalidations to 1.96 million of 2.48 million; the committer's lookup phase went from 9.75 to 5.75 µs per draw. I have no measurement ofmainalone.Related: #6060 keeps Windows imports of private write-watched memory on
GetWriteWatchwhen a start-up probe allows it; memory it keeps watched never reaches this path, so this PR matters for what stays untracked (imports through views, devices whose probe fails). I have not measured how much of the Flycast workload #6060 would cover.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