Repository navigation
perf(agc): skip forgetting known-zero pages that no commit marked again - #22506
Conversation
StorageTexture::markLayersPending forgets the known-zero pages of the layers a draw writes. The forget takes the global WindowsMappings mutex on every draw, although after the first draw the range holds no known-zero bit. Only markZero sets those bits, so it now advances a counter, and a texture skips the forget while the counter is unchanged and the range lies inside the one it last forgot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GtFtGrfcHTXazyD8pfg1n3
|
This pull request is labeled |
|
Ran the AGC zero, pending, clear, alias, readback, writeback and upload tests with the Khronos validation layer on Linux and NVIDIA's proprietary driver, since the PR was tested on Windows only. Setup: Arch Linux (kernel 7.3.4), GCC 16.2.1, Release, NVIDIA GeForce RTX 4090 (vendor
No new AI-assisted: yes (Claude Code) |
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
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.
|
|
GTA V numbers for this change, measured together with #22411 / #22506, because we carry both. The two are in one build, so this is their combined effect, not each one's.
S − M: p50 −3.4 ± 1.7 ms (−3.0%), p90 −19.2 ± 4.8 ms (standard error of the difference, 2 boots per build). p99 doesn't separate. Thanks for both. |
|
Head No new failures and no new validation messages on either GPU.
Layer runs used AI-assisted: yes |
What
Each draw that writes a storage texture forgets the known-zero pages of the layers it writes (
StorageTexture::markLayersPendingcallsGuestMemory::ForgetKnownZero). The forget takes the globalWindowsMappingsmutex, which other threads hold for whole write-watch collects, so on a busy title the draw committer waits on it, although after the first draw over a target the range holds no known-zero bit.Only
WindowsMappings::markZerosets known-zero bits (a fresh watched private commit and a fresh resident run). It now advances an atomic counter after it sets them, read through a new libc exportGuestArenaKnownZeroMarks_nid_no_patch(GuestMemory::KnownZeroMarksin the driver; 0 off Windows). EachStorageTextureremembers the counter value it read before its last forget and the range it forgot, and skips the forget when the counter is unchanged and the layers lie inside that range. No bit can have been set in the range since, so the skipped call would have cleared nothing. A counter change or a range outside the remembered one forgets as before.<atomic>is now included inWindowsMappings.hppunconditionally (it was only included withAPS5_COUNT_MAPPING_QUERIES).Tested
Windows 10 Pro 22H2 (19045), NVIDIA GeForce RTX 4060, driver 621.14.
windows_write_watchhas a new check: a watched private commit and a fresh resident run advance the counter,ForgetKnownZeroand an unwatched commit do not, and the forgotten range is no longer known zero.GPU tests, same build directory,
main2218a29 and this PR (then on 2218a29; rebased onto 5adb7d2, whose 67 new commits change no file of libc orlibSceAgcDriver),ctest -R <197 write-watch and AGC layer, pending, clear, zero, target, alias, readback, writeback and upload tests> -j 4 -VwithANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer(validation layer 1.4.363):main: 193 passed, 3 skipped, 1 failed (agc_driver_stencil_plane_memory, "a consumed stencil clear was lost on a read-only rebind"), 0VUID-lines, the layer inserted 256 times,was not found but was requested0 times.VUID-lines, the layer inserted 256 times,was not found but was requested0 times.(
agc_driver_upload_cache_read_only_flushdoes not build on Windows on currentmain(setenv; #19899, #22366, #22373), so it is not in either run.)Astroneer (PPSA27623), opening cutscene (#21967), no input, 140 s launches, warm launch of each cold + warm pair, same machine. Plain
mainaborts or draws this scene wrongly (#21967), so both arms carry the #16053 revert, plus #18293, #18757 and #22001, the open PRs with which the draw committer limits this scene (queue worker 0 is 96 % busy without them): base e7fbc2c890 =mainf0c01bc + #16053 revert + #18293 + #18757 + #22001, change 432fd77993 = the same plus this PR's change (without the new test). Switches on both:APS5_DRAW_PIPELINE=1 APS5_PIPELINE_DISPATCH=1 APS5_PIPELINE_DISPATCH_MISSES=1 APS5_PIPELINE_STATS=1 APS5_ARM_BLOCKS=1, relinked with--frame-red-zone(#18293). The 62maincommits after f0c01bc touch no file of libc, AGC, the shader recompiler, VideoOut or the relinker. FPS is the 30-90 s window of the summary clock (the cutscene advances with frames, so a faster arm reaches the faster part of the scene sooner); commits are the[draw] pipelinedlines over the same window.Launch order: base pair 1, PR pair 1, PR pair 2, base pair 2 (launches of another variant ran between the last two). One more PR warm launch, before PR pair 1, crashed at 20 s during loading in the title's
AK::BankManagerthread (access violation reading 0x84000008cc) and was run again. This title has crashed with access violations in about 1 of 11 launches on other builds here too (TaskGraphThreadHP,FAsyncLoadingThread), and known-zero bits do not change guest memory: they only let a collect drop a written page whose bytes are still all zero.Committer samples (
APS5_SAMPLE_COMMITTER, pair 2, whole launch):GuestArenaForgetKnownZero_nid_no_patchis in 10988 of 93531 samples (11.7 %) on the base, 9926 of them underStorageTexture::markLayersPending, and in 1615 of 90285 (1.8 %) with this PR, where the remaining forgets come from label, fill and sample-dump writes (Recorder::noteWrite,GuestMemory::MarkWritten).markLayersPendinggoes from 11.5 % to 1.3 % of the samples.trace_digest.pyof the summary files (the 300:10 trace window starts after the 140 s launches, so no window trace was written):Captures with a trace window, for the comparison the Performance report form asks for: the same two builds and switches, one cold + warm launch each (base, then this PR),
APS5_TRACE_SECONDS=50:10, warm launches. The window is 50-60 s of the cutscene on both; since the scene advances with frames, the faster build is somewhat further into the same planet-surface part. Warm 30-90 s FPS of these launches: base 13.26, this PR 18.02.tools/performance_compare.py --require-matching-contextreports no configuration difference between the two lines.Graphics.Draw.draw_and_resource_release(ms per frame)Traces: base, this PR.
aps5-summary.jsonlwindow lines (base, then this PR):{"commit":"e7fbc2c8907e","dirty":false,"env":{"APS5_ARM_BLOCKS":"1","APS5_DRAW_PIPELINE":"1","APS5_DUMP_FRAMES":"100000","APS5_DUMP_FRAMES_EVERY":"30","APS5_DUMP_SCALE":"8","APS5_PIPELINE_DISPATCH":"1","APS5_PIPELINE_DISPATCH_MISSES":"1","APS5_PIPELINE_STATS":"1","APS5_RELINK_RELOCATE_RED_ZONE":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"50:10","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 4060","driver":"NVIDIA 621.14","os":"Windows 10.0.19045","cpu":"AMD Ryzen 5 5600 6-Core Processor","cpu_threads":12,"memory_mib":32678,"title_id":"PPSA27623","title":"ASTRONEER","content_version":"01.015.000","resolution":"3840x2160","window":{"spec":"seconds 50:10","first_present":1139,"ms":10032.549},"presents":134,"frame_ms":{"p50":73.224,"p90":81.620,"p99":92.189,"max":101.308},"gpu_busy_ms_per_present":38.470,"worker_busy_pct":{"queue worker 0x0":88.515,"queue worker 0x20":99.975},"phase_totals_ms":{"Driver.Completion":1.633,"Driver.Dispatch":359.364,"Driver.Dispatch.capture_resources":156.177,"Driver.Dispatch.decode_key_device_setup":6.959,"Driver.Dispatch.lookup_cache":1.010,"Driver.Dispatch.materialize":5.596,"Driver.Dispatch.prepared_invocation":4.962,"Driver.Draw":6334.183,"Driver.Draw.device_setup":407.481,"Driver.Draw.draw_handed_off":5154.943,"Driver.Draw.prepare":739.164,"Driver.DrawFinish":8217.107,"Driver.DrawFinish.draw_enqueued":5303.587,"Driver.DrawFinish.post_compile_prepare":56.992,"Driver.DrawFinish.shader_compile_and_link":2802.146,"Driver.EndSubmission":106.836,"Driver.Packet":18801.884,"Driver.Packet.device_lock":92.415,"Driver.Packet.dispatch":696.971,"Driver.Packet.draw":6405.868,"Driver.Packet.execute":619.641,"Driver.Packet.flip_flush":6.473,"Driver.Packet.flush_between_packets":206.049,"Driver.Packet.memory_wait":9582.844,"Driver.Packet.pipeline_drain":473.101,"Driver.Packet.pipeline_prepare":134.150,"Driver.Packet.prepare_memory":193.301,"Driver.Packet.rendering_wait":0.238,"Driver.Present":1848.077,"Driver.Present.acquire_image":2.215,"Driver.Present.device_setup":0.089,"Driver.Present.gpu_mutex_wait":4.553,"Driver.Present.inflight_wait":0.362,"Driver.Present.present_display_buffer":19.729,"Driver.Present.queue_present":64.580,"Driver.Present.release_and_callback":0.272,"Driver.Present.render_fence_wait":1755.899,"Driver.Present.resize":0.238,"Driver.Present.validate":0.040,"Driver.Suspend":0.031,"GpuMutex.wait.dispatch":44.479,"GpuMutex.wait.draw":68.834,"GpuMutex.wait.end":32.587,"GpuMutex.wait.fill":9.646,"GpuMutex.wait.flush":0.456,"GpuMutex.wait.hook":84.234,"GpuMutex.wait.label":50.978,"GpuMutex.wait.other":142.088,"GpuMutex.wait.present":4.266,"GpuMutex.wait.wait":1.507,"Graphics.Draw":8110.434,"Graphics.Draw.draw_and_resource_release":6878.394,"Graphics.Draw.index_upload":361.901,"Graphics.Draw.validate":243.611,"Graphics.Draw.vertex_upload":525.458,"Recorder.Reap":77.674,"Recorder.Submit":279.038,"Resources.Complete":33.202,"Resources.Prepare":35.540,"Shader.DrawStage":2543.718,"Shader.DrawStage.capture_resources":1269.566,"Shader.DrawStage.materialize":703.852,"Shader.DrawStage.prepared_invocation":535.146,"VideoOut.Flip":1861.925,"VideoOut.Flip.completion_mutex_wait":0.212,"VideoOut.Flip.config_mutex_wait":0.013,"VideoOut.Flip.frame_limit":0.102,"VideoOut.Flip.notify_game":3.682,"VideoOut.Flip.present":1849.081,"VideoOut.Flip.validate":0.168,"VideoOut.Flip.vblank_wait":0.105,"VideoOut.Flip.window_prepare":0.218,"VideoOut.Flip.window_title":8.129,"VideoOut.Readiness":0.319,"VideoOut.Readiness.locks_validate":0.127,"Vulkan.Acquire":2.029,"Vulkan.Acquire.acquire_fence_wait":0.292,"Vulkan.Acquire.acquire_image":1.258,"Vulkan.Acquire.fence_reset":0.345,"Vulkan.Acquire.retired_swapchains":0.079,"Vulkan.Dispatch":76.359,"Vulkan.Dispatch.command_record":37.351,"Vulkan.Dispatch.shader_resources":37.799,"Vulkan.Present":14.060,"Vulkan.Present.command_record_scale":6.202,"Vulkan.Present.pixel_upload":1.198,"Vulkan.Present.queue_submit":6.521,"Vulkan.QueuePresent":64.249,"Vulkan.QueuePresent.queue_present":63.982,"Vulkan.Retire":1755.838,"Vulkan.Retire.dump":1.091,"Vulkan.Retire.wait":1752.440},"top_phases_ms_per_frame":{"Driver.Packet":140.313,"Driver.Packet.memory_wait":71.514,"Driver.DrawFinish":61.322,"Graphics.Draw":60.526,"Graphics.Draw.draw_and_resource_release":51.331,"Driver.Packet.draw":47.805,"Driver.Draw":47.270,"Driver.DrawFinish.draw_enqueued":39.579},"owned_draw_counts":{"OwnedDraw.evicted_other":5115},"graphics_track":{"Graphics.Barrier.copy":1751,"Graphics.Barrier.dcc-clear":1876,"Graphics.Barrier.dcc-keys":804,"Graphics.Barrier.dispatch-lead":1077,"Graphics.Barrier.dispatch-trail":1742,"Graphics.Barrier.draw":19108,"Graphics.Barrier.fill":1571,"Graphics.Barrier.fill-clear":804,"Graphics.Barrier.input-mirror":977,"Graphics.Barrier.label-run":38899,"Graphics.Barrier.present-blit":268,"Graphics.Barrier.shadow-publish":268,"Graphics.Barrier.staging-in":938,"Graphics.Barrier.staging-out":402,"Graphics.Barrier.storage-writeback":3648,"Graphics.BarrierMerged.dispatch-lead":665,"Graphics.BarrierMerged.fill":1109,"Graphics.BarrierMerged.label-run":510,"Graphics.BarrierMerged.shadow-publish":268,"Graphics.BarrierMerged.staging-in":268,"Graphics.BarrierMerged.staging-out":402,"Graphics.BarrierMerged.storage-writeback":908,"Graphics.Copy":2451,"Graphics.Copy.bytes":3929240604,"Graphics.RenderPass":10435,"Graphics.RenderPass.Close.command":3145,"Graphics.RenderPass.Close.image":1319,"Graphics.RenderPass.Close.key":756,"Graphics.RenderPass.Close.label":510,"Graphics.RenderPass.Close.new-batch":4705,"Graphics.RenderPass.Continued":243202},"trace_dropped":false,"trace":"aps5-trace-e7fbc2c8907e-8284.json.gz"} {"commit":"432fd7799362","dirty":false,"env":{"APS5_ARM_BLOCKS":"1","APS5_DRAW_PIPELINE":"1","APS5_DUMP_FRAMES":"100000","APS5_DUMP_FRAMES_EVERY":"30","APS5_DUMP_SCALE":"8","APS5_PIPELINE_DISPATCH":"1","APS5_PIPELINE_DISPATCH_MISSES":"1","APS5_PIPELINE_STATS":"1","APS5_RELINK_RELOCATE_RED_ZONE":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"50:10","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 4060","driver":"NVIDIA 621.14","os":"Windows 10.0.19045","cpu":"AMD Ryzen 5 5600 6-Core Processor","cpu_threads":12,"memory_mib":32678,"title_id":"PPSA27623","title":"ASTRONEER","content_version":"01.015.000","resolution":"3840x2160","window":{"spec":"seconds 50:10","first_present":1285,"ms":10004.784},"presents":181,"frame_ms":{"p50":52.308,"p90":65.998,"p99":101.594,"max":132.174},"gpu_busy_ms_per_present":39.122,"worker_busy_pct":{"queue worker 0x0":88.403,"queue worker 0x20":99.935},"phase_totals_ms":{"Driver.Completion":2.675,"Driver.Dispatch":566.512,"Driver.Dispatch.capture_resources":269.652,"Driver.Dispatch.decode_key_device_setup":10.938,"Driver.Dispatch.lookup_cache":1.897,"Driver.Dispatch.materialize":7.585,"Driver.Dispatch.prepared_invocation":7.393,"Driver.Draw":5167.748,"Driver.Draw.device_setup":668.807,"Driver.Draw.draw_handed_off":3211.247,"Driver.Draw.prepare":1237.784,"Driver.DrawFinish":7481.016,"Driver.DrawFinish.draw_enqueued":3069.628,"Driver.DrawFinish.post_compile_prepare":90.735,"Driver.DrawFinish.shader_compile_and_link":4247.851,"Driver.EndSubmission":115.372,"Driver.Packet":18724.663,"Driver.Packet.device_lock":144.320,"Driver.Packet.dispatch":1661.043,"Driver.Packet.draw":5274.131,"Driver.Packet.execute":920.846,"Driver.Packet.flip_flush":8.298,"Driver.Packet.flush_between_packets":390.030,"Driver.Packet.memory_wait":8621.744,"Driver.Packet.pipeline_drain":701.351,"Driver.Packet.pipeline_prepare":219.494,"Driver.Packet.prepare_memory":270.256,"Driver.Packet.rendering_wait":0.381,"Driver.Present":2572.144,"Driver.Present.acquire_image":3.187,"Driver.Present.device_setup":0.135,"Driver.Present.gpu_mutex_wait":5.983,"Driver.Present.inflight_wait":0.550,"Driver.Present.present_display_buffer":28.265,"Driver.Present.queue_present":88.413,"Driver.Present.release_and_callback":0.440,"Driver.Present.render_fence_wait":2444.603,"Driver.Present.resize":0.360,"Driver.Present.validate":0.058,"Driver.Suspend":0.127,"GpuMutex.wait.dispatch":46.396,"GpuMutex.wait.draw":111.680,"GpuMutex.wait.end":17.917,"GpuMutex.wait.fill":22.190,"GpuMutex.wait.flush":2.414,"GpuMutex.wait.hook":129.831,"GpuMutex.wait.label":91.114,"GpuMutex.wait.other":73.714,"GpuMutex.wait.present":5.584,"GpuMutex.wait.wait":7.698,"Graphics.Draw":7069.442,"Graphics.Draw.draw_and_resource_release":5110.299,"Graphics.Draw.index_upload":616.795,"Graphics.Draw.validate":363.209,"Graphics.Draw.vertex_upload":832.198,"Recorder.Reap":150.647,"Recorder.Submit":385.725,"Resources.Complete":43.969,"Resources.Prepare":49.715,"Shader.DrawStage":3845.730,"Shader.DrawStage.capture_resources":1828.898,"Shader.DrawStage.materialize":1164.452,"Shader.DrawStage.prepared_invocation":798.105,"Shader.PrepareArtifact":15.155,"Shader.Register":3.211,"Shader.ResolveAbi":0.438,"Shader.ResolveGraphicsAbi":0.044,"Shader.ResolveGraphicsStagesAbi":6.322,"VideoOut.Flip":2601.572,"VideoOut.Flip.completion_mutex_wait":0.400,"VideoOut.Flip.config_mutex_wait":0.073,"VideoOut.Flip.frame_limit":0.135,"VideoOut.Flip.notify_game":12.525,"VideoOut.Flip.present":2573.255,"VideoOut.Flip.validate":0.229,"VideoOut.Flip.vblank_wait":0.134,"VideoOut.Flip.window_prepare":0.312,"VideoOut.Flip.window_title":13.873,"VideoOut.Readiness":0.453,"VideoOut.Readiness.locks_validate":0.186,"Vulkan.Acquire":2.956,"Vulkan.Acquire.acquire_fence_wait":0.439,"Vulkan.Acquire.acquire_image":1.780,"Vulkan.Acquire.fence_reset":0.552,"Vulkan.Acquire.retired_swapchains":0.109,"Vulkan.Dispatch":108.480,"Vulkan.Dispatch.command_record":46.295,"Vulkan.Dispatch.shader_resources":60.325,"Vulkan.GraphicsPipeline":1.069,"Vulkan.GraphicsPipeline.modules_and_state":1.044,"Vulkan.GraphicsPipelinePrebuild":1.133,"Vulkan.Present":21.094,"Vulkan.Present.command_record_scale":8.642,"Vulkan.Present.pixel_upload":1.257,"Vulkan.Present.queue_submit":10.986,"Vulkan.QueuePresent":87.928,"Vulkan.QueuePresent.queue_present":87.582,"Vulkan.Retire":2444.535,"Vulkan.Retire.dump":1.525,"Vulkan.Retire.wait":2439.084},"top_phases_ms_per_frame":{"Driver.Packet":103.451,"Driver.Packet.memory_wait":47.634,"Driver.DrawFinish":41.332,"Graphics.Draw":39.058,"Driver.Packet.draw":29.139,"Driver.Draw":28.551,"Graphics.Draw.draw_and_resource_release":28.234,"Driver.DrawFinish.shader_compile_and_link":23.469},"owned_draw_counts":{"OwnedDraw.evicted_other":15245},"graphics_track":{"Graphics.Barrier.copy":2362,"Graphics.Barrier.dcc-clear":2534,"Graphics.Barrier.dcc-keys":1086,"Graphics.Barrier.dispatch-lead":1465,"Graphics.Barrier.dispatch-trail":2353,"Graphics.Barrier.draw":27042,"Graphics.Barrier.fill":2198,"Graphics.Barrier.fill-clear":1086,"Graphics.Barrier.input-mirror":1715,"Graphics.Barrier.label-run":54211,"Graphics.Barrier.present-blit":362,"Graphics.Barrier.shadow-publish":362,"Graphics.Barrier.staging-in":1268,"Graphics.Barrier.staging-out":543,"Graphics.Barrier.storage-upload":4,"Graphics.Barrier.storage-writeback":4945,"Graphics.BarrierMerged.dispatch-lead":888,"Graphics.BarrierMerged.fill":1426,"Graphics.BarrierMerged.label-run":623,"Graphics.BarrierMerged.shadow-publish":362,"Graphics.BarrierMerged.staging-in":361,"Graphics.BarrierMerged.staging-out":543,"Graphics.BarrierMerged.storage-writeback":1209,"Graphics.Copy":3706,"Graphics.Copy.bytes":5311063680,"Graphics.RenderPass":14728,"Graphics.RenderPass.Close.command":4490,"Graphics.RenderPass.Close.image":1819,"Graphics.RenderPass.Close.key":1051,"Graphics.RenderPass.Close.label":623,"Graphics.RenderPass.Close.new-batch":6745,"Graphics.RenderPass.Continued":390130},"trace_dropped":false,"trace":"aps5-trace-432fd7799362-9212.json.gz"}trace_digest.pyof the two traces: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)