Repository navigation
perf(agc): audit a cached template only after the host import set changed - #9012
SP4C3B4R-8 wants to merge 1 commit into
Conversation
|
This pull request is labeled |
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
Thanks for measuring this. The 44 µs per walk on Astro Bot is a real cost, and gating the audit on import changes makes sense if that is the only thing it has to catch. One data point from Demon's Souls before this goes in. The audit in #8047 is what fixed the DS level crawl (#8040). The released-texture check alone was not enough: with only that check, 2 of 2 runs still crawled (indexed-indirect draw ratio 439 and 436, normal is 200 to 225). With the timed audit added, 3 of 3 were normal on the old base and 3 of 3 on main 6762694. What I don't know yet is which change the audit catches on DS. If it is always a host import being added or retired, this PR keeps the fix. If something else changes a lookup's answer there, gating on I'm running DS with this PR on top of our stack tonight and will post the crawl ratios and the audit failure counts here when they're in. AI-assisted: yes |
|
Follow-up with the Demon's Souls numbers. This PR doesn't bring the crawl back on DS, and the audits it skips are not ones that fail there. Setup: our DS stack (main 6762694 plus #8047 and a few of our open fixes) with this PR cherry-picked, plus a local counter for audits that the import gate skips, audits that fail, and failures with no import change since the template's last full walk. Three 900 s runs from boot into the first level, judged by the indexed-indirect draw ratio from #8040 (normal 200 to 225, crawl 410 to 475) and a screenshot at t+400 s. Counts are totals over the whole run.
With the audit forced at every interval (run 2), 39 audits failed, and every one of them came after a host import was added or retired. None failed without an import change, so on DS the gate keeps exactly the case the audit exists for. All the failures fall in the title, menu and level-load stretch, where the import set churns. In the level itself no audit failed in any run. No crashes, and the screenshots are clean. Steady presents were 9.79 per 10 s with this PR and 9.57 with the audit forced, about 2% better (run 1 overlapped a build on the same machine, so I left its fps out). Caveats: one title and three runs. A lookup change that doesn't go through the host import set would get past the gate, and DS showed none. (Edited: the first version of this comment quoted counts from the last 10 s report only, which showed 0 failures. These are whole-run totals.) AI-assisted: yes |
CnRJay
left a comment
There was a problem hiding this comment.
The cost is measured on a scene where it matters (Astro Bot Crash Site: ~7,700 audit walks at about 44 us per 10 s; revalidate 1,542 ms to 1,162 ms per 10 s; APS5_TEMPLATE_AUDIT_MS=0 gives the same 1,180 ms, so the PR reaches the "audit off" cost) and the reasoning for the condition is sound: the answer the audit guards depends on HostImportCovers, which can only change when the import set does.
- The generation is process-wide. Any import added or retired anywhere makes
walkImportGeneration != HostImportSetGeneration()true for every cached template at its next use past the interval. With ~1,600 templates at ~44 us that is about 70 ms of audit walks landing in the frames right after one import, on the committer, which is the bound thread in this scene. In a scene that imports regularly (streaming, #8926's rewatch, windows retiring and being replaced) the saving shrinks and the cost arrives as hitches. Please post the audits per 10 s and the worst frame time on a scene that streams imports, or stagger it: audit at most N templates per frame after a change, oldestlastFullWalkfirst. - The test says the import "also fails the fast proof by itself (full path, failure
Other), so the audit is not what catches it there". So no test shows the audit catching a stale answer after an import change, which is the only case it still exists for, and the only case this PR can break. Add one where the fast proof would pass and only the audit catches it, with an import added (the audit runs) and with an unrelated change (it doesn't). HostImportSetGenerationis bumped "wherever the registry'sepochis bumped" and where an import is inserted. List the sites in the description and add a test that fails if a new bump site forgets it, since a missing bump silently disables the audit.
5771aac to
19191f4
Compare
|
@CnRJay thanks, all three points are addressed in the new push (rebased on 1. Audits after one import change are now spread out. Audits per 10 s on Astro Bot (PPSA21564) with this PR, from boot through the menu, the hub load and the Crash Site hub ( 2. A test where only the audit runs after an import, and one where it doesn't.
Mutation: with the bump after the import insert removed (and the generation About the last step: in this fixture the import of the bound surface fails the fast proof itself. The import re-arms write tracking of the range, so the fast proof fails on 3. Bump sites. There are no separate bumps any more. Performance capture (same build, 19191f4, Crash Site hub, warm caches,
Tests on the rebase: AI-assisted: yes (Claude Code) |
|
@SP4C3B4R-8, this still carries |
|
@panicDa3m0n yes please, that would help: an alternated A/B at Crash Site, AI-assisted: yes (Claude Code) |
|
Thanks @SP4C3B4R-8. I'll run the alternated pair at Crash Site, |
|
@SP4C3B4R-8, the alternated A/B you asked for:
Per round (rounds 1 to 6), this PR minus
Three runs had their 150 s window start near present 4,800-5,000 instead of 2,600-2,700: runs 1 and 12 (both Where the time goes, from the traces: ms per present summed over the thread, this PR minus
The queue 0 worker is busy 98.7 to 98.9% of the window in all twelve runs. A profiled pair, separate from the A/B (
Reading of the numbers (AI-assisted):
Summary lines, in run order{"commit":"d6eafa54d046","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"13312","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"150:5"},"gpu":"NVIDIA GeForce RTX 4070 Ti SUPER","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz","cpu_threads":16,"memory_mib":32599,"title_id":"PPSA21567","title":"ASTRO BOT","content_version":"01.019.000","resolution":"3840x2160","window":{"spec":"seconds 150:5","first_present":4972,"ms":5147.612},"presents":31,"frame_ms":{"p50":167.36,"p90":175.426,"p99":177.992,"max":177.992},"gpu_busy_ms_per_present":139.637,"worker_busy_pct":{"queue worker 0x0":98.759,"queue worker 0x40":97.698,"queue worker 0x48":88.554,"queue worker 0x46":4.664},"top_phases_ms_per_frame":{"Driver.Packet":480.607,"Driver.Packet.memory_wait":274.15,"Driver.Packet.draw":97.616,"Driver.Draw":96.491,"Graphics.Draw":85.504,"Graphics.Draw.draw_and_resource_release":68.385,"Driver.Draw.shader_compile_and_link":54.439,"Driver.Packet.prepare_memory":45.847},"trace_dropped":false,"trace":"aps5-trace-d6eafa54d046-8152.json.gz"}
{"commit":"19191f4ea263","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"13312","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"150:5"},"gpu":"NVIDIA GeForce RTX 4070 Ti SUPER","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz","cpu_threads":16,"memory_mib":32599,"title_id":"PPSA21567","title":"ASTRO BOT","content_version":"01.019.000","resolution":"3840x2160","window":{"spec":"seconds 150:5","first_present":2672,"ms":5036.035},"presents":29,"frame_ms":{"p50":175.86,"p90":181.506,"p99":184.268,"max":184.268},"gpu_busy_ms_per_present":157.641,"worker_busy_pct":{"queue worker 0x0":98.774,"queue worker 0x40":97.846,"queue worker 0x48":94.081,"queue worker 0x46":9.056},"top_phases_ms_per_frame":{"Driver.Packet":520.138,"Driver.Packet.memory_wait":295.873,"Driver.Packet.draw":88.37,"Driver.Draw":87.244,"Graphics.Draw":77.007,"Driver.Packet.prepare_memory":61.107,"Graphics.Draw.draw_and_resource_release":59.743,"Driver.Packet.dispatch":53.233},"trace_dropped":false,"trace":"aps5-trace-19191f4ea263-22164.json.gz"}
{"commit":"d6eafa54d046","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"13312","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"150:5"},"gpu":"NVIDIA GeForce RTX 4070 Ti SUPER","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz","cpu_threads":16,"memory_mib":32599,"title_id":"PPSA21567","title":"ASTRO BOT","content_version":"01.019.000","resolution":"3840x2160","window":{"spec":"seconds 150:5","first_present":2681,"ms":5060.239},"presents":30,"frame_ms":{"p50":168.823,"p90":176.758,"p99":180.831,"max":180.831},"gpu_busy_ms_per_present":149.354,"worker_busy_pct":{"queue worker 0x0":98.801,"queue worker 0x40":97.63,"queue worker 0x48":94.542,"queue worker 0x46":8.097},"top_phases_ms_per_frame":{"Driver.Packet":504.052,"Driver.Packet.memory_wait":290.954,"Driver.Packet.draw":85.657,"Driver.Draw":84.509,"Graphics.Draw":80.305,"Graphics.Draw.draw_and_resource_release":63.844,"Driver.Packet.prepare_memory":62.216,"Driver.Draw.shader_compile_and_link":50.704},"trace_dropped":false,"trace":"aps5-trace-d6eafa54d046-22280.json.gz"}
{"commit":"19191f4ea263","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"13312","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"150:5"},"gpu":"NVIDIA GeForce RTX 4070 Ti SUPER","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz","cpu_threads":16,"memory_mib":32599,"title_id":"PPSA21567","title":"ASTRO BOT","content_version":"01.019.000","resolution":"3840x2160","window":{"spec":"seconds 150:5","first_present":2698,"ms":5031.162},"presents":30,"frame_ms":{"p50":168.125,"p90":174.995,"p99":176.086,"max":176.086},"gpu_busy_ms_per_present":154.246,"worker_busy_pct":{"queue worker 0x0":98.776,"queue worker 0x40":97.672,"queue worker 0x48":94.193,"queue worker 0x46":9.669},"top_phases_ms_per_frame":{"Driver.Packet":503.252,"Driver.Packet.memory_wait":285.077,"Driver.Packet.draw":86.029,"Driver.Draw":84.894,"Graphics.Draw":74.637,"Graphics.Draw.draw_and_resource_release":58.032,"Driver.Packet.dispatch":56.162,"Driver.Packet.prepare_memory":55.277},"trace_dropped":false,"trace":"aps5-trace-19191f4ea263-3816.json.gz"}
{"commit":"d6eafa54d046","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"13312","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"150:5"},"gpu":"NVIDIA GeForce RTX 4070 Ti SUPER","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz","cpu_threads":16,"memory_mib":32599,"title_id":"PPSA21567","title":"ASTRO BOT","content_version":"01.019.000","resolution":"3840x2160","window":{"spec":"seconds 150:5","first_present":2670,"ms":5108.42},"presents":30,"frame_ms":{"p50":171.441,"p90":177.708,"p99":185.174,"max":185.174},"gpu_busy_ms_per_present":150.877,"worker_busy_pct":{"queue worker 0x0":98.818,"queue worker 0x40":98.232,"queue worker 0x48":94.513,"queue worker 0x46":9.605},"top_phases_ms_per_frame":{"Driver.Packet":512.43,"Driver.Packet.memory_wait":292.073,"Driver.Packet.draw":90.816,"Driver.Draw":89.705,"Graphics.Draw":80.562,"Graphics.Draw.draw_and_resource_release":63.864,"Driver.Packet.prepare_memory":59.172,"Driver.Draw.shader_compile_and_link":51.148},"trace_dropped":false,"trace":"aps5-trace-d6eafa54d046-19564.json.gz"}
{"commit":"19191f4ea263","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"13312","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"150:5"},"gpu":"NVIDIA GeForce RTX 4070 Ti SUPER","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz","cpu_threads":16,"memory_mib":32599,"title_id":"PPSA21567","title":"ASTRO BOT","content_version":"01.019.000","resolution":"3840x2160","window":{"spec":"seconds 150:5","first_present":2673,"ms":5164.923},"presents":30,"frame_ms":{"p50":173.546,"p90":178.765,"p99":182.587,"max":182.587},"gpu_busy_ms_per_present":154.052,"worker_busy_pct":{"queue worker 0x0":98.751,"queue worker 0x40":97.731,"queue worker 0x48":94.007,"queue worker 0x46":7.956},"top_phases_ms_per_frame":{"Driver.Packet":513.426,"Driver.Packet.memory_wait":296.143,"Driver.Packet.draw":83.251,"Driver.Draw":82.134,"Graphics.Draw":75.004,"Driver.Packet.prepare_memory":67.543,"Graphics.Draw.draw_and_resource_release":58.274,"Recorder.WaitSerial":54.497},"trace_dropped":false,"trace":"aps5-trace-19191f4ea263-28320.json.gz"}
{"commit":"d6eafa54d046","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"13312","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"150:5"},"gpu":"NVIDIA GeForce RTX 4070 Ti SUPER","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz","cpu_threads":16,"memory_mib":32599,"title_id":"PPSA21567","title":"ASTRO BOT","content_version":"01.019.000","resolution":"3840x2160","window":{"spec":"seconds 150:5","first_present":2697,"ms":5085.977},"presents":29,"frame_ms":{"p50":175.586,"p90":185.992,"p99":192.942,"max":192.942},"gpu_busy_ms_per_present":155.272,"worker_busy_pct":{"queue worker 0x0":98.766,"queue worker 0x40":97.796,"queue worker 0x48":94.22,"queue worker 0x46":9.693},"top_phases_ms_per_frame":{"Driver.Packet":526.603,"Driver.Packet.memory_wait":298.415,"Driver.Packet.draw":94.59,"Driver.Draw":93.437,"Graphics.Draw":80.565,"Graphics.Draw.draw_and_resource_release":63.973,"Driver.Packet.prepare_memory":58.478,"Driver.Packet.dispatch":54.1},"trace_dropped":false,"trace":"aps5-trace-d6eafa54d046-13024.json.gz"}
{"commit":"19191f4ea263","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"13312","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"150:5"},"gpu":"NVIDIA GeForce RTX 4070 Ti SUPER","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz","cpu_threads":16,"memory_mib":32599,"title_id":"PPSA21567","title":"ASTRO BOT","content_version":"01.019.000","resolution":"3840x2160","window":{"spec":"seconds 150:5","first_present":2610,"ms":5078.559},"presents":27,"frame_ms":{"p50":187.094,"p90":199.273,"p99":203.459,"max":203.459},"gpu_busy_ms_per_present":170.02,"worker_busy_pct":{"queue worker 0x0":98.91,"queue worker 0x40":98.229,"queue worker 0x48":93.957,"queue worker 0x46":13.559},"top_phases_ms_per_frame":{"Driver.Packet":572.643,"Driver.Packet.memory_wait":328.882,"Driver.Packet.draw":80.032,"Driver.Draw":78.945,"Graphics.Draw":74.815,"Driver.Packet.prepare_memory":74.155,"Driver.Packet.dispatch":69.102,"Driver.Dispatch":66.452},"trace_dropped":false,"trace":"aps5-trace-19191f4ea263-15060.json.gz"}
{"commit":"19191f4ea263","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"13312","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"150:5"},"gpu":"NVIDIA GeForce RTX 4070 Ti SUPER","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz","cpu_threads":16,"memory_mib":32599,"title_id":"PPSA21567","title":"ASTRO BOT","content_version":"01.019.000","resolution":"3840x2160","window":{"spec":"seconds 150:5","first_present":2683,"ms":5037.46},"presents":29,"frame_ms":{"p50":176.617,"p90":180.722,"p99":185.974,"max":185.974},"gpu_busy_ms_per_present":152.507,"worker_busy_pct":{"queue worker 0x0":98.7,"queue worker 0x40":97.668,"queue worker 0x48":97.613,"queue worker 0x46":9.731},"top_phases_ms_per_frame":{"Driver.Packet":527.101,"Driver.Packet.memory_wait":301.15,"Driver.Packet.draw":88.367,"Driver.Draw":87.224,"Graphics.Draw":78.25,"Graphics.Draw.draw_and_resource_release":60.967,"Driver.Packet.dispatch":59.397,"Driver.Dispatch":56.65},"trace_dropped":false,"trace":"aps5-trace-19191f4ea263-2552.json.gz"}
{"commit":"d6eafa54d046","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"13312","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"150:5"},"gpu":"NVIDIA GeForce RTX 4070 Ti SUPER","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz","cpu_threads":16,"memory_mib":32599,"title_id":"PPSA21567","title":"ASTRO BOT","content_version":"01.019.000","resolution":"3840x2160","window":{"spec":"seconds 150:5","first_present":2715,"ms":5022.611},"presents":29,"frame_ms":{"p50":174.751,"p90":185.149,"p99":189.206,"max":189.206},"gpu_busy_ms_per_present":156.952,"worker_busy_pct":{"queue worker 0x0":98.778,"queue worker 0x40":97.612,"queue worker 0x48":93.47,"queue worker 0x46":7.514},"top_phases_ms_per_frame":{"Driver.Packet":514.624,"Driver.Packet.memory_wait":296.292,"Driver.Packet.draw":91.186,"Driver.Draw":90.042,"Graphics.Draw":83.189,"Graphics.Draw.draw_and_resource_release":66.018,"Driver.Packet.prepare_memory":58.756,"Driver.Draw.shader_compile_and_link":52.95},"trace_dropped":false,"trace":"aps5-trace-d6eafa54d046-5280.json.gz"}
{"commit":"19191f4ea263","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"13312","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"150:5"},"gpu":"NVIDIA GeForce RTX 4070 Ti SUPER","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz","cpu_threads":16,"memory_mib":32599,"title_id":"PPSA21567","title":"ASTRO BOT","content_version":"01.019.000","resolution":"3840x2160","window":{"spec":"seconds 150:5","first_present":2696,"ms":5133.729},"presents":30,"frame_ms":{"p50":171.66,"p90":178.243,"p99":180.319,"max":180.319},"gpu_busy_ms_per_present":144.422,"worker_busy_pct":{"queue worker 0x0":98.74,"queue worker 0x40":97.663,"queue worker 0x48":94.21,"queue worker 0x46":9.896},"top_phases_ms_per_frame":{"Driver.Packet":513.659,"Driver.Packet.memory_wait":292.62,"Driver.Packet.draw":89.151,"Driver.Draw":88.03,"Graphics.Draw":78.097,"Graphics.Draw.draw_and_resource_release":60.622,"Driver.Packet.dispatch":55.333,"Driver.Packet.prepare_memory":55.05},"trace_dropped":false,"trace":"aps5-trace-19191f4ea263-8520.json.gz"}
{"commit":"d6eafa54d046","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"13312","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"150:5"},"gpu":"NVIDIA GeForce RTX 4070 Ti SUPER","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz","cpu_threads":16,"memory_mib":32599,"title_id":"PPSA21567","title":"ASTRO BOT","content_version":"01.019.000","resolution":"3840x2160","window":{"spec":"seconds 150:5","first_present":4796,"ms":5149.502},"presents":31,"frame_ms":{"p50":166.007,"p90":174.995,"p99":179.774,"max":179.774},"gpu_busy_ms_per_present":136.177,"worker_busy_pct":{"queue worker 0x0":98.745,"queue worker 0x40":97.702,"queue worker 0x48":94.349,"queue worker 0x46":8.351},"top_phases_ms_per_frame":{"Driver.Packet":496.525,"Driver.Packet.memory_wait":286.112,"Driver.Packet.draw":92.319,"Driver.Draw":91.195,"Graphics.Draw":83.633,"Graphics.Draw.draw_and_resource_release":66.548,"Driver.Draw.shader_compile_and_link":54.712,"Driver.Packet.prepare_memory":49.09},"trace_dropped":false,"trace":"aps5-trace-d6eafa54d046-13632.json.gz"}trace_digest.py, first line of each trace, in run orderThe traces follow in the next comment, one zip per round with that round's two traces, summary lines and |
|
Traces of the twelve runs in the comment above, one zip per round with that round's two traces, their pr9012-ab-round1.zip |
|
A Linux/RADV data point for 19191f4 (one build with #9899 under it; Setup: ASTRO BOT (PPSA21567) Sky Garden, 3840x2160, no input, headless gamescope, Ryzen 7 7800X3D, RX 9070 XT (RADV Mesa 26.2.4), GCC Release. Base
No device loss, page fault or With and without Measured and written by Claude (AI assistant) on a contributor's machine. |
|
A Windows run of this head on an AMD device and a second NVIDIA generation: Windows 11 Home 10.0.26200, WinLibs GCC 15.2.0 r7 (MinGW-w64 UCRT), Release. The 14 tests built from
The build has no errors. Its two warnings are AI-assisted: yes (Claude Code) |
|
AMD data (amdvlk on Windows), as asked for: ASTRO BOT's Crash Site hub. Every run with this PR is faster than every run of its parent, by about 4 % on average. That is the same direction and size as the NVIDIA numbers. One caveat: switching the audit off altogether on the parent gains less than this PR does, so I cannot attribute the whole difference to skipped audits.
AI-assisted: yes (Claude Code). The runs were made on my machine. |
|
Thanks for the A/B data in the thread (NVIDIA, AMD on Windows and RADV). Reviewed at |
|
Maintainer edits are on, but this branch conflicts with current |
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
Carry #9012 while preserving current recent-import and insertion bookkeeping. Exercise joined import generation and stable repeated lookups. Co-authored-by: SP4C3B4R-8 <SP4C3B4R-8@users.noreply.github.com>
|
Hi @SP4C3B4R-8, Thank you for this change and for the A/B data on NVIDIA, AMD and RADV. The carry, #14838, merged into If anything from this branch didn't make it into #14838, say so here and we'll pick it up. |
What
#8047 (@fisherjoey) made a cached
ShaderResourcestake the full walk instead of the fast proof once its last full walk is older thanAPS5_TEMPLATE_AUDIT_MS(1000 ms). The case it names is a sampled lookup whose answer changes without any lookup running: a snapshot whose surface became host-imported is viewed through its storage image from then on. That answer depends onHostImportCovers, so it can only change when the set of host imports changes.On a committer-bound scene the audit is a steady cost. Astro Bot (PPSA21564), Crash Site hub, has ~1,600 cached templates, so it runs ~7,700 full walks per 10 s, about 44 µs each. In these runs no audit failed a template (
failed 0).This PR keeps the interval and adds one condition: the audit runs only when a host import was added or retired since the template's last full walk.
GuestBufferMemory.cppkeeps a process-wideimportSetGeneration, read byHostImportSetGeneration().bumpEpoch(state)replaces every++state.epoch(retireImport, the device change inrefreshImports,ClearHostImports) and bumps the generation too;importSetChanged()follows the import insert inimportRunAt.ShaderResourcesrecords the generation when it is built and at the start of each full walk (walkImportGeneration). The audit condition becomesTemplateAuditDue(lastFullWalk) && (AuditEveryInterval() || walkImportGeneration != HostImportSetGeneration()).APS5_TEMPLATE_AUDIT_BUDGET(default 8,0= no limit) start per 4 ms across all templates. A template over the budget keeps the fast proof and audits at a later use.ProofReport::auditedsays whether the proof took the full walk because of the audit.APS5_TEMPLATE_AUDIT_ALWAYS=1restores the audit at every interval, without the budget.APS5_TEMPLATE_AUDIT_MS=0still turns it off.The released-texture check from #8047 is unchanged.
Tested
Windows 11, RTX 5070 Ti (NVIDIA 617.42), Ryzen 7 7800X3D, MinGW GCC 15.2, Release. First measured on
main27c88a8 (table below). Rebased onmaind6eafa5 on 10-22, measured again and retested (see the review reply for the captures).APS5_PROFILE_DRAW=1, same session:mainmain+APS5_TEMPLATE_AUDIT_MS=0(two runs)mainagain (two runs)Frame dumps of the hub with this PR look the same as
main.APS5_TEMPLATE_AUDIT_ALWAYS=1. Audits per 10 s with this PR: 1, 15, 78, 157, 14 through the menu and the load, then 0 in the level. Committer busy per frame (tools/trace_digest.py): 46.5 vs 49.4 ms.SampledCacheBudgetresource-lookup-changed: past the interval with no import change, and after a write to an unrelated surface, the proof stays fast and is not audited. After a host import of an unrelated surface the next proof past the interval is audited and keeps the bound texture. After the import of the bound surface the proof fails and the rebuilt template binds the storage view. Mutation: without the insert bump the test fails at the audit step.agc_driver_graphics_testsand 124 ctests (*draw*,*stencil*,*indirect*,*multisample*,*msaa*,*target*,*pass*,*sampled_cache*,*resource_cache*,*host_import*): all pass apart from the relinker testunused_filter_indirect, which does not touch this code.python tools/check_conventions.py --base origin/main: all checks passed.Performance report
Capture on
mainand with this change, same title, scene and machine, by @panicDa3m0n (full table, profiled pair and all twelve summary lines in his comment and the comment after it). Astro Bot Crash Site, 3840x2160, RTX 4070 Ti SUPER (NVIDIA 616.64), i7-11700K, Windows 10.0.26200, MinGW GCC 15.2 Release,maind6eafa5 (this head's parent) against 19191f4,APS5_TRACE_SECONDS=150:5, six alternated rounds.Graphics.Drawon the committer is lower in all six rounds, with either build first: −8.5, −5.7, −5.6, −5.8, −4.9, −5.5 ms per frame.main, none with this PR; revalidate 1,734.7 against 1,606.2 ms per 10 s; 35.6 against 33.1 µs per pipelined commit; no failed proof.VUID.Round 1 summary lines (
main, then this PR):{"commit":"d6eafa54d046","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"13312","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"150:5"},"gpu":"NVIDIA GeForce RTX 4070 Ti SUPER","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz","cpu_threads":16,"memory_mib":32599,"title_id":"PPSA21567","title":"ASTRO BOT","content_version":"01.019.000","resolution":"3840x2160","window":{"spec":"seconds 150:5","first_present":4972,"ms":5147.612},"presents":31,"frame_ms":{"p50":167.36,"p90":175.426,"p99":177.992,"max":177.992},"gpu_busy_ms_per_present":139.637,"worker_busy_pct":{"queue worker 0x0":98.759,"queue worker 0x40":97.698,"queue worker 0x48":88.554,"queue worker 0x46":4.664},"top_phases_ms_per_frame":{"Driver.Packet":480.607,"Driver.Packet.memory_wait":274.15,"Driver.Packet.draw":97.616,"Driver.Draw":96.491,"Graphics.Draw":85.504,"Graphics.Draw.draw_and_resource_release":68.385,"Driver.Draw.shader_compile_and_link":54.439,"Driver.Packet.prepare_memory":45.847},"trace_dropped":false,"trace":"aps5-trace-d6eafa54d046-8152.json.gz"} {"commit":"19191f4ea263","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"13312","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"150:5"},"gpu":"NVIDIA GeForce RTX 4070 Ti SUPER","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz","cpu_threads":16,"memory_mib":32599,"title_id":"PPSA21567","title":"ASTRO BOT","content_version":"01.019.000","resolution":"3840x2160","window":{"spec":"seconds 150:5","first_present":2672,"ms":5036.035},"presents":29,"frame_ms":{"p50":175.86,"p90":181.506,"p99":184.268,"max":184.268},"gpu_busy_ms_per_present":157.641,"worker_busy_pct":{"queue worker 0x0":98.774,"queue worker 0x40":97.846,"queue worker 0x48":94.081,"queue worker 0x46":9.056},"top_phases_ms_per_frame":{"Driver.Packet":520.138,"Driver.Packet.memory_wait":295.873,"Driver.Packet.draw":88.37,"Driver.Draw":87.244,"Graphics.Draw":77.007,"Driver.Packet.prepare_memory":61.107,"Graphics.Draw.draw_and_resource_release":59.743,"Driver.Packet.dispatch":53.233},"trace_dropped":false,"trace":"aps5-trace-19191f4ea263-22164.json.gz"}tools/trace_digest.py, first line of each:Traces: round 1, 2, 3, 4, 5, 6.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)