perf(libkernel): return at once from a zero-timeout semaphore or event flag wait that cannot be satisfied #22073

Merged
nicolasabosch merged 1 commit from upstream-pr/22073 into main 2026-11-17 06:16:36 +00:00
nicolasabosch commented 2026-11-17 03:55:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by nicolasabosch on 2026-11-17T03:55:16Z.


What

sceKernelWaitSema and sceKernelWaitEventFlag with a timeout of 0 now return SCE_KERNEL_ERROR_ETIMEDOUT as soon as the token or pattern check fails. Before, they queued a waiter, read the clock, ran the timed wait and woke the other waiters on the way out, only to time out. The results are the same as the slow path (the timeout stays 0 and the event flag reports its pattern), and the check order, the deleted and single-waiter errors and the token handout are unchanged. The event flag wait's clock reads that only feed the APS5_TRACE_WAITS trace now run only when it is set.

Overlap: #22055 makes sceKernelWaitEventFlag write its result pattern and timeout through checked guest copies, in the same lines as this early return. If #22055 merges first, this PR will be rebased and its early return will report the pattern through the same checked write (ReportPattern). If this one merges first, #22055 needs to cover the early return too. #10558 adds test cases next to this PR's in GuestSemaphore.cpp; that conflict is textual.

Tested

Windows 11, MinGW (GCC, Release), no title. ctest -R '^(guest_semaphore|guest_semaphore_trace|guest_semaphore_handoff|guest_kernel_errors|guest_event_flag_wake|guest_event_flag_released_waiter|guest_wait_trace)$' passed (7/7); guest_semaphore and guest_kernel_errors gained cases for a zero timeout that is satisfied, that times out with and without another waiter queued, and that is followed by a signal.

Performance: two 60 s captures each with APS5_TRACE_SECONDS=660:60, same machine and session (NVIDIA GeForce RTX 4070 Laptop GPU, driver 616.92, Intel Core i9-14900HX, Windows 11 Pro 26300), warm shader caches, in the same scripted scene of EA SPORTS UFC 6 (PPSA23566, 01.004.000): the first practice fight of the tutorial ("LAND 5 PUNCHES"), reached through the menus with APS5_PAD_SCRIPT. Both builds are main 2a8a0d1fc3 plus the pad-script commit of #22064, which only injects the scripted input; the change adds this commit on top.

run main this change
1 seconds 660:60 from present 11012: 55 presents, frame p50 1004.2 / p90 1086.4 / p99 5716.0 / max 5716.0 ms, GPU busy 288.6 ms per present seconds 660:60 from present 11464: 69 presents, frame p50 861.1 / p90 953.3 / p99 1027.6 / max 1027.6 ms, GPU busy 181.0 ms per present
2 seconds 660:60 from present 11549: 56 presents, frame p50 1071.4 / p90 1128.7 / p99 1215.3 / max 1215.3 ms, GPU busy 327.3 ms per present seconds 660:60 from present 11552: 59 presents, frame p50 1038.4 / p90 1065.9 / p99 1115.4 / max 1115.4 ms, GPU busy 270.8 ms per present

Both runs of the change present more often than both runs of main (59 and 69 against 55 and 56), but the gain varies between runs: +5 % to +25 % presents, p50 frame time -3 % to -14 %. All traces report trace_dropped after the queue-worker event buffer fills; the summary lines are complete. Traces and trace_digest.py outputs: main run 1: trace, digest; main run 2: trace, digest; this change run 1: trace, digest; this change run 2: trace, digest.

aps5-summary.jsonl lines

main, run 1:

{"commit":"241bfd31f250","dirty":false,"env":{"APS5_LAZY_SHADER_PREPARE":"1","APS5_PAD_SCRIPT":"<path>","APS5_TRACE_SECONDS":"660:60"},"gpu":"NVIDIA GeForce RTX 4070 Laptop GPU","driver":"NVIDIA 616.92","os":"Windows 10.0.26300","cpu":"Intel(R) Core(TM) i9-14900HX","cpu_threads":32,"memory_mib":32543,"title_id":"PPSA23566","title":"EA SPORTS™ UFC® 6","content_version":"01.004.000","resolution":"1920x1080","window":{"spec":"seconds 660:60","first_present":11012,"ms":60290.998},"presents":55,"frame_ms":{"p50":1004.223,"p90":1086.447,"p99":5716.009,"max":5716.009},"gpu_busy_ms_per_present":288.557,"worker_busy_pct":{"queue worker 0x0":98.497,"queue worker 0x29":9.422,"queue worker 0x2a":9.638,"queue worker 0x2b":9.261,"queue worker 0x2c":9.156,"queue worker 0x2d":9.287,"queue worker 0x2e":9.069,"queue worker 0x2f":9.205,"queue worker 0x28":14.485},"phase_totals_ms":{"Driver.Completion":1.369,"Driver.Dispatch":46604.504,"Driver.Dispatch.capture_resources":329.533,"Driver.Dispatch.decode_key_device_setup":1032.629,"Driver.Dispatch.lookup_cache":25.702,"Driver.Dispatch.materialize":85.816,"Driver.Dispatch.prepared_invocation":200.01,"Driver.Draw":43300.605,"Driver.Draw.device_setup":176.166,"Driver.Draw.draw_enqueued":39186.962,"Driver.Draw.post_compile_prepare":29.268,"Driver.Draw.prepare":542.715,"Driver.Draw.shader_compile_and_link":3092.764,"Driver.EndSubmission":131.14,"Driver.Packet":107197.022,"Driver.Packet.device_lock":90.675,"Driver.Packet.dispatch":46238.381,"Driver.Packet.draw":43359.308,"Driver.Packet.execute":4144.494,"Driver.Packet.flip_flush":1.678,"Driver.Packet.flush_between_packets":279.296,"Driver.Packet.memory_wait":12276.403,"Driver.Packet.pipeline_drain":135.683,"Driver.Packet.pipeline_prepare":119.436,"Driver.Packet.prepare_memory":147.483,"Driver.Packet.rendering_wait":0.044,"Driver.Present":160.045,"Driver.Present.acquire_image":0.671,"Driver.Present.device_setup":0.036,"Driver.Present.gpu_mutex_wait":0.397,"Driver.Present.inflight_wait":0.152,"Driver.Present.present_display_buffer":6.623,"Driver.Present.queue_present":23.361,"Driver.Present.release_and_callback":0.099,"Driver.Present.render_fence_wait":128.474,"Driver.Present.resize":0.17,"Driver.Present.validate":0.021,"Driver.Suspend":0.007,"GpuMutex.wait.dispatch":579.319,"GpuMutex.wait.draw":34467.577,"GpuMutex.wait.end":193.154,"GpuMutex.wait.fill":0.144,"GpuMutex.wait.flush":8.82,"GpuMutex.wait.hook":87.515,"GpuMutex.wait.indirect":1.69,"GpuMutex.wait.label":257.307,"GpuMutex.wait.other":17.339,"GpuMutex.wait.present":0.275,"GpuMutex.wait.wait":0.082,"Graphics.Draw":8776.731,"Graphics.Draw.draw_and_resource_release":8097.741,"Graphics.Draw.index_upload":349.797,"Graphics.Draw.validate":255.887,"Graphics.Draw.vertex_upload":30.893,"Graphics.DrawWithRecipe":24.054,"Graphics.DrawWithRecipe.draw_and_resource_release":23.52,"Graphics.DrawWithRecipe.index_upload":0.033,"Graphics.DrawWithRecipe.validate":0.247,"Graphics.DrawWithRecipe.vertex_upload":0.164,"Recorder.Reap":480.593,"Recorder.Submit":349.225,"Recorder.Sync":18536.37,"Recorder.WaitSerial":173.32,"Resources.Complete":41250.476,"Resources.Prepare":357.457,"Shader.DrawStage":2721.353,"Shader.DrawStage.capture_resources":1865.394,"Shader.DrawStage.materialize":529.432,"Shader.DrawStage.prepared_invocation":301.8,"Shader.PrepareArtifact":99.091,"Shader.ResolveAbi":11.236,"Shader.ResolveGraphicsAbi":15.284,"Shader.ResolveGraphicsStagesAbi":68.194,"VideoOut.Flip":162.068,"VideoOut.Flip.completion_mutex_wait":0.057,"VideoOut.Flip.config_mutex_wait":0.013,"VideoOut.Flip.frame_limit":0.049,"VideoOut.Flip.notify_game":0.773,"VideoOut.Flip.present":157.94,"VideoOut.Flip.validate":0.1,"VideoOut.Flip.vblank_wait":0.049,"VideoOut.Flip.window_prepare":0.107,"VideoOut.Flip.window_title":2.949,"VideoOut.Readiness":0.111,"VideoOut.Readiness.locks_validate":0.052,"Vulkan.Acquire":0.609,"Vulkan.Acquire.acquire_fence_wait":0.104,"Vulkan.Acquire.acquire_image":0.345,"Vulkan.Acquire.fence_reset":0.118,"Vulkan.Acquire.retired_swapchains":0.023,"Vulkan.ComputePipeline":1178.179,"Vulkan.Dispatch":41751.997,"Vulkan.Dispatch.command_record":302.137,"Vulkan.Dispatch.shader_resources":41440.951,"Vulkan.DispatchRecipe":49.353,"Vulkan.DispatchRecipe.command_record":49.075,"Vulkan.DrawFromRecipe":24.222,"Vulkan.GraphicsPipeline":3884.937,"Vulkan.GraphicsPipeline.create":3720.114,"Vulkan.GraphicsPipeline.modules_and_state":5.692,"Vulkan.GraphicsPipelineLibrary":3699.446,"Vulkan.GraphicsPipelineLink":0.068,"Vulkan.GraphicsPipelinePrebuild":160.695,"Vulkan.Present":5.044,"Vulkan.Present.command_record_scale":1.813,"Vulkan.Present.pixel_upload":0.189,"Vulkan.Present.queue_submit":3.0,"Vulkan.QueuePresent":23.274,"Vulkan.QueuePresent.queue_present":23.187,"Vulkan.Retire":128.451,"Vulkan.Retire.wait":127.082},"top_phases_ms_per_frame":{"Driver.Packet":1949.037,"Driver.Dispatch":847.355,"Driver.Packet.dispatch":840.698,"Driver.Packet.draw":788.351,"Driver.Draw":787.284,"Vulkan.Dispatch":759.127,"Vulkan.Dispatch.shader_resources":753.472,"Resources.Complete":750.009},"owned_draw_counts":{},"graphics_track":{"Graphics.Barrier.copy":275,"Graphics.Barrier.dispatch-lead":37292,"Graphics.Barrier.dispatch-trail":41021,"Graphics.Barrier.draw":63780,"Graphics.Barrier.fill":1370,"Graphics.Barrier.indirect-args":5775,"Graphics.Barrier.input-mirror":12722,"Graphics.Barrier.label-run":31300,"Graphics.Barrier.present-blit":110,"Graphics.Barrier.shadow-publish":2684,"Graphics.Barrier.staging-in":19227,"Graphics.Barrier.staging-out":10104,"Graphics.Barrier.storage-upload":6220,"Graphics.Barrier.storage-writeback":15193,"Graphics.Barrier.template-refresh":112,"Graphics.BarrierMerged.dispatch-lead":15279,"Graphics.BarrierMerged.fill":280,"Graphics.BarrierMerged.label-run":46,"Graphics.BarrierMerged.shadow-publish":2598,"Graphics.BarrierMerged.staging-in":12750,"Graphics.BarrierMerged.staging-out":10104,"Graphics.BarrierMerged.storage-writeback":5707,"Graphics.Copy":49189,"Graphics.Copy.bytes":4693849204,"Graphics.RenderPass":29821,"Graphics.RenderPass.Close.command":24136,"Graphics.RenderPass.Close.image":207,"Graphics.RenderPass.Close.key":694,"Graphics.RenderPass.Close.label":46,"Graphics.RenderPass.Close.new-batch":4738,"Graphics.RenderPass.Continued":214387},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":43.573,"events_lost":105056,"totals_full":false}},"trace":"aps5-trace-241bfd31f250-56360.json.gz"}

main, run 2:

{"commit":"241bfd31f250","dirty":false,"env":{"APS5_LAZY_SHADER_PREPARE":"1","APS5_PAD_SCRIPT":"<path>","APS5_TRACE_SECONDS":"660:60"},"gpu":"NVIDIA GeForce RTX 4070 Laptop GPU","driver":"NVIDIA 616.92","os":"Windows 10.0.26300","cpu":"Intel(R) Core(TM) i9-14900HX","cpu_threads":32,"memory_mib":32543,"title_id":"PPSA23566","title":"EA SPORTS™ UFC® 6","content_version":"01.004.000","resolution":"1920x1080","window":{"spec":"seconds 660:60","first_present":11549,"ms":60446.666},"presents":56,"frame_ms":{"p50":1071.428,"p90":1128.656,"p99":1215.329,"max":1215.329},"gpu_busy_ms_per_present":327.303,"worker_busy_pct":{"queue worker 0x0":98.838,"queue worker 0x29":10.061,"queue worker 0x2a":10.065,"queue worker 0x2b":10.114,"queue worker 0x2c":9.996,"queue worker 0x2d":10.039,"queue worker 0x2e":9.9,"queue worker 0x2f":10.14,"queue worker 0x28":10.084},"phase_totals_ms":{"Driver.Completion":1.298,"Driver.Dispatch":48780.542,"Driver.Dispatch.capture_resources":339.22,"Driver.Dispatch.decode_key_device_setup":459.251,"Driver.Dispatch.lookup_cache":23.774,"Driver.Dispatch.materialize":67.518,"Driver.Dispatch.prepared_invocation":45.503,"Driver.Draw":43692.407,"Driver.Draw.device_setup":184.254,"Driver.Draw.draw_enqueued":39646.524,"Driver.Draw.post_compile_prepare":31.813,"Driver.Draw.prepare":564.601,"Driver.Draw.shader_compile_and_link":3067.365,"Driver.EndSubmission":271.747,"Driver.Packet":108069.607,"Driver.Packet.device_lock":96.15,"Driver.Packet.dispatch":48685.058,"Driver.Packet.draw":43755.579,"Driver.Packet.execute":5282.314,"Driver.Packet.flip_flush":1.498,"Driver.Packet.flush_between_packets":401.828,"Driver.Packet.memory_wait":8756.662,"Driver.Packet.pipeline_drain":139.236,"Driver.Packet.pipeline_prepare":125.261,"Driver.Packet.prepare_memory":154.655,"Driver.Packet.rendering_wait":0.073,"Driver.Present":88.052,"Driver.Present.acquire_image":0.682,"Driver.Present.device_setup":0.029,"Driver.Present.gpu_mutex_wait":0.262,"Driver.Present.inflight_wait":0.145,"Driver.Present.present_display_buffer":6.721,"Driver.Present.queue_present":21.966,"Driver.Present.release_and_callback":0.09,"Driver.Present.render_fence_wait":57.899,"Driver.Present.resize":0.201,"Driver.Present.validate":0.019,"Driver.Suspend":0.007,"GpuMutex.wait.dispatch":456.95,"GpuMutex.wait.draw":38697.845,"GpuMutex.wait.end":43.618,"GpuMutex.wait.fill":0.301,"GpuMutex.wait.flush":5.704,"GpuMutex.wait.hook":99.141,"GpuMutex.wait.indirect":0.814,"GpuMutex.wait.label":28.666,"GpuMutex.wait.other":3.469,"GpuMutex.wait.present":0.147,"GpuMutex.wait.wait":0.123,"Graphics.Draw":5224.234,"Graphics.Draw.draw_and_resource_release":4538.586,"Graphics.Draw.index_upload":341.624,"Graphics.Draw.validate":265.676,"Graphics.Draw.vertex_upload":32.799,"Graphics.DrawWithRecipe":70.919,"Graphics.DrawWithRecipe.draw_and_resource_release":70.639,"Graphics.DrawWithRecipe.index_upload":0.021,"Graphics.DrawWithRecipe.validate":0.116,"Graphics.DrawWithRecipe.vertex_upload":0.088,"Recorder.Reap":765.567,"Recorder.Submit":358.078,"Recorder.Sync":20123.129,"Recorder.WaitSerial":0.642,"Resources.Complete":45454.32,"Resources.Prepare":847.292,"Shader.DrawStage":2673.691,"Shader.DrawStage.capture_resources":1995.548,"Shader.DrawStage.materialize":397.375,"Shader.DrawStage.prepared_invocation":254.682,"Shader.ResolveAbi":10.771,"Shader.ResolveGraphicsAbi":15.591,"Shader.ResolveGraphicsStagesAbi":22.252,"VideoOut.Flip":90.253,"VideoOut.Flip.completion_mutex_wait":0.063,"VideoOut.Flip.config_mutex_wait":0.01,"VideoOut.Flip.frame_limit":0.04,"VideoOut.Flip.notify_game":0.753,"VideoOut.Flip.present":86.126,"VideoOut.Flip.validate":0.084,"VideoOut.Flip.vblank_wait":0.041,"VideoOut.Flip.window_prepare":0.098,"VideoOut.Flip.window_title":3.016,"VideoOut.Readiness":0.119,"VideoOut.Readiness.locks_validate":0.048,"Vulkan.Acquire":0.62,"Vulkan.Acquire.acquire_fence_wait":0.108,"Vulkan.Acquire.acquire_image":0.353,"Vulkan.Acquire.fence_reset":0.11,"Vulkan.Acquire.retired_swapchains":0.028,"Vulkan.Dispatch":45818.514,"Vulkan.Dispatch.command_record":317.303,"Vulkan.Dispatch.shader_resources":45491.92,"Vulkan.DispatchRecipe":91.948,"Vulkan.DispatchRecipe.command_record":91.664,"Vulkan.DrawFromRecipe":71.034,"Vulkan.Present":5.105,"Vulkan.Present.command_record_scale":1.836,"Vulkan.Present.pixel_upload":0.249,"Vulkan.Present.queue_submit":2.978,"Vulkan.QueuePresent":21.887,"Vulkan.QueuePresent.queue_present":21.805,"Vulkan.Retire":57.884,"Vulkan.Retire.wait":56.578},"top_phases_ms_per_frame":{"Driver.Packet":1929.814,"Driver.Dispatch":871.081,"Driver.Packet.dispatch":869.376,"Vulkan.Dispatch":818.188,"Vulkan.Dispatch.shader_resources":812.356,"Resources.Complete":811.684,"Driver.Packet.draw":781.35,"Driver.Draw":780.222},"owned_draw_counts":{},"graphics_track":{"Graphics.Barrier.copy":280,"Graphics.Barrier.dispatch-lead":33810,"Graphics.Barrier.dispatch-trail":42873,"Graphics.Barrier.draw":61381,"Graphics.Barrier.fill":1412,"Graphics.Barrier.indirect-args":6216,"Graphics.Barrier.input-mirror":9701,"Graphics.Barrier.label-run":25377,"Graphics.Barrier.present-blit":112,"Graphics.Barrier.shadow-publish":1315,"Graphics.Barrier.staging-in":20926,"Graphics.Barrier.staging-out":12242,"Graphics.Barrier.storage-upload":6774,"Graphics.Barrier.storage-writeback":12884,"Graphics.Barrier.template-refresh":135,"Graphics.BarrierMerged.dispatch-lead":21495,"Graphics.BarrierMerged.fill":268,"Graphics.BarrierMerged.label-run":111,"Graphics.BarrierMerged.shadow-publish":1255,"Graphics.BarrierMerged.staging-in":17983,"Graphics.BarrierMerged.staging-out":12242,"Graphics.BarrierMerged.storage-writeback":4826,"Graphics.Copy":64227,"Graphics.Copy.bytes":3555827091,"Graphics.RenderPass":28447,"Graphics.RenderPass.Close.command":22473,"Graphics.RenderPass.Close.image":160,"Graphics.RenderPass.Close.key":710,"Graphics.RenderPass.Close.label":111,"Graphics.RenderPass.Close.new-batch":4993,"Graphics.RenderPass.Continued":230913},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":40.285,"events_lost":127515,"totals_full":false}},"trace":"aps5-trace-241bfd31f250-49796.json.gz"}

this change, run 1:

{"commit":"07b55f7074c6","dirty":false,"env":{"APS5_LAZY_SHADER_PREPARE":"1","APS5_PAD_SCRIPT":"<path>","APS5_TRACE_SECONDS":"660:60"},"gpu":"NVIDIA GeForce RTX 4070 Laptop GPU","driver":"NVIDIA 616.92","os":"Windows 10.0.26300","cpu":"Intel(R) Core(TM) i9-14900HX","cpu_threads":32,"memory_mib":32543,"title_id":"PPSA23566","title":"EA SPORTS™ UFC® 6","content_version":"01.004.000","resolution":"1920x1080","window":{"spec":"seconds 660:60","first_present":11464,"ms":60559.193},"presents":69,"frame_ms":{"p50":861.104,"p90":953.278,"p99":1027.613,"max":1027.613},"gpu_busy_ms_per_present":181.008,"worker_busy_pct":{"queue worker 0x0":98.338,"queue worker 0x29":10.761,"queue worker 0x2a":10.991,"queue worker 0x2b":10.788,"queue worker 0x2c":11.088,"queue worker 0x2d":9.401,"queue worker 0x2e":9.729,"queue worker 0x2f":9.649,"queue worker 0x28":10.751},"phase_totals_ms":{"Driver.Completion":1.477,"Driver.Dispatch":49938.394,"Driver.Dispatch.capture_resources":416.881,"Driver.Dispatch.decode_key_device_setup":777.979,"Driver.Dispatch.lookup_cache":30.759,"Driver.Dispatch.materialize":82.837,"Driver.Dispatch.prepared_invocation":55.824,"Driver.Draw":47822.302,"Driver.Draw.device_setup":219.4,"Driver.Draw.draw_enqueued":43027.376,"Driver.Draw.post_compile_prepare":39.366,"Driver.Draw.prepare":639.347,"Driver.Draw.shader_compile_and_link":3678.269,"Driver.EndSubmission":140.487,"Driver.Packet":109770.679,"Driver.Packet.device_lock":114.924,"Driver.Packet.dispatch":49869.272,"Driver.Packet.draw":47896.296,"Driver.Packet.execute":3150.613,"Driver.Packet.flip_flush":1.653,"Driver.Packet.flush_between_packets":403.387,"Driver.Packet.memory_wait":7440.012,"Driver.Packet.pipeline_drain":164.06,"Driver.Packet.pipeline_prepare":150.366,"Driver.Packet.prepare_memory":193.63,"Driver.Packet.rendering_wait":0.075,"Driver.Present":189.711,"Driver.Present.acquire_image":0.941,"Driver.Present.device_setup":0.046,"Driver.Present.gpu_mutex_wait":0.355,"Driver.Present.inflight_wait":0.202,"Driver.Present.present_display_buffer":8.595,"Driver.Present.queue_present":29.139,"Driver.Present.release_and_callback":0.127,"Driver.Present.render_fence_wait":150.079,"Driver.Present.resize":0.144,"Driver.Present.validate":0.029,"Driver.Suspend":0.01,"GpuMutex.wait.dispatch":512.518,"GpuMutex.wait.draw":41266.572,"GpuMutex.wait.end":105.676,"GpuMutex.wait.fill":0.524,"GpuMutex.wait.flush":17.3,"GpuMutex.wait.hook":32.724,"GpuMutex.wait.indirect":2.113,"GpuMutex.wait.label":291.044,"GpuMutex.wait.other":0.421,"GpuMutex.wait.present":0.192,"GpuMutex.wait.wait":0.16,"Graphics.Draw":5823.549,"Graphics.Draw.draw_and_resource_release":5023.658,"Graphics.Draw.index_upload":378.72,"Graphics.Draw.validate":328.768,"Graphics.Draw.vertex_upload":35.173,"Graphics.DrawWithRecipe":51.141,"Graphics.DrawWithRecipe.draw_and_resource_release":50.602,"Graphics.DrawWithRecipe.index_upload":0.037,"Graphics.DrawWithRecipe.validate":0.225,"Graphics.DrawWithRecipe.vertex_upload":0.174,"Recorder.Reap":1071.04,"Recorder.Submit":421.311,"Recorder.Sync":17915.208,"Recorder.WaitSerial":0.766,"Resources.Complete":45675.422,"Resources.Prepare":1007.398,"Shader.DrawStage":3212.067,"Shader.DrawStage.capture_resources":2393.699,"Shader.DrawStage.materialize":485.449,"Shader.DrawStage.prepared_invocation":301.138,"Shader.ResolveAbi":3.402,"Shader.ResolveGraphicsAbi":1.695,"Shader.ResolveGraphicsStagesAbi":11.402,"VideoOut.Flip":194.771,"VideoOut.Flip.completion_mutex_wait":0.076,"VideoOut.Flip.config_mutex_wait":0.016,"VideoOut.Flip.frame_limit":0.057,"VideoOut.Flip.notify_game":1.09,"VideoOut.Flip.present":189.359,"VideoOut.Flip.validate":0.132,"VideoOut.Flip.vblank_wait":0.066,"VideoOut.Flip.window_prepare":0.14,"VideoOut.Flip.window_title":3.807,"VideoOut.Readiness":0.134,"VideoOut.Readiness.locks_validate":0.062,"Vulkan.Acquire":0.85,"Vulkan.Acquire.acquire_fence_wait":0.149,"Vulkan.Acquire.acquire_image":0.476,"Vulkan.Acquire.fence_reset":0.159,"Vulkan.Acquire.retired_swapchains":0.036,"Vulkan.Dispatch":46288.451,"Vulkan.Dispatch.command_record":378.327,"Vulkan.Dispatch.shader_resources":45896.729,"Vulkan.DispatchRecipe":66.985,"Vulkan.DispatchRecipe.command_record":66.702,"Vulkan.DrawFromRecipe":51.334,"Vulkan.Present":6.431,"Vulkan.Present.command_record_scale":2.313,"Vulkan.Present.pixel_upload":0.23,"Vulkan.Present.queue_submit":3.835,"Vulkan.QueuePresent":29.054,"Vulkan.QueuePresent.queue_present":28.939,"Vulkan.Retire":150.055,"Vulkan.Retire.wait":148.391},"top_phases_ms_per_frame":{"Driver.Packet":1590.879,"Driver.Dispatch":723.745,"Driver.Packet.dispatch":722.743,"Driver.Packet.draw":694.149,"Driver.Draw":693.077,"Vulkan.Dispatch":670.847,"Vulkan.Dispatch.shader_resources":665.17,"Resources.Complete":661.963},"owned_draw_counts":{},"graphics_track":{"Graphics.Barrier.copy":345,"Graphics.Barrier.dispatch-lead":42104,"Graphics.Barrier.dispatch-trail":50974,"Graphics.Barrier.draw":61100,"Graphics.Barrier.fill":1732,"Graphics.Barrier.indirect-args":7311,"Graphics.Barrier.input-mirror":7649,"Graphics.Barrier.label-run":29601,"Graphics.Barrier.present-blit":138,"Graphics.Barrier.shadow-publish":1608,"Graphics.Barrier.staging-in":57101,"Graphics.Barrier.staging-out":25674,"Graphics.Barrier.storage-upload":7442,"Graphics.Barrier.storage-writeback":12068,"Graphics.Barrier.template-refresh":145,"Graphics.BarrierMerged.dispatch-lead":23492,"Graphics.BarrierMerged.fill":338,"Graphics.BarrierMerged.label-run":78,"Graphics.BarrierMerged.shadow-publish":1584,"Graphics.BarrierMerged.staging-in":25074,"Graphics.BarrierMerged.staging-out":25674,"Graphics.BarrierMerged.storage-writeback":4741,"Graphics.Copy":101171,"Graphics.Copy.bytes":15574492096,"Graphics.RenderPass":28081,"Graphics.RenderPass.Close.command":20937,"Graphics.RenderPass.Close.image":256,"Graphics.RenderPass.Close.key":906,"Graphics.RenderPass.Close.label":78,"Graphics.RenderPass.Close.new-batch":5904,"Graphics.RenderPass.Continued":287717},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":34.006,"events_lost":203473,"totals_full":false}},"trace":"aps5-trace-07b55f7074c6-26292.json.gz"}

this change, run 2:

{"commit":"07b55f7074c6","dirty":false,"env":{"APS5_LAZY_SHADER_PREPARE":"1","APS5_PAD_SCRIPT":"<path>","APS5_TRACE_SECONDS":"660:60"},"gpu":"NVIDIA GeForce RTX 4070 Laptop GPU","driver":"NVIDIA 616.92","os":"Windows 10.0.26300","cpu":"Intel(R) Core(TM) i9-14900HX","cpu_threads":32,"memory_mib":32543,"title_id":"PPSA23566","title":"EA SPORTS™ UFC® 6","content_version":"01.004.000","resolution":"1920x1080","window":{"spec":"seconds 660:60","first_present":11552,"ms":60463.282},"presents":59,"frame_ms":{"p50":1038.369,"p90":1065.909,"p99":1115.414,"max":1115.414},"gpu_busy_ms_per_present":270.81,"worker_busy_pct":{"queue worker 0x0":99.053,"queue worker 0x29":11.04,"queue worker 0x2a":10.957,"queue worker 0x2b":11.076,"queue worker 0x2c":9.635,"queue worker 0x2d":9.654,"queue worker 0x2e":9.654,"queue worker 0x2f":9.627,"queue worker 0x28":9.59},"phase_totals_ms":{"Driver.Completion":1.903,"Driver.Dispatch":49691.402,"Driver.Dispatch.capture_resources":355.302,"Driver.Dispatch.decode_key_device_setup":731.243,"Driver.Dispatch.lookup_cache":26.38,"Driver.Dispatch.materialize":70.344,"Driver.Dispatch.prepared_invocation":47.345,"Driver.Draw":43907.341,"Driver.Draw.device_setup":196.812,"Driver.Draw.draw_enqueued":39679.66,"Driver.Draw.post_compile_prepare":34.126,"Driver.Draw.prepare":560.43,"Driver.Draw.shader_compile_and_link":3254.551,"Driver.EndSubmission":621.693,"Driver.Packet":108382.186,"Driver.Packet.device_lock":102.478,"Driver.Packet.dispatch":49607.468,"Driver.Packet.draw":43973.405,"Driver.Packet.execute":4294.847,"Driver.Packet.flip_flush":1.632,"Driver.Packet.flush_between_packets":343.99,"Driver.Packet.memory_wait":8289.513,"Driver.Packet.pipeline_drain":146.024,"Driver.Packet.pipeline_prepare":133.116,"Driver.Packet.prepare_memory":164.817,"Driver.Packet.rendering_wait":0.077,"Driver.Present":87.652,"Driver.Present.acquire_image":0.664,"Driver.Present.device_setup":0.03,"Driver.Present.gpu_mutex_wait":0.566,"Driver.Present.inflight_wait":0.129,"Driver.Present.present_display_buffer":7.087,"Driver.Present.queue_present":24.876,"Driver.Present.release_and_callback":0.082,"Driver.Present.render_fence_wait":54.067,"Driver.Present.resize":0.099,"Driver.Present.validate":0.014,"Driver.Suspend":0.006,"GpuMutex.wait.dispatch":508.325,"GpuMutex.wait.draw":39130.797,"GpuMutex.wait.end":289.896,"GpuMutex.wait.fill":0.466,"GpuMutex.wait.flush":6.289,"GpuMutex.wait.hook":6.499,"GpuMutex.wait.indirect":3.747,"GpuMutex.wait.label":278.394,"GpuMutex.wait.other":2.44,"GpuMutex.wait.present":0.463,"GpuMutex.wait.wait":0.106,"Graphics.Draw":5671.401,"Graphics.Draw.draw_and_resource_release":4961.528,"Graphics.Draw.index_upload":346.622,"Graphics.Draw.validate":279.354,"Graphics.Draw.vertex_upload":35.0,"Graphics.DrawWithRecipe":43.753,"Graphics.DrawWithRecipe.draw_and_resource_release":43.405,"Graphics.DrawWithRecipe.index_upload":0.022,"Graphics.DrawWithRecipe.validate":0.151,"Graphics.DrawWithRecipe.vertex_upload":0.112,"Recorder.Reap":741.967,"Recorder.Submit":384.066,"Recorder.Sync":19315.064,"Recorder.WaitSerial":30.498,"Resources.Complete":45855.822,"Resources.Prepare":794.265,"Shader.DrawStage":2837.258,"Shader.DrawStage.capture_resources":2120.701,"Shader.DrawStage.materialize":420.203,"Shader.DrawStage.prepared_invocation":268.486,"Shader.ResolveAbi":10.904,"Shader.ResolveGraphicsAbi":15.282,"Shader.ResolveGraphicsStagesAbi":20.494,"VideoOut.Flip":89.957,"VideoOut.Flip.completion_mutex_wait":0.103,"VideoOut.Flip.config_mutex_wait":0.008,"VideoOut.Flip.frame_limit":0.029,"VideoOut.Flip.notify_game":0.831,"VideoOut.Flip.present":85.752,"VideoOut.Flip.validate":0.061,"VideoOut.Flip.vblank_wait":0.045,"VideoOut.Flip.window_prepare":0.096,"VideoOut.Flip.window_title":3.009,"VideoOut.Readiness":0.115,"VideoOut.Readiness.locks_validate":0.051,"Vulkan.Acquire":0.607,"Vulkan.Acquire.acquire_fence_wait":0.095,"Vulkan.Acquire.acquire_image":0.366,"Vulkan.Acquire.fence_reset":0.104,"Vulkan.Acquire.retired_swapchains":0.023,"Vulkan.Dispatch":46394.477,"Vulkan.Dispatch.command_record":332.756,"Vulkan.Dispatch.shader_resources":46051.66,"Vulkan.DispatchRecipe":78.084,"Vulkan.DispatchRecipe.command_record":77.789,"Vulkan.DrawFromRecipe":43.885,"Vulkan.Present":5.373,"Vulkan.Present.command_record_scale":1.904,"Vulkan.Present.pixel_upload":0.335,"Vulkan.Present.queue_submit":3.094,"Vulkan.QueuePresent":24.797,"Vulkan.QueuePresent.queue_present":24.7,"Vulkan.Retire":54.041,"Vulkan.Retire.wait":52.812},"top_phases_ms_per_frame":{"Driver.Packet":1836.986,"Driver.Dispatch":842.227,"Driver.Packet.dispatch":840.805,"Vulkan.Dispatch":786.347,"Vulkan.Dispatch.shader_resources":780.537,"Resources.Complete":777.217,"Driver.Packet.draw":745.312,"Driver.Draw":744.192},"owned_draw_counts":{},"graphics_track":{"Graphics.Barrier.copy":590,"Graphics.Barrier.dispatch-lead":39054,"Graphics.Barrier.dispatch-trail":45049,"Graphics.Barrier.draw":58842,"Graphics.Barrier.fill":1422,"Graphics.Barrier.indirect-args":6549,"Graphics.Barrier.input-mirror":7406,"Graphics.Barrier.label-run":27968,"Graphics.Barrier.present-blit":118,"Graphics.Barrier.shadow-publish":1453,"Graphics.Barrier.staging-in":28027,"Graphics.Barrier.staging-out":14128,"Graphics.Barrier.storage-upload":7558,"Graphics.Barrier.storage-writeback":13870,"Graphics.Barrier.template-refresh":139,"Graphics.BarrierMerged.dispatch-lead":19093,"Graphics.BarrierMerged.fill":236,"Graphics.BarrierMerged.label-run":63,"Graphics.BarrierMerged.shadow-publish":1433,"Graphics.BarrierMerged.staging-in":19398,"Graphics.BarrierMerged.staging-out":14128,"Graphics.BarrierMerged.storage-writeback":5179,"Graphics.Copy":61096,"Graphics.Copy.bytes":5253844390,"Graphics.RenderPass":27195,"Graphics.RenderPass.Close.command":20775,"Graphics.RenderPass.Close.image":169,"Graphics.RenderPass.Close.key":886,"Graphics.RenderPass.Close.label":63,"Graphics.RenderPass.Close.new-batch":5302,"Graphics.RenderPass.Continued":250675},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":37.747,"events_lost":142340,"totals_full":false}},"trace":"aps5-trace-07b55f7074c6-44244.json.gz"}

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: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5350292744 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22073). Originally posted by [nicolasabosch](https://github.com/nicolasabosch) on 2026-11-17T03:55:16Z. --- ### What `sceKernelWaitSema` and `sceKernelWaitEventFlag` with a timeout of 0 now return `SCE_KERNEL_ERROR_ETIMEDOUT` as soon as the token or pattern check fails. Before, they queued a waiter, read the clock, ran the timed wait and woke the other waiters on the way out, only to time out. The results are the same as the slow path (the timeout stays 0 and the event flag reports its pattern), and the check order, the deleted and single-waiter errors and the token handout are unchanged. The event flag wait's clock reads that only feed the `APS5_TRACE_WAITS` trace now run only when it is set. Overlap: #22055 makes `sceKernelWaitEventFlag` write its result pattern and timeout through checked guest copies, in the same lines as this early return. If #22055 merges first, this PR will be rebased and its early return will report the pattern through the same checked write (`ReportPattern`). If this one merges first, #22055 needs to cover the early return too. #10558 adds test cases next to this PR's in `GuestSemaphore.cpp`; that conflict is textual. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows 11, MinGW (GCC, Release), no title. `ctest -R '^(guest_semaphore|guest_semaphore_trace|guest_semaphore_handoff|guest_kernel_errors|guest_event_flag_wake|guest_event_flag_released_waiter|guest_wait_trace)$'` passed (7/7); `guest_semaphore` and `guest_kernel_errors` gained cases for a zero timeout that is satisfied, that times out with and without another waiter queued, and that is followed by a signal. Performance: two 60 s captures each with `APS5_TRACE_SECONDS=660:60`, same machine and session (NVIDIA GeForce RTX 4070 Laptop GPU, driver 616.92, Intel Core i9-14900HX, Windows 11 Pro 26300), warm shader caches, in the same scripted scene of EA SPORTS UFC 6 (PPSA23566, 01.004.000): the first practice fight of the tutorial ("LAND 5 PUNCHES"), reached through the menus with `APS5_PAD_SCRIPT`. Both builds are `main` 2a8a0d1fc33 plus the pad-script commit of #22064, which only injects the scripted input; the change adds this commit on top. | run | `main` | this change | | --- | --- | --- | | 1 | `seconds 660:60 from present 11012: 55 presents, frame p50 1004.2 / p90 1086.4 / p99 5716.0 / max 5716.0 ms, GPU busy 288.6 ms per present` | `seconds 660:60 from present 11464: 69 presents, frame p50 861.1 / p90 953.3 / p99 1027.6 / max 1027.6 ms, GPU busy 181.0 ms per present` | | 2 | `seconds 660:60 from present 11549: 56 presents, frame p50 1071.4 / p90 1128.7 / p99 1215.3 / max 1215.3 ms, GPU busy 327.3 ms per present` | `seconds 660:60 from present 11552: 59 presents, frame p50 1038.4 / p90 1065.9 / p99 1115.4 / max 1115.4 ms, GPU busy 270.8 ms per present` | Both runs of the change present more often than both runs of `main` (59 and 69 against 55 and 56), but the gain varies between runs: +5 % to +25 % presents, p50 frame time -3 % to -14 %. All traces report `trace_dropped` after the queue-worker event buffer fills; the summary lines are complete. Traces and `trace_digest.py` outputs: `main` run 1: [trace](https://github.com/nicolasabosch/AnyPS5/releases/download/perf-traces-2026-11-17/main-m1.json.gz), [digest](https://github.com/nicolasabosch/AnyPS5/releases/download/perf-traces-2026-11-17/main-m1.digest.md); `main` run 2: [trace](https://github.com/nicolasabosch/AnyPS5/releases/download/perf-traces-2026-11-17/main-m2.json.gz), [digest](https://github.com/nicolasabosch/AnyPS5/releases/download/perf-traces-2026-11-17/main-m2.digest.md); this change run 1: [trace](https://github.com/nicolasabosch/AnyPS5/releases/download/perf-traces-2026-11-17/libkernel-zero-timeout-wait-m1.json.gz), [digest](https://github.com/nicolasabosch/AnyPS5/releases/download/perf-traces-2026-11-17/libkernel-zero-timeout-wait-m1.digest.md); this change run 2: [trace](https://github.com/nicolasabosch/AnyPS5/releases/download/perf-traces-2026-11-17/libkernel-zero-timeout-wait-m2.json.gz), [digest](https://github.com/nicolasabosch/AnyPS5/releases/download/perf-traces-2026-11-17/libkernel-zero-timeout-wait-m2.digest.md). <details><summary><code>aps5-summary.jsonl</code> lines</summary> main, run 1: ```json {"commit":"241bfd31f250","dirty":false,"env":{"APS5_LAZY_SHADER_PREPARE":"1","APS5_PAD_SCRIPT":"<path>","APS5_TRACE_SECONDS":"660:60"},"gpu":"NVIDIA GeForce RTX 4070 Laptop GPU","driver":"NVIDIA 616.92","os":"Windows 10.0.26300","cpu":"Intel(R) Core(TM) i9-14900HX","cpu_threads":32,"memory_mib":32543,"title_id":"PPSA23566","title":"EA SPORTS™ UFC® 6","content_version":"01.004.000","resolution":"1920x1080","window":{"spec":"seconds 660:60","first_present":11012,"ms":60290.998},"presents":55,"frame_ms":{"p50":1004.223,"p90":1086.447,"p99":5716.009,"max":5716.009},"gpu_busy_ms_per_present":288.557,"worker_busy_pct":{"queue worker 0x0":98.497,"queue worker 0x29":9.422,"queue worker 0x2a":9.638,"queue worker 0x2b":9.261,"queue worker 0x2c":9.156,"queue worker 0x2d":9.287,"queue worker 0x2e":9.069,"queue worker 0x2f":9.205,"queue worker 0x28":14.485},"phase_totals_ms":{"Driver.Completion":1.369,"Driver.Dispatch":46604.504,"Driver.Dispatch.capture_resources":329.533,"Driver.Dispatch.decode_key_device_setup":1032.629,"Driver.Dispatch.lookup_cache":25.702,"Driver.Dispatch.materialize":85.816,"Driver.Dispatch.prepared_invocation":200.01,"Driver.Draw":43300.605,"Driver.Draw.device_setup":176.166,"Driver.Draw.draw_enqueued":39186.962,"Driver.Draw.post_compile_prepare":29.268,"Driver.Draw.prepare":542.715,"Driver.Draw.shader_compile_and_link":3092.764,"Driver.EndSubmission":131.14,"Driver.Packet":107197.022,"Driver.Packet.device_lock":90.675,"Driver.Packet.dispatch":46238.381,"Driver.Packet.draw":43359.308,"Driver.Packet.execute":4144.494,"Driver.Packet.flip_flush":1.678,"Driver.Packet.flush_between_packets":279.296,"Driver.Packet.memory_wait":12276.403,"Driver.Packet.pipeline_drain":135.683,"Driver.Packet.pipeline_prepare":119.436,"Driver.Packet.prepare_memory":147.483,"Driver.Packet.rendering_wait":0.044,"Driver.Present":160.045,"Driver.Present.acquire_image":0.671,"Driver.Present.device_setup":0.036,"Driver.Present.gpu_mutex_wait":0.397,"Driver.Present.inflight_wait":0.152,"Driver.Present.present_display_buffer":6.623,"Driver.Present.queue_present":23.361,"Driver.Present.release_and_callback":0.099,"Driver.Present.render_fence_wait":128.474,"Driver.Present.resize":0.17,"Driver.Present.validate":0.021,"Driver.Suspend":0.007,"GpuMutex.wait.dispatch":579.319,"GpuMutex.wait.draw":34467.577,"GpuMutex.wait.end":193.154,"GpuMutex.wait.fill":0.144,"GpuMutex.wait.flush":8.82,"GpuMutex.wait.hook":87.515,"GpuMutex.wait.indirect":1.69,"GpuMutex.wait.label":257.307,"GpuMutex.wait.other":17.339,"GpuMutex.wait.present":0.275,"GpuMutex.wait.wait":0.082,"Graphics.Draw":8776.731,"Graphics.Draw.draw_and_resource_release":8097.741,"Graphics.Draw.index_upload":349.797,"Graphics.Draw.validate":255.887,"Graphics.Draw.vertex_upload":30.893,"Graphics.DrawWithRecipe":24.054,"Graphics.DrawWithRecipe.draw_and_resource_release":23.52,"Graphics.DrawWithRecipe.index_upload":0.033,"Graphics.DrawWithRecipe.validate":0.247,"Graphics.DrawWithRecipe.vertex_upload":0.164,"Recorder.Reap":480.593,"Recorder.Submit":349.225,"Recorder.Sync":18536.37,"Recorder.WaitSerial":173.32,"Resources.Complete":41250.476,"Resources.Prepare":357.457,"Shader.DrawStage":2721.353,"Shader.DrawStage.capture_resources":1865.394,"Shader.DrawStage.materialize":529.432,"Shader.DrawStage.prepared_invocation":301.8,"Shader.PrepareArtifact":99.091,"Shader.ResolveAbi":11.236,"Shader.ResolveGraphicsAbi":15.284,"Shader.ResolveGraphicsStagesAbi":68.194,"VideoOut.Flip":162.068,"VideoOut.Flip.completion_mutex_wait":0.057,"VideoOut.Flip.config_mutex_wait":0.013,"VideoOut.Flip.frame_limit":0.049,"VideoOut.Flip.notify_game":0.773,"VideoOut.Flip.present":157.94,"VideoOut.Flip.validate":0.1,"VideoOut.Flip.vblank_wait":0.049,"VideoOut.Flip.window_prepare":0.107,"VideoOut.Flip.window_title":2.949,"VideoOut.Readiness":0.111,"VideoOut.Readiness.locks_validate":0.052,"Vulkan.Acquire":0.609,"Vulkan.Acquire.acquire_fence_wait":0.104,"Vulkan.Acquire.acquire_image":0.345,"Vulkan.Acquire.fence_reset":0.118,"Vulkan.Acquire.retired_swapchains":0.023,"Vulkan.ComputePipeline":1178.179,"Vulkan.Dispatch":41751.997,"Vulkan.Dispatch.command_record":302.137,"Vulkan.Dispatch.shader_resources":41440.951,"Vulkan.DispatchRecipe":49.353,"Vulkan.DispatchRecipe.command_record":49.075,"Vulkan.DrawFromRecipe":24.222,"Vulkan.GraphicsPipeline":3884.937,"Vulkan.GraphicsPipeline.create":3720.114,"Vulkan.GraphicsPipeline.modules_and_state":5.692,"Vulkan.GraphicsPipelineLibrary":3699.446,"Vulkan.GraphicsPipelineLink":0.068,"Vulkan.GraphicsPipelinePrebuild":160.695,"Vulkan.Present":5.044,"Vulkan.Present.command_record_scale":1.813,"Vulkan.Present.pixel_upload":0.189,"Vulkan.Present.queue_submit":3.0,"Vulkan.QueuePresent":23.274,"Vulkan.QueuePresent.queue_present":23.187,"Vulkan.Retire":128.451,"Vulkan.Retire.wait":127.082},"top_phases_ms_per_frame":{"Driver.Packet":1949.037,"Driver.Dispatch":847.355,"Driver.Packet.dispatch":840.698,"Driver.Packet.draw":788.351,"Driver.Draw":787.284,"Vulkan.Dispatch":759.127,"Vulkan.Dispatch.shader_resources":753.472,"Resources.Complete":750.009},"owned_draw_counts":{},"graphics_track":{"Graphics.Barrier.copy":275,"Graphics.Barrier.dispatch-lead":37292,"Graphics.Barrier.dispatch-trail":41021,"Graphics.Barrier.draw":63780,"Graphics.Barrier.fill":1370,"Graphics.Barrier.indirect-args":5775,"Graphics.Barrier.input-mirror":12722,"Graphics.Barrier.label-run":31300,"Graphics.Barrier.present-blit":110,"Graphics.Barrier.shadow-publish":2684,"Graphics.Barrier.staging-in":19227,"Graphics.Barrier.staging-out":10104,"Graphics.Barrier.storage-upload":6220,"Graphics.Barrier.storage-writeback":15193,"Graphics.Barrier.template-refresh":112,"Graphics.BarrierMerged.dispatch-lead":15279,"Graphics.BarrierMerged.fill":280,"Graphics.BarrierMerged.label-run":46,"Graphics.BarrierMerged.shadow-publish":2598,"Graphics.BarrierMerged.staging-in":12750,"Graphics.BarrierMerged.staging-out":10104,"Graphics.BarrierMerged.storage-writeback":5707,"Graphics.Copy":49189,"Graphics.Copy.bytes":4693849204,"Graphics.RenderPass":29821,"Graphics.RenderPass.Close.command":24136,"Graphics.RenderPass.Close.image":207,"Graphics.RenderPass.Close.key":694,"Graphics.RenderPass.Close.label":46,"Graphics.RenderPass.Close.new-batch":4738,"Graphics.RenderPass.Continued":214387},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":43.573,"events_lost":105056,"totals_full":false}},"trace":"aps5-trace-241bfd31f250-56360.json.gz"} ``` main, run 2: ```json {"commit":"241bfd31f250","dirty":false,"env":{"APS5_LAZY_SHADER_PREPARE":"1","APS5_PAD_SCRIPT":"<path>","APS5_TRACE_SECONDS":"660:60"},"gpu":"NVIDIA GeForce RTX 4070 Laptop GPU","driver":"NVIDIA 616.92","os":"Windows 10.0.26300","cpu":"Intel(R) Core(TM) i9-14900HX","cpu_threads":32,"memory_mib":32543,"title_id":"PPSA23566","title":"EA SPORTS™ UFC® 6","content_version":"01.004.000","resolution":"1920x1080","window":{"spec":"seconds 660:60","first_present":11549,"ms":60446.666},"presents":56,"frame_ms":{"p50":1071.428,"p90":1128.656,"p99":1215.329,"max":1215.329},"gpu_busy_ms_per_present":327.303,"worker_busy_pct":{"queue worker 0x0":98.838,"queue worker 0x29":10.061,"queue worker 0x2a":10.065,"queue worker 0x2b":10.114,"queue worker 0x2c":9.996,"queue worker 0x2d":10.039,"queue worker 0x2e":9.9,"queue worker 0x2f":10.14,"queue worker 0x28":10.084},"phase_totals_ms":{"Driver.Completion":1.298,"Driver.Dispatch":48780.542,"Driver.Dispatch.capture_resources":339.22,"Driver.Dispatch.decode_key_device_setup":459.251,"Driver.Dispatch.lookup_cache":23.774,"Driver.Dispatch.materialize":67.518,"Driver.Dispatch.prepared_invocation":45.503,"Driver.Draw":43692.407,"Driver.Draw.device_setup":184.254,"Driver.Draw.draw_enqueued":39646.524,"Driver.Draw.post_compile_prepare":31.813,"Driver.Draw.prepare":564.601,"Driver.Draw.shader_compile_and_link":3067.365,"Driver.EndSubmission":271.747,"Driver.Packet":108069.607,"Driver.Packet.device_lock":96.15,"Driver.Packet.dispatch":48685.058,"Driver.Packet.draw":43755.579,"Driver.Packet.execute":5282.314,"Driver.Packet.flip_flush":1.498,"Driver.Packet.flush_between_packets":401.828,"Driver.Packet.memory_wait":8756.662,"Driver.Packet.pipeline_drain":139.236,"Driver.Packet.pipeline_prepare":125.261,"Driver.Packet.prepare_memory":154.655,"Driver.Packet.rendering_wait":0.073,"Driver.Present":88.052,"Driver.Present.acquire_image":0.682,"Driver.Present.device_setup":0.029,"Driver.Present.gpu_mutex_wait":0.262,"Driver.Present.inflight_wait":0.145,"Driver.Present.present_display_buffer":6.721,"Driver.Present.queue_present":21.966,"Driver.Present.release_and_callback":0.09,"Driver.Present.render_fence_wait":57.899,"Driver.Present.resize":0.201,"Driver.Present.validate":0.019,"Driver.Suspend":0.007,"GpuMutex.wait.dispatch":456.95,"GpuMutex.wait.draw":38697.845,"GpuMutex.wait.end":43.618,"GpuMutex.wait.fill":0.301,"GpuMutex.wait.flush":5.704,"GpuMutex.wait.hook":99.141,"GpuMutex.wait.indirect":0.814,"GpuMutex.wait.label":28.666,"GpuMutex.wait.other":3.469,"GpuMutex.wait.present":0.147,"GpuMutex.wait.wait":0.123,"Graphics.Draw":5224.234,"Graphics.Draw.draw_and_resource_release":4538.586,"Graphics.Draw.index_upload":341.624,"Graphics.Draw.validate":265.676,"Graphics.Draw.vertex_upload":32.799,"Graphics.DrawWithRecipe":70.919,"Graphics.DrawWithRecipe.draw_and_resource_release":70.639,"Graphics.DrawWithRecipe.index_upload":0.021,"Graphics.DrawWithRecipe.validate":0.116,"Graphics.DrawWithRecipe.vertex_upload":0.088,"Recorder.Reap":765.567,"Recorder.Submit":358.078,"Recorder.Sync":20123.129,"Recorder.WaitSerial":0.642,"Resources.Complete":45454.32,"Resources.Prepare":847.292,"Shader.DrawStage":2673.691,"Shader.DrawStage.capture_resources":1995.548,"Shader.DrawStage.materialize":397.375,"Shader.DrawStage.prepared_invocation":254.682,"Shader.ResolveAbi":10.771,"Shader.ResolveGraphicsAbi":15.591,"Shader.ResolveGraphicsStagesAbi":22.252,"VideoOut.Flip":90.253,"VideoOut.Flip.completion_mutex_wait":0.063,"VideoOut.Flip.config_mutex_wait":0.01,"VideoOut.Flip.frame_limit":0.04,"VideoOut.Flip.notify_game":0.753,"VideoOut.Flip.present":86.126,"VideoOut.Flip.validate":0.084,"VideoOut.Flip.vblank_wait":0.041,"VideoOut.Flip.window_prepare":0.098,"VideoOut.Flip.window_title":3.016,"VideoOut.Readiness":0.119,"VideoOut.Readiness.locks_validate":0.048,"Vulkan.Acquire":0.62,"Vulkan.Acquire.acquire_fence_wait":0.108,"Vulkan.Acquire.acquire_image":0.353,"Vulkan.Acquire.fence_reset":0.11,"Vulkan.Acquire.retired_swapchains":0.028,"Vulkan.Dispatch":45818.514,"Vulkan.Dispatch.command_record":317.303,"Vulkan.Dispatch.shader_resources":45491.92,"Vulkan.DispatchRecipe":91.948,"Vulkan.DispatchRecipe.command_record":91.664,"Vulkan.DrawFromRecipe":71.034,"Vulkan.Present":5.105,"Vulkan.Present.command_record_scale":1.836,"Vulkan.Present.pixel_upload":0.249,"Vulkan.Present.queue_submit":2.978,"Vulkan.QueuePresent":21.887,"Vulkan.QueuePresent.queue_present":21.805,"Vulkan.Retire":57.884,"Vulkan.Retire.wait":56.578},"top_phases_ms_per_frame":{"Driver.Packet":1929.814,"Driver.Dispatch":871.081,"Driver.Packet.dispatch":869.376,"Vulkan.Dispatch":818.188,"Vulkan.Dispatch.shader_resources":812.356,"Resources.Complete":811.684,"Driver.Packet.draw":781.35,"Driver.Draw":780.222},"owned_draw_counts":{},"graphics_track":{"Graphics.Barrier.copy":280,"Graphics.Barrier.dispatch-lead":33810,"Graphics.Barrier.dispatch-trail":42873,"Graphics.Barrier.draw":61381,"Graphics.Barrier.fill":1412,"Graphics.Barrier.indirect-args":6216,"Graphics.Barrier.input-mirror":9701,"Graphics.Barrier.label-run":25377,"Graphics.Barrier.present-blit":112,"Graphics.Barrier.shadow-publish":1315,"Graphics.Barrier.staging-in":20926,"Graphics.Barrier.staging-out":12242,"Graphics.Barrier.storage-upload":6774,"Graphics.Barrier.storage-writeback":12884,"Graphics.Barrier.template-refresh":135,"Graphics.BarrierMerged.dispatch-lead":21495,"Graphics.BarrierMerged.fill":268,"Graphics.BarrierMerged.label-run":111,"Graphics.BarrierMerged.shadow-publish":1255,"Graphics.BarrierMerged.staging-in":17983,"Graphics.BarrierMerged.staging-out":12242,"Graphics.BarrierMerged.storage-writeback":4826,"Graphics.Copy":64227,"Graphics.Copy.bytes":3555827091,"Graphics.RenderPass":28447,"Graphics.RenderPass.Close.command":22473,"Graphics.RenderPass.Close.image":160,"Graphics.RenderPass.Close.key":710,"Graphics.RenderPass.Close.label":111,"Graphics.RenderPass.Close.new-batch":4993,"Graphics.RenderPass.Continued":230913},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":40.285,"events_lost":127515,"totals_full":false}},"trace":"aps5-trace-241bfd31f250-49796.json.gz"} ``` this change, run 1: ```json {"commit":"07b55f7074c6","dirty":false,"env":{"APS5_LAZY_SHADER_PREPARE":"1","APS5_PAD_SCRIPT":"<path>","APS5_TRACE_SECONDS":"660:60"},"gpu":"NVIDIA GeForce RTX 4070 Laptop GPU","driver":"NVIDIA 616.92","os":"Windows 10.0.26300","cpu":"Intel(R) Core(TM) i9-14900HX","cpu_threads":32,"memory_mib":32543,"title_id":"PPSA23566","title":"EA SPORTS™ UFC® 6","content_version":"01.004.000","resolution":"1920x1080","window":{"spec":"seconds 660:60","first_present":11464,"ms":60559.193},"presents":69,"frame_ms":{"p50":861.104,"p90":953.278,"p99":1027.613,"max":1027.613},"gpu_busy_ms_per_present":181.008,"worker_busy_pct":{"queue worker 0x0":98.338,"queue worker 0x29":10.761,"queue worker 0x2a":10.991,"queue worker 0x2b":10.788,"queue worker 0x2c":11.088,"queue worker 0x2d":9.401,"queue worker 0x2e":9.729,"queue worker 0x2f":9.649,"queue worker 0x28":10.751},"phase_totals_ms":{"Driver.Completion":1.477,"Driver.Dispatch":49938.394,"Driver.Dispatch.capture_resources":416.881,"Driver.Dispatch.decode_key_device_setup":777.979,"Driver.Dispatch.lookup_cache":30.759,"Driver.Dispatch.materialize":82.837,"Driver.Dispatch.prepared_invocation":55.824,"Driver.Draw":47822.302,"Driver.Draw.device_setup":219.4,"Driver.Draw.draw_enqueued":43027.376,"Driver.Draw.post_compile_prepare":39.366,"Driver.Draw.prepare":639.347,"Driver.Draw.shader_compile_and_link":3678.269,"Driver.EndSubmission":140.487,"Driver.Packet":109770.679,"Driver.Packet.device_lock":114.924,"Driver.Packet.dispatch":49869.272,"Driver.Packet.draw":47896.296,"Driver.Packet.execute":3150.613,"Driver.Packet.flip_flush":1.653,"Driver.Packet.flush_between_packets":403.387,"Driver.Packet.memory_wait":7440.012,"Driver.Packet.pipeline_drain":164.06,"Driver.Packet.pipeline_prepare":150.366,"Driver.Packet.prepare_memory":193.63,"Driver.Packet.rendering_wait":0.075,"Driver.Present":189.711,"Driver.Present.acquire_image":0.941,"Driver.Present.device_setup":0.046,"Driver.Present.gpu_mutex_wait":0.355,"Driver.Present.inflight_wait":0.202,"Driver.Present.present_display_buffer":8.595,"Driver.Present.queue_present":29.139,"Driver.Present.release_and_callback":0.127,"Driver.Present.render_fence_wait":150.079,"Driver.Present.resize":0.144,"Driver.Present.validate":0.029,"Driver.Suspend":0.01,"GpuMutex.wait.dispatch":512.518,"GpuMutex.wait.draw":41266.572,"GpuMutex.wait.end":105.676,"GpuMutex.wait.fill":0.524,"GpuMutex.wait.flush":17.3,"GpuMutex.wait.hook":32.724,"GpuMutex.wait.indirect":2.113,"GpuMutex.wait.label":291.044,"GpuMutex.wait.other":0.421,"GpuMutex.wait.present":0.192,"GpuMutex.wait.wait":0.16,"Graphics.Draw":5823.549,"Graphics.Draw.draw_and_resource_release":5023.658,"Graphics.Draw.index_upload":378.72,"Graphics.Draw.validate":328.768,"Graphics.Draw.vertex_upload":35.173,"Graphics.DrawWithRecipe":51.141,"Graphics.DrawWithRecipe.draw_and_resource_release":50.602,"Graphics.DrawWithRecipe.index_upload":0.037,"Graphics.DrawWithRecipe.validate":0.225,"Graphics.DrawWithRecipe.vertex_upload":0.174,"Recorder.Reap":1071.04,"Recorder.Submit":421.311,"Recorder.Sync":17915.208,"Recorder.WaitSerial":0.766,"Resources.Complete":45675.422,"Resources.Prepare":1007.398,"Shader.DrawStage":3212.067,"Shader.DrawStage.capture_resources":2393.699,"Shader.DrawStage.materialize":485.449,"Shader.DrawStage.prepared_invocation":301.138,"Shader.ResolveAbi":3.402,"Shader.ResolveGraphicsAbi":1.695,"Shader.ResolveGraphicsStagesAbi":11.402,"VideoOut.Flip":194.771,"VideoOut.Flip.completion_mutex_wait":0.076,"VideoOut.Flip.config_mutex_wait":0.016,"VideoOut.Flip.frame_limit":0.057,"VideoOut.Flip.notify_game":1.09,"VideoOut.Flip.present":189.359,"VideoOut.Flip.validate":0.132,"VideoOut.Flip.vblank_wait":0.066,"VideoOut.Flip.window_prepare":0.14,"VideoOut.Flip.window_title":3.807,"VideoOut.Readiness":0.134,"VideoOut.Readiness.locks_validate":0.062,"Vulkan.Acquire":0.85,"Vulkan.Acquire.acquire_fence_wait":0.149,"Vulkan.Acquire.acquire_image":0.476,"Vulkan.Acquire.fence_reset":0.159,"Vulkan.Acquire.retired_swapchains":0.036,"Vulkan.Dispatch":46288.451,"Vulkan.Dispatch.command_record":378.327,"Vulkan.Dispatch.shader_resources":45896.729,"Vulkan.DispatchRecipe":66.985,"Vulkan.DispatchRecipe.command_record":66.702,"Vulkan.DrawFromRecipe":51.334,"Vulkan.Present":6.431,"Vulkan.Present.command_record_scale":2.313,"Vulkan.Present.pixel_upload":0.23,"Vulkan.Present.queue_submit":3.835,"Vulkan.QueuePresent":29.054,"Vulkan.QueuePresent.queue_present":28.939,"Vulkan.Retire":150.055,"Vulkan.Retire.wait":148.391},"top_phases_ms_per_frame":{"Driver.Packet":1590.879,"Driver.Dispatch":723.745,"Driver.Packet.dispatch":722.743,"Driver.Packet.draw":694.149,"Driver.Draw":693.077,"Vulkan.Dispatch":670.847,"Vulkan.Dispatch.shader_resources":665.17,"Resources.Complete":661.963},"owned_draw_counts":{},"graphics_track":{"Graphics.Barrier.copy":345,"Graphics.Barrier.dispatch-lead":42104,"Graphics.Barrier.dispatch-trail":50974,"Graphics.Barrier.draw":61100,"Graphics.Barrier.fill":1732,"Graphics.Barrier.indirect-args":7311,"Graphics.Barrier.input-mirror":7649,"Graphics.Barrier.label-run":29601,"Graphics.Barrier.present-blit":138,"Graphics.Barrier.shadow-publish":1608,"Graphics.Barrier.staging-in":57101,"Graphics.Barrier.staging-out":25674,"Graphics.Barrier.storage-upload":7442,"Graphics.Barrier.storage-writeback":12068,"Graphics.Barrier.template-refresh":145,"Graphics.BarrierMerged.dispatch-lead":23492,"Graphics.BarrierMerged.fill":338,"Graphics.BarrierMerged.label-run":78,"Graphics.BarrierMerged.shadow-publish":1584,"Graphics.BarrierMerged.staging-in":25074,"Graphics.BarrierMerged.staging-out":25674,"Graphics.BarrierMerged.storage-writeback":4741,"Graphics.Copy":101171,"Graphics.Copy.bytes":15574492096,"Graphics.RenderPass":28081,"Graphics.RenderPass.Close.command":20937,"Graphics.RenderPass.Close.image":256,"Graphics.RenderPass.Close.key":906,"Graphics.RenderPass.Close.label":78,"Graphics.RenderPass.Close.new-batch":5904,"Graphics.RenderPass.Continued":287717},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":34.006,"events_lost":203473,"totals_full":false}},"trace":"aps5-trace-07b55f7074c6-26292.json.gz"} ``` this change, run 2: ```json {"commit":"07b55f7074c6","dirty":false,"env":{"APS5_LAZY_SHADER_PREPARE":"1","APS5_PAD_SCRIPT":"<path>","APS5_TRACE_SECONDS":"660:60"},"gpu":"NVIDIA GeForce RTX 4070 Laptop GPU","driver":"NVIDIA 616.92","os":"Windows 10.0.26300","cpu":"Intel(R) Core(TM) i9-14900HX","cpu_threads":32,"memory_mib":32543,"title_id":"PPSA23566","title":"EA SPORTS™ UFC® 6","content_version":"01.004.000","resolution":"1920x1080","window":{"spec":"seconds 660:60","first_present":11552,"ms":60463.282},"presents":59,"frame_ms":{"p50":1038.369,"p90":1065.909,"p99":1115.414,"max":1115.414},"gpu_busy_ms_per_present":270.81,"worker_busy_pct":{"queue worker 0x0":99.053,"queue worker 0x29":11.04,"queue worker 0x2a":10.957,"queue worker 0x2b":11.076,"queue worker 0x2c":9.635,"queue worker 0x2d":9.654,"queue worker 0x2e":9.654,"queue worker 0x2f":9.627,"queue worker 0x28":9.59},"phase_totals_ms":{"Driver.Completion":1.903,"Driver.Dispatch":49691.402,"Driver.Dispatch.capture_resources":355.302,"Driver.Dispatch.decode_key_device_setup":731.243,"Driver.Dispatch.lookup_cache":26.38,"Driver.Dispatch.materialize":70.344,"Driver.Dispatch.prepared_invocation":47.345,"Driver.Draw":43907.341,"Driver.Draw.device_setup":196.812,"Driver.Draw.draw_enqueued":39679.66,"Driver.Draw.post_compile_prepare":34.126,"Driver.Draw.prepare":560.43,"Driver.Draw.shader_compile_and_link":3254.551,"Driver.EndSubmission":621.693,"Driver.Packet":108382.186,"Driver.Packet.device_lock":102.478,"Driver.Packet.dispatch":49607.468,"Driver.Packet.draw":43973.405,"Driver.Packet.execute":4294.847,"Driver.Packet.flip_flush":1.632,"Driver.Packet.flush_between_packets":343.99,"Driver.Packet.memory_wait":8289.513,"Driver.Packet.pipeline_drain":146.024,"Driver.Packet.pipeline_prepare":133.116,"Driver.Packet.prepare_memory":164.817,"Driver.Packet.rendering_wait":0.077,"Driver.Present":87.652,"Driver.Present.acquire_image":0.664,"Driver.Present.device_setup":0.03,"Driver.Present.gpu_mutex_wait":0.566,"Driver.Present.inflight_wait":0.129,"Driver.Present.present_display_buffer":7.087,"Driver.Present.queue_present":24.876,"Driver.Present.release_and_callback":0.082,"Driver.Present.render_fence_wait":54.067,"Driver.Present.resize":0.099,"Driver.Present.validate":0.014,"Driver.Suspend":0.006,"GpuMutex.wait.dispatch":508.325,"GpuMutex.wait.draw":39130.797,"GpuMutex.wait.end":289.896,"GpuMutex.wait.fill":0.466,"GpuMutex.wait.flush":6.289,"GpuMutex.wait.hook":6.499,"GpuMutex.wait.indirect":3.747,"GpuMutex.wait.label":278.394,"GpuMutex.wait.other":2.44,"GpuMutex.wait.present":0.463,"GpuMutex.wait.wait":0.106,"Graphics.Draw":5671.401,"Graphics.Draw.draw_and_resource_release":4961.528,"Graphics.Draw.index_upload":346.622,"Graphics.Draw.validate":279.354,"Graphics.Draw.vertex_upload":35.0,"Graphics.DrawWithRecipe":43.753,"Graphics.DrawWithRecipe.draw_and_resource_release":43.405,"Graphics.DrawWithRecipe.index_upload":0.022,"Graphics.DrawWithRecipe.validate":0.151,"Graphics.DrawWithRecipe.vertex_upload":0.112,"Recorder.Reap":741.967,"Recorder.Submit":384.066,"Recorder.Sync":19315.064,"Recorder.WaitSerial":30.498,"Resources.Complete":45855.822,"Resources.Prepare":794.265,"Shader.DrawStage":2837.258,"Shader.DrawStage.capture_resources":2120.701,"Shader.DrawStage.materialize":420.203,"Shader.DrawStage.prepared_invocation":268.486,"Shader.ResolveAbi":10.904,"Shader.ResolveGraphicsAbi":15.282,"Shader.ResolveGraphicsStagesAbi":20.494,"VideoOut.Flip":89.957,"VideoOut.Flip.completion_mutex_wait":0.103,"VideoOut.Flip.config_mutex_wait":0.008,"VideoOut.Flip.frame_limit":0.029,"VideoOut.Flip.notify_game":0.831,"VideoOut.Flip.present":85.752,"VideoOut.Flip.validate":0.061,"VideoOut.Flip.vblank_wait":0.045,"VideoOut.Flip.window_prepare":0.096,"VideoOut.Flip.window_title":3.009,"VideoOut.Readiness":0.115,"VideoOut.Readiness.locks_validate":0.051,"Vulkan.Acquire":0.607,"Vulkan.Acquire.acquire_fence_wait":0.095,"Vulkan.Acquire.acquire_image":0.366,"Vulkan.Acquire.fence_reset":0.104,"Vulkan.Acquire.retired_swapchains":0.023,"Vulkan.Dispatch":46394.477,"Vulkan.Dispatch.command_record":332.756,"Vulkan.Dispatch.shader_resources":46051.66,"Vulkan.DispatchRecipe":78.084,"Vulkan.DispatchRecipe.command_record":77.789,"Vulkan.DrawFromRecipe":43.885,"Vulkan.Present":5.373,"Vulkan.Present.command_record_scale":1.904,"Vulkan.Present.pixel_upload":0.335,"Vulkan.Present.queue_submit":3.094,"Vulkan.QueuePresent":24.797,"Vulkan.QueuePresent.queue_present":24.7,"Vulkan.Retire":54.041,"Vulkan.Retire.wait":52.812},"top_phases_ms_per_frame":{"Driver.Packet":1836.986,"Driver.Dispatch":842.227,"Driver.Packet.dispatch":840.805,"Vulkan.Dispatch":786.347,"Vulkan.Dispatch.shader_resources":780.537,"Resources.Complete":777.217,"Driver.Packet.draw":745.312,"Driver.Draw":744.192},"owned_draw_counts":{},"graphics_track":{"Graphics.Barrier.copy":590,"Graphics.Barrier.dispatch-lead":39054,"Graphics.Barrier.dispatch-trail":45049,"Graphics.Barrier.draw":58842,"Graphics.Barrier.fill":1422,"Graphics.Barrier.indirect-args":6549,"Graphics.Barrier.input-mirror":7406,"Graphics.Barrier.label-run":27968,"Graphics.Barrier.present-blit":118,"Graphics.Barrier.shadow-publish":1453,"Graphics.Barrier.staging-in":28027,"Graphics.Barrier.staging-out":14128,"Graphics.Barrier.storage-upload":7558,"Graphics.Barrier.storage-writeback":13870,"Graphics.Barrier.template-refresh":139,"Graphics.BarrierMerged.dispatch-lead":19093,"Graphics.BarrierMerged.fill":236,"Graphics.BarrierMerged.label-run":63,"Graphics.BarrierMerged.shadow-publish":1433,"Graphics.BarrierMerged.staging-in":19398,"Graphics.BarrierMerged.staging-out":14128,"Graphics.BarrierMerged.storage-writeback":5179,"Graphics.Copy":61096,"Graphics.Copy.bytes":5253844390,"Graphics.RenderPass":27195,"Graphics.RenderPass.Close.command":20775,"Graphics.RenderPass.Close.image":169,"Graphics.RenderPass.Close.key":886,"Graphics.RenderPass.Close.label":63,"Graphics.RenderPass.Close.new-batch":5302,"Graphics.RenderPass.Continued":250675},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":37.747,"events_lost":142340,"totals_full":false}},"trace":"aps5-trace-07b55f7074c6-44244.json.gz"} ``` </details> ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) 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](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/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: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
PrivacyOnion commented 2026-11-17 03:59:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-17T03:59:25Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 4d059d71b8:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_kernel_error_tests, guest_semaphore_tests built cleanly.
  • CTest (guest_semaphore, guest_kernel_errors):
    1/2 Test #5356: guest_semaphore ..................   Passed    0.03 sec
    2/2 Test #5417: guest_kernel_errors ..............   Passed    0.19 sec
    100% tests passed, 0 tests failed out of 2
    
  • Negative control: with core/libs/prx/libkernel/EventFlag/src/EventFlag.cpp, core/libs/prx/libkernel/Semaphore/src/Semaphore.cpp reverted to main and the new tests kept, the suite fails:
    1/2 Test #5356: guest_semaphore ..................   Passed    0.04 sec
    2/2 Test #5417: guest_kernel_errors ..............   Passed    0.20 sec
    100% tests passed, 0 tests failed out of 2
    
    Restoring the change makes it pass again.
  • Code reading:
    • Verified that sceKernelWaitEventFlag in EventFlag.cpp:358 checks timeout and *timeout == 0 after checking handle validity, bit_pattern != 0, valid wait_mode, deleted state, and single-waiter concurrency, exactly matching the normal wait path prerequisites.
    • Verified that sceKernelWaitEventFlag assigns *result_pat = flag->_pattern on zero-timeout expiration, preserving the current event flag pattern without modifying it or consuming flags when unsatisfied.
    • Verified that sceKernelWaitSema in Semaphore.cpp:123 checks time != nullptr && *time == 0 after checking sem != nullptr, need bounds (0 < need <= sem->maxCount), deleted flag, and immediate token satisfaction (sem->tokenCount >= need).
    • Verified that traceSyncWaitEnd(SCE_KERNEL_ERROR_ETIMEDOUT) and KernelTraceWait_nid_postfix('sema', caller, 0, true) are consistently invoked for tracing on the zero-timeout early exit in sceKernelWaitSema.
    • Verified that zero-timeout calls do not increment waiterCount or register a waiter in the waiter queue/list, preventing unnecessary wakeups and thread contention.
    • Verified that both GuestKernelErrors.cpp and GuestSemaphore.cpp cleanly clean up allocated resources, join threads, and thoroughly test both immediate satisfaction and timeout with/without active queued waiters.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5932573443 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22073#pullrequestreview-5932573443). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-17T03:59:25Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `4d059d71b8`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_kernel_error_tests`, `guest_semaphore_tests` built cleanly. - **CTest** (`guest_semaphore`, `guest_kernel_errors`): ``` 1/2 Test #5356: guest_semaphore .................. Passed 0.03 sec 2/2 Test #5417: guest_kernel_errors .............. Passed 0.19 sec 100% tests passed, 0 tests failed out of 2 ``` - **Negative control**: with `core/libs/prx/libkernel/EventFlag/src/EventFlag.cpp`, `core/libs/prx/libkernel/Semaphore/src/Semaphore.cpp` reverted to `main` and the new tests kept, the suite fails: ``` 1/2 Test #5356: guest_semaphore .................. Passed 0.04 sec 2/2 Test #5417: guest_kernel_errors .............. Passed 0.20 sec 100% tests passed, 0 tests failed out of 2 ``` Restoring the change makes it pass again. - **Code reading**: - Verified that sceKernelWaitEventFlag in EventFlag.cpp:358 checks timeout and *timeout == 0 after checking handle validity, bit_pattern != 0, valid wait_mode, deleted state, and single-waiter concurrency, exactly matching the normal wait path prerequisites. - Verified that sceKernelWaitEventFlag assigns *result_pat = flag->_pattern on zero-timeout expiration, preserving the current event flag pattern without modifying it or consuming flags when unsatisfied. - Verified that sceKernelWaitSema in Semaphore.cpp:123 checks time != nullptr && *time == 0 after checking sem != nullptr, need bounds (0 < need <= sem->maxCount), deleted flag, and immediate token satisfaction (sem->tokenCount >= need). - Verified that traceSyncWaitEnd(SCE_KERNEL_ERROR_ETIMEDOUT) and KernelTraceWait_nid_postfix('sema', caller, 0, true) are consistently invoked for tracing on the zero-timeout early exit in sceKernelWaitSema. - Verified that zero-timeout calls do not increment waiterCount or register a waiter in the waiter queue/list, preventing unnecessary wakeups and thread contention. - Verified that both GuestKernelErrors.cpp and GuestSemaphore.cpp cleanly clean up allocated resources, join threads, and thoroughly test both immediate satisfaction and timeout with/without active queued waiters. Looks Good To Me
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!22073
No description provided.