perf(libkernel): find the next free direct-memory page with memchr #25280

Open
LeandroLP23 wants to merge 1 commit from upstream-pr/25280 into main
LeandroLP23 commented 2026-11-21 20:50:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-11-21T20:50:04Z.


What

  • The direct-memory pool's first-fit search skips a used run by looking for the next free page flag with std::find, one byte per 16 KiB page. SuperTuxKart (PPSA69421) allocates, maps, unmaps and releases about 1000 64 KiB blocks per second during a race, above a used prefix of about 1.4 GiB, so every sceKernelAllocateDirectMemory scans about 92,000 flags under the pool lock.
  • PhysicalMemoryPool::_nextFreePage now finds the flag with memchr and returns the same page (or the search limit when every flag up to it is set). A static_assert pins sizeof(bool) == 1, which the byte scan relies on.
  • MemoryPoolTest gets alloc_past_a_long_used_run: two 1.5 GiB runs around a one-page hole; a two-page request lands after the second run, the hole is found for a one-page request, and a search end inside the runs (or at the end of the second one for a two-page request) returns SCE_KERNEL_ERROR_EAGAIN.
  • tools/pr_overlap.py --branch HEAD: no overlap with open pull requests (#24063 also edits MemoryPool.cpp and merges cleanly).

Tested

Windows 11 (10.0.26300), NVIDIA GeForce RTX 5060 Ti (NVIDIA 621.24), Intel i5-10600K, WinLibs GCC 15.2.0 r7, Release.

  • MemoryPoolTest on main 8763aeffdc (with the new case added) and with this change: 21 of 21 cases pass on both.

  • Time per call, measured with a temporary steady_clock timer around the export (not part of this change) in the same SuperTuxKart race (title_run with a pad timeline, 110 s), two interleaved pairs; this was on a local branch with 1a5c95da66e applied, which main already contains:

    run sceKernelAllocateDirectMemory per call
    std::find 28.9 us
    memchr 10.3 us
    std::find 29.3 us
    memchr 10.5 us

    That is about 0.6 ms per frame of the game thread at about 35 allocations per frame. The frame time does not show it within the run-to-run noise: frame p50 37.9 / 38.4 ms with std::find and 37.7 / 38.9 ms with memchr on that branch.

  • tools/trace_digest.py on real commits, same race, 10 s window 80 s after the first present (APS5_TRACE_SECONDS=80:10), main 8763aeffdc and this branch's head b6de80aed7, alternated twice:

    run presents frame p50 / p99 GPU busy per present
    main 201 49.5 / 55.7 ms 20.4 ms
    this PR 194 49.5 / 78.8 ms 19.9 ms
    main 198 49.9 / 59.6 ms 20.6 ms
    this PR 198 50.4 / 62.4 ms 21.1 ms

    No change in frame time beyond noise; the claim is the time per allocation above. Working set and private bytes are unchanged (3.3 / 5.0 GB).

Summary lines of the first pair:

main (8763aeffdc)
{"commit":"8763aeffdc37","dirty":false,"env":{"APS5_DUMP_FRAMES":"100000","APS5_DUMP_FRAMES_EVERY":"30","APS5_DUMP_SCALE":"8","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_EVENTS":"1048576","APS5_TRACE_SECONDS":"80:10","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 5060 Ti","driver":"NVIDIA 621.24","os":"Windows 10.0.26300","cpu":"Intel(R) Core(TM) i5-10600K CPU @ 4.10GHz","cpu_threads":12,"memory_mib":32685,"title_id":"PPSA69421","title":"SuperTuxKart","content_version":"00.001.000","resolution":"1920x1080","window":{"spec":"seconds 80:10","first_present":1464,"ms":10000.865},"presents":201,"frame_ms":{"p50":49.460,"p90":52.357,"p99":55.684,"max":58.123},"gpu_busy_ms_per_present":20.353,"worker_busy_pct":{"queue worker 0x0":7.146},"phase_totals_ms":{"Driver.Completion":1.397,"Driver.Draw":540.067,"Driver.Draw.device_setup":33.719,"Driver.Draw.draw_enqueued":122.441,"Driver.Draw.post_compile_prepare":7.338,"Driver.Draw.prepare":46.225,"Driver.Draw.shader_compile_and_link":321.126,"Driver.EndSubmission":5.215,"Driver.Packet":707.949,"Driver.Packet.device_lock":9.319,"Driver.Packet.draw":549.728,"Driver.Packet.execute":62.059,"Driver.Packet.flip_flush":0.283,"Driver.Packet.flush_between_packets":15.153,"Driver.Packet.pipeline_drain":13.158,"Driver.Packet.pipeline_prepare":14.092,"Driver.Packet.prepare_memory":14.448,"Driver.Present":104.874,"Driver.Present.acquire_image":2.349,"Driver.Present.device_setup":0.111,"Driver.Present.gpu_mutex_wait":0.411,"Driver.Present.inflight_wait":0.545,"Driver.Present.present_display_buffer":24.971,"Driver.Present.queue_present":72.761,"Driver.Present.release_and_callback":0.251,"Driver.Present.render_fence_wait":2.927,"Driver.Present.resize":0.368,"Driver.Present.validate":0.059,"Driver.Suspend":0.051,"Graphics.Draw":1154.184,"Graphics.Draw.draw_and_resource_release":1097.644,"Graphics.Draw.index_upload":26.064,"Graphics.Draw.validate":23.301,"Graphics.Draw.vertex_upload":2.982,"Graphics.DrawWithRecipe":1060.300,"Graphics.DrawWithRecipe.draw_and_resource_release":1002.265,"Graphics.DrawWithRecipe.index_upload":45.326,"Graphics.DrawWithRecipe.validate":6.705,"Graphics.DrawWithRecipe.vertex_upload":2.945,"Recorder.Reap":0.821,"Recorder.Submit":258.012,"Recorder.Sync":4792.116,"Shader.DrawStage":177.106,"Shader.DrawStage.capture_resources":115.757,"Shader.DrawStage.materialize":29.385,"Shader.DrawStage.prepared_invocation":29.694,"VideoOut.Flip":130.583,"VideoOut.Flip.completion_mutex_wait":0.178,"VideoOut.Flip.config_mutex_wait":0.024,"VideoOut.Flip.frame_limit":0.123,"VideoOut.Flip.notify_game":22.462,"VideoOut.Flip.present":105.921,"VideoOut.Flip.validate":0.269,"VideoOut.Flip.vblank_wait":0.150,"VideoOut.Flip.window_prepare":0.325,"VideoOut.Flip.window_title":0.904,"VideoOut.Readiness":0.533,"VideoOut.Readiness.locks_validate":0.163,"Vulkan.Acquire":2.154,"Vulkan.Acquire.acquire_fence_wait":0.389,"Vulkan.Acquire.acquire_image":1.192,"Vulkan.Acquire.fence_reset":0.403,"Vulkan.Acquire.retired_swapchains":0.100,"Vulkan.DrawFromRecipe":1066.442,"Vulkan.Present":19.239,"Vulkan.Present.command_record_scale":7.287,"Vulkan.Present.pixel_upload":0.369,"Vulkan.Present.queue_submit":11.324,"Vulkan.QueuePresent":72.393,"Vulkan.QueuePresent.queue_present":71.941,"Vulkan.Retire":2.840,"Vulkan.Retire.dump":0.368,"Vulkan.Retire.wait":0.671},"top_phases_ms_per_frame":{"Recorder.Sync":23.841,"Graphics.Draw":5.742,"Graphics.Draw.draw_and_resource_release":5.461,"Vulkan.DrawFromRecipe":5.306,"Graphics.DrawWithRecipe":5.275,"Graphics.DrawWithRecipe.draw_and_resource_release":4.986,"Driver.Packet":3.522,"Driver.Packet.draw":2.735},"owned_draw_counts":{},"graphics_track":{"Graphics.Barrier.draw":20985,"Graphics.Barrier.present-blit":402,"Graphics.Barrier.storage-upload":2412,"Graphics.Barrier.storage-writeback":3618,"Graphics.RenderPass":6995,"Graphics.RenderPass.Close.command":603,"Graphics.RenderPass.Close.new-batch":6392,"Graphics.RenderPass.Continued":8470},"trace_dropped":false,"trace":"aps5-trace-8763aeffdc37-9248.json.gz"}
this PR (b6de80aed7)
{"commit":"b6de80aed7fb","dirty":false,"env":{"APS5_DUMP_FRAMES":"100000","APS5_DUMP_FRAMES_EVERY":"30","APS5_DUMP_SCALE":"8","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_EVENTS":"1048576","APS5_TRACE_SECONDS":"80:10","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 5060 Ti","driver":"NVIDIA 621.24","os":"Windows 10.0.26300","cpu":"Intel(R) Core(TM) i5-10600K CPU @ 4.10GHz","cpu_threads":12,"memory_mib":32685,"title_id":"PPSA69421","title":"SuperTuxKart","content_version":"00.001.000","resolution":"1920x1080","window":{"spec":"seconds 80:10","first_present":1488,"ms":10035.941},"presents":194,"frame_ms":{"p50":49.450,"p90":53.246,"p99":78.799,"max":351.872},"gpu_busy_ms_per_present":19.885,"worker_busy_pct":{"queue worker 0x0":7.172},"phase_totals_ms":{"Driver.Completion":1.287,"Driver.Draw":548.576,"Driver.Draw.device_setup":34.682,"Driver.Draw.draw_enqueued":121.773,"Driver.Draw.post_compile_prepare":7.982,"Driver.Draw.prepare":47.206,"Driver.Draw.shader_compile_and_link":327.557,"Driver.EndSubmission":7.140,"Driver.Packet":711.267,"Driver.Packet.device_lock":9.091,"Driver.Packet.draw":558.795,"Driver.Packet.execute":57.278,"Driver.Packet.flip_flush":0.287,"Driver.Packet.flush_between_packets":14.870,"Driver.Packet.pipeline_drain":13.101,"Driver.Packet.pipeline_prepare":14.460,"Driver.Packet.prepare_memory":14.369,"Driver.Present":103.454,"Driver.Present.acquire_image":2.303,"Driver.Present.device_setup":0.112,"Driver.Present.gpu_mutex_wait":0.397,"Driver.Present.inflight_wait":0.528,"Driver.Present.present_display_buffer":24.646,"Driver.Present.queue_present":71.676,"Driver.Present.release_and_callback":0.279,"Driver.Present.render_fence_wait":2.991,"Driver.Present.resize":0.344,"Driver.Present.validate":0.058,"Driver.Suspend":0.054,"GpuMutex.wait.flush":231.516,"Graphics.Draw":1166.891,"Graphics.Draw.draw_and_resource_release":1111.393,"Graphics.Draw.index_upload":25.264,"Graphics.Draw.validate":23.253,"Graphics.Draw.vertex_upload":2.961,"Graphics.DrawWithRecipe":1086.549,"Graphics.DrawWithRecipe.draw_and_resource_release":1023.527,"Graphics.DrawWithRecipe.index_upload":50.095,"Graphics.DrawWithRecipe.validate":7.005,"Graphics.DrawWithRecipe.vertex_upload":2.951,"Graphics.Submit":0.059,"Graphics.Submit.command_end":0.004,"Graphics.Submit.queue_submit":0.055,"Graphics.Wait":3.113,"Graphics.Wait.fence_wait":3.111,"Recorder.Reap":0.804,"Recorder.Submit":580.909,"Recorder.Sync":4856.607,"Shader.DrawStage":181.698,"Shader.DrawStage.capture_resources":120.253,"Shader.DrawStage.materialize":29.321,"Shader.DrawStage.prepared_invocation":29.862,"VideoOut.Flip":117.376,"VideoOut.Flip.completion_mutex_wait":0.175,"VideoOut.Flip.config_mutex_wait":0.024,"VideoOut.Flip.frame_limit":0.113,"VideoOut.Flip.notify_game":10.809,"VideoOut.Flip.present":104.464,"VideoOut.Flip.validate":0.248,"VideoOut.Flip.vblank_wait":0.153,"VideoOut.Flip.window_prepare":0.312,"VideoOut.Flip.window_title":0.824,"VideoOut.Readiness":0.490,"VideoOut.Readiness.locks_validate":0.164,"Vulkan.Acquire":2.116,"Vulkan.Acquire.acquire_fence_wait":0.405,"Vulkan.Acquire.acquire_image":1.149,"Vulkan.Acquire.fence_reset":0.411,"Vulkan.Acquire.retired_swapchains":0.088,"Vulkan.DrawFromRecipe":1092.655,"Vulkan.Present":18.809,"Vulkan.Present.command_record_scale":7.290,"Vulkan.Present.pixel_upload":0.373,"Vulkan.Present.queue_submit":10.905,"Vulkan.QueuePresent":71.340,"Vulkan.QueuePresent.queue_present":70.893,"Vulkan.Retire":2.896,"Vulkan.Retire.dump":0.395,"Vulkan.Retire.wait":0.627},"top_phases_ms_per_frame":{"Recorder.Sync":25.034,"Graphics.Draw":6.015,"Graphics.Draw.draw_and_resource_release":5.729,"Vulkan.DrawFromRecipe":5.632,"Graphics.DrawWithRecipe":5.601,"Graphics.DrawWithRecipe.draw_and_resource_release":5.276,"Driver.Packet":3.666,"Recorder.Submit":2.994},"owned_draw_counts":{},"graphics_track":{"Graphics.Barrier.draw":20319,"Graphics.Barrier.present-blit":388,"Graphics.Barrier.storage-upload":2328,"Graphics.Barrier.storage-writeback":3492,"Graphics.Copy":2,"Graphics.Copy.bytes":18874368,"Graphics.RenderPass":6773,"Graphics.RenderPass.Close.command":582,"Graphics.RenderPass.Close.new-batch":6191,"Graphics.RenderPass.Continued":8175},"trace_dropped":false,"trace":"aps5-trace-b6de80aed7fb-1588.json.gz"}

Not run: the whole CTest suite, other titles, Linux and macOS (the change is in shared code with no platform branch). The traces are available on request.

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: NVIDIA GeForce RTX 5060 Ti, NVIDIA 621.24, Windows 11 (10.0.26300)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5432269828 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25280). Originally posted by [LeandroLP23](https://github.com/LeandroLP23) on 2026-11-21T20:50:04Z. --- ### What - The direct-memory pool's first-fit search skips a used run by looking for the next free page flag with `std::find`, one byte per 16 KiB page. SuperTuxKart (PPSA69421) allocates, maps, unmaps and releases about 1000 64 KiB blocks per second during a race, above a used prefix of about 1.4 GiB, so every `sceKernelAllocateDirectMemory` scans about 92,000 flags under the pool lock. - `PhysicalMemoryPool::_nextFreePage` now finds the flag with `memchr` and returns the same page (or the search limit when every flag up to it is set). A `static_assert` pins `sizeof(bool) == 1`, which the byte scan relies on. - `MemoryPoolTest` gets `alloc_past_a_long_used_run`: two 1.5 GiB runs around a one-page hole; a two-page request lands after the second run, the hole is found for a one-page request, and a search end inside the runs (or at the end of the second one for a two-page request) returns `SCE_KERNEL_ERROR_EAGAIN`. - `tools/pr_overlap.py --branch HEAD`: no overlap with open pull requests (#24063 also edits `MemoryPool.cpp` and merges cleanly). ### Tested Windows 11 (10.0.26300), NVIDIA GeForce RTX 5060 Ti (NVIDIA 621.24), Intel i5-10600K, WinLibs GCC 15.2.0 r7, Release. - `MemoryPoolTest` on `main` `8763aeffdc` (with the new case added) and with this change: 21 of 21 cases pass on both. - Time per call, measured with a temporary `steady_clock` timer around the export (not part of this change) in the same SuperTuxKart race (title_run with a pad timeline, 110 s), two interleaved pairs; this was on a local branch with `1a5c95da66e` applied, which `main` already contains: | run | `sceKernelAllocateDirectMemory` per call | |---|---| | `std::find` | 28.9 us | | `memchr` | 10.3 us | | `std::find` | 29.3 us | | `memchr` | 10.5 us | That is about 0.6 ms per frame of the game thread at about 35 allocations per frame. The frame time does not show it within the run-to-run noise: frame p50 37.9 / 38.4 ms with `std::find` and 37.7 / 38.9 ms with `memchr` on that branch. - `tools/trace_digest.py` on real commits, same race, 10 s window 80 s after the first present (`APS5_TRACE_SECONDS=80:10`), `main` `8763aeffdc` and this branch's head `b6de80aed7`, alternated twice: | run | presents | frame p50 / p99 | GPU busy per present | |---|---|---|---| | main | 201 | 49.5 / 55.7 ms | 20.4 ms | | this PR | 194 | 49.5 / 78.8 ms | 19.9 ms | | main | 198 | 49.9 / 59.6 ms | 20.6 ms | | this PR | 198 | 50.4 / 62.4 ms | 21.1 ms | No change in frame time beyond noise; the claim is the time per allocation above. Working set and private bytes are unchanged (3.3 / 5.0 GB). Summary lines of the first pair: <details><summary>main (<code>8763aeffdc</code>)</summary> ```json {"commit":"8763aeffdc37","dirty":false,"env":{"APS5_DUMP_FRAMES":"100000","APS5_DUMP_FRAMES_EVERY":"30","APS5_DUMP_SCALE":"8","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_EVENTS":"1048576","APS5_TRACE_SECONDS":"80:10","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 5060 Ti","driver":"NVIDIA 621.24","os":"Windows 10.0.26300","cpu":"Intel(R) Core(TM) i5-10600K CPU @ 4.10GHz","cpu_threads":12,"memory_mib":32685,"title_id":"PPSA69421","title":"SuperTuxKart","content_version":"00.001.000","resolution":"1920x1080","window":{"spec":"seconds 80:10","first_present":1464,"ms":10000.865},"presents":201,"frame_ms":{"p50":49.460,"p90":52.357,"p99":55.684,"max":58.123},"gpu_busy_ms_per_present":20.353,"worker_busy_pct":{"queue worker 0x0":7.146},"phase_totals_ms":{"Driver.Completion":1.397,"Driver.Draw":540.067,"Driver.Draw.device_setup":33.719,"Driver.Draw.draw_enqueued":122.441,"Driver.Draw.post_compile_prepare":7.338,"Driver.Draw.prepare":46.225,"Driver.Draw.shader_compile_and_link":321.126,"Driver.EndSubmission":5.215,"Driver.Packet":707.949,"Driver.Packet.device_lock":9.319,"Driver.Packet.draw":549.728,"Driver.Packet.execute":62.059,"Driver.Packet.flip_flush":0.283,"Driver.Packet.flush_between_packets":15.153,"Driver.Packet.pipeline_drain":13.158,"Driver.Packet.pipeline_prepare":14.092,"Driver.Packet.prepare_memory":14.448,"Driver.Present":104.874,"Driver.Present.acquire_image":2.349,"Driver.Present.device_setup":0.111,"Driver.Present.gpu_mutex_wait":0.411,"Driver.Present.inflight_wait":0.545,"Driver.Present.present_display_buffer":24.971,"Driver.Present.queue_present":72.761,"Driver.Present.release_and_callback":0.251,"Driver.Present.render_fence_wait":2.927,"Driver.Present.resize":0.368,"Driver.Present.validate":0.059,"Driver.Suspend":0.051,"Graphics.Draw":1154.184,"Graphics.Draw.draw_and_resource_release":1097.644,"Graphics.Draw.index_upload":26.064,"Graphics.Draw.validate":23.301,"Graphics.Draw.vertex_upload":2.982,"Graphics.DrawWithRecipe":1060.300,"Graphics.DrawWithRecipe.draw_and_resource_release":1002.265,"Graphics.DrawWithRecipe.index_upload":45.326,"Graphics.DrawWithRecipe.validate":6.705,"Graphics.DrawWithRecipe.vertex_upload":2.945,"Recorder.Reap":0.821,"Recorder.Submit":258.012,"Recorder.Sync":4792.116,"Shader.DrawStage":177.106,"Shader.DrawStage.capture_resources":115.757,"Shader.DrawStage.materialize":29.385,"Shader.DrawStage.prepared_invocation":29.694,"VideoOut.Flip":130.583,"VideoOut.Flip.completion_mutex_wait":0.178,"VideoOut.Flip.config_mutex_wait":0.024,"VideoOut.Flip.frame_limit":0.123,"VideoOut.Flip.notify_game":22.462,"VideoOut.Flip.present":105.921,"VideoOut.Flip.validate":0.269,"VideoOut.Flip.vblank_wait":0.150,"VideoOut.Flip.window_prepare":0.325,"VideoOut.Flip.window_title":0.904,"VideoOut.Readiness":0.533,"VideoOut.Readiness.locks_validate":0.163,"Vulkan.Acquire":2.154,"Vulkan.Acquire.acquire_fence_wait":0.389,"Vulkan.Acquire.acquire_image":1.192,"Vulkan.Acquire.fence_reset":0.403,"Vulkan.Acquire.retired_swapchains":0.100,"Vulkan.DrawFromRecipe":1066.442,"Vulkan.Present":19.239,"Vulkan.Present.command_record_scale":7.287,"Vulkan.Present.pixel_upload":0.369,"Vulkan.Present.queue_submit":11.324,"Vulkan.QueuePresent":72.393,"Vulkan.QueuePresent.queue_present":71.941,"Vulkan.Retire":2.840,"Vulkan.Retire.dump":0.368,"Vulkan.Retire.wait":0.671},"top_phases_ms_per_frame":{"Recorder.Sync":23.841,"Graphics.Draw":5.742,"Graphics.Draw.draw_and_resource_release":5.461,"Vulkan.DrawFromRecipe":5.306,"Graphics.DrawWithRecipe":5.275,"Graphics.DrawWithRecipe.draw_and_resource_release":4.986,"Driver.Packet":3.522,"Driver.Packet.draw":2.735},"owned_draw_counts":{},"graphics_track":{"Graphics.Barrier.draw":20985,"Graphics.Barrier.present-blit":402,"Graphics.Barrier.storage-upload":2412,"Graphics.Barrier.storage-writeback":3618,"Graphics.RenderPass":6995,"Graphics.RenderPass.Close.command":603,"Graphics.RenderPass.Close.new-batch":6392,"Graphics.RenderPass.Continued":8470},"trace_dropped":false,"trace":"aps5-trace-8763aeffdc37-9248.json.gz"} ``` </details> <details><summary>this PR (<code>b6de80aed7</code>)</summary> ```json {"commit":"b6de80aed7fb","dirty":false,"env":{"APS5_DUMP_FRAMES":"100000","APS5_DUMP_FRAMES_EVERY":"30","APS5_DUMP_SCALE":"8","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_EVENTS":"1048576","APS5_TRACE_SECONDS":"80:10","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 5060 Ti","driver":"NVIDIA 621.24","os":"Windows 10.0.26300","cpu":"Intel(R) Core(TM) i5-10600K CPU @ 4.10GHz","cpu_threads":12,"memory_mib":32685,"title_id":"PPSA69421","title":"SuperTuxKart","content_version":"00.001.000","resolution":"1920x1080","window":{"spec":"seconds 80:10","first_present":1488,"ms":10035.941},"presents":194,"frame_ms":{"p50":49.450,"p90":53.246,"p99":78.799,"max":351.872},"gpu_busy_ms_per_present":19.885,"worker_busy_pct":{"queue worker 0x0":7.172},"phase_totals_ms":{"Driver.Completion":1.287,"Driver.Draw":548.576,"Driver.Draw.device_setup":34.682,"Driver.Draw.draw_enqueued":121.773,"Driver.Draw.post_compile_prepare":7.982,"Driver.Draw.prepare":47.206,"Driver.Draw.shader_compile_and_link":327.557,"Driver.EndSubmission":7.140,"Driver.Packet":711.267,"Driver.Packet.device_lock":9.091,"Driver.Packet.draw":558.795,"Driver.Packet.execute":57.278,"Driver.Packet.flip_flush":0.287,"Driver.Packet.flush_between_packets":14.870,"Driver.Packet.pipeline_drain":13.101,"Driver.Packet.pipeline_prepare":14.460,"Driver.Packet.prepare_memory":14.369,"Driver.Present":103.454,"Driver.Present.acquire_image":2.303,"Driver.Present.device_setup":0.112,"Driver.Present.gpu_mutex_wait":0.397,"Driver.Present.inflight_wait":0.528,"Driver.Present.present_display_buffer":24.646,"Driver.Present.queue_present":71.676,"Driver.Present.release_and_callback":0.279,"Driver.Present.render_fence_wait":2.991,"Driver.Present.resize":0.344,"Driver.Present.validate":0.058,"Driver.Suspend":0.054,"GpuMutex.wait.flush":231.516,"Graphics.Draw":1166.891,"Graphics.Draw.draw_and_resource_release":1111.393,"Graphics.Draw.index_upload":25.264,"Graphics.Draw.validate":23.253,"Graphics.Draw.vertex_upload":2.961,"Graphics.DrawWithRecipe":1086.549,"Graphics.DrawWithRecipe.draw_and_resource_release":1023.527,"Graphics.DrawWithRecipe.index_upload":50.095,"Graphics.DrawWithRecipe.validate":7.005,"Graphics.DrawWithRecipe.vertex_upload":2.951,"Graphics.Submit":0.059,"Graphics.Submit.command_end":0.004,"Graphics.Submit.queue_submit":0.055,"Graphics.Wait":3.113,"Graphics.Wait.fence_wait":3.111,"Recorder.Reap":0.804,"Recorder.Submit":580.909,"Recorder.Sync":4856.607,"Shader.DrawStage":181.698,"Shader.DrawStage.capture_resources":120.253,"Shader.DrawStage.materialize":29.321,"Shader.DrawStage.prepared_invocation":29.862,"VideoOut.Flip":117.376,"VideoOut.Flip.completion_mutex_wait":0.175,"VideoOut.Flip.config_mutex_wait":0.024,"VideoOut.Flip.frame_limit":0.113,"VideoOut.Flip.notify_game":10.809,"VideoOut.Flip.present":104.464,"VideoOut.Flip.validate":0.248,"VideoOut.Flip.vblank_wait":0.153,"VideoOut.Flip.window_prepare":0.312,"VideoOut.Flip.window_title":0.824,"VideoOut.Readiness":0.490,"VideoOut.Readiness.locks_validate":0.164,"Vulkan.Acquire":2.116,"Vulkan.Acquire.acquire_fence_wait":0.405,"Vulkan.Acquire.acquire_image":1.149,"Vulkan.Acquire.fence_reset":0.411,"Vulkan.Acquire.retired_swapchains":0.088,"Vulkan.DrawFromRecipe":1092.655,"Vulkan.Present":18.809,"Vulkan.Present.command_record_scale":7.290,"Vulkan.Present.pixel_upload":0.373,"Vulkan.Present.queue_submit":10.905,"Vulkan.QueuePresent":71.340,"Vulkan.QueuePresent.queue_present":70.893,"Vulkan.Retire":2.896,"Vulkan.Retire.dump":0.395,"Vulkan.Retire.wait":0.627},"top_phases_ms_per_frame":{"Recorder.Sync":25.034,"Graphics.Draw":6.015,"Graphics.Draw.draw_and_resource_release":5.729,"Vulkan.DrawFromRecipe":5.632,"Graphics.DrawWithRecipe":5.601,"Graphics.DrawWithRecipe.draw_and_resource_release":5.276,"Driver.Packet":3.666,"Recorder.Submit":2.994},"owned_draw_counts":{},"graphics_track":{"Graphics.Barrier.draw":20319,"Graphics.Barrier.present-blit":388,"Graphics.Barrier.storage-upload":2328,"Graphics.Barrier.storage-writeback":3492,"Graphics.Copy":2,"Graphics.Copy.bytes":18874368,"Graphics.RenderPass":6773,"Graphics.RenderPass.Close.command":582,"Graphics.RenderPass.Close.new-batch":6191,"Graphics.RenderPass.Continued":8175},"trace_dropped":false,"trace":"aps5-trace-b6de80aed7fb-1588.json.gz"} ``` </details> Not run: the whole CTest suite, other titles, Linux and macOS (the change is in shared code with no platform branch). The traces are available on request. ### 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: NVIDIA GeForce RTX 5060 Ti, NVIDIA 621.24, Windows 11 (10.0.26300) - [x] AI-assisted: yes
PrivacyOnion commented 2026-11-21 21:53:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-21T21:53:42Z.

Review: APPROVED


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

  • Conventions: tools/check_conventions.py passed.
  • Build: MemoryPoolTest built cleanly.
  • CTest (MemoryPoolTest):
    1/1 Test #1078: MemoryPoolTest ...................   Passed    0.53 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libkernel/DirectMemory/MemoryPool.cpp reverted to main and the new tests kept, the suite fails:
    1/1 Test #1078: MemoryPoolTest ...................   Passed    0.36 sec
    100% tests passed, 0 tests failed out of 1
    
    Restoring the change makes it pass again.
  • Code reading:
    • Verified std::memchr(_used + first, 0, limit - first) correctly locates the first byte equal to 0 (false) in PhysicalMemoryPool::_nextFreePage
    • Verified static_assert(sizeof(bool) == 1) ensures scanning bool array _used byte-by-byte via std::memchr is safe and well-defined under standard C++ boolean representations
    • Checked pointer arithmetic and bounds: _used + first is within bounds since first <= limit <= kNumPages, and pointer subtraction static_cast<const bool*>(hit) - _used produces the exact page index
    • Checked fallback when memchr returns nullptr: properly returns limit matching the previous std::find behavior where std::find(_used + first, _used + limit, false) returned _used + limit
    • Audited MemoryPoolTest alloc_past_a_long_used_run test case to ensure proper pool cleanup via DirectMemoryFree(0, kPool) and CHECK(PoolEmpty())

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6008440556 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25280#pullrequestreview-6008440556). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-21T21:53:42Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `b6de80aed7`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `MemoryPoolTest` built cleanly. - **CTest** (`MemoryPoolTest`): ``` 1/1 Test #1078: MemoryPoolTest ................... Passed 0.53 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libkernel/DirectMemory/MemoryPool.cpp` reverted to `main` and the new tests kept, the suite fails: ``` 1/1 Test #1078: MemoryPoolTest ................... Passed 0.36 sec 100% tests passed, 0 tests failed out of 1 ``` Restoring the change makes it pass again. - **Code reading**: - Verified std::memchr(_used + first, 0, limit - first) correctly locates the first byte equal to 0 (false) in PhysicalMemoryPool::_nextFreePage - Verified static_assert(sizeof(bool) == 1) ensures scanning bool array _used byte-by-byte via std::memchr is safe and well-defined under standard C++ boolean representations - Checked pointer arithmetic and bounds: _used + first is within bounds since first <= limit <= kNumPages, and pointer subtraction static_cast<const bool*>(hit) - _used produces the exact page index - Checked fallback when memchr returns nullptr: properly returns limit matching the previous std::find behavior where std::find(_used + first, _used + limit, false) returned _used + limit - Audited MemoryPoolTest alloc_past_a_long_used_run test case to ensure proper pool cleanup via DirectMemoryFree(0, kPool) and CHECK(PoolEmpty()) Looks Good To Me
MarcZX10 commented 2026-11-22 18:09:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T18:09:24Z.

Review: APPROVED


Reviewed — looks good

The reviewed change preserves the existing first-fit search behavior while using memchr to find the next free page flag.

What I ran

Read the prepared PR description, commits, manifest, and diff, then read both changed files through the reader pinned to head b6de80aed7fb20c0b45f4c7da2d8483aeb17c4eb. No executable tests or other commands were run in this environment.

Results

Check Result Note
Changed code review passed Both changed files read
MemoryPoolTest not run Author reports 21 of 21 cases passed
Full CTest suite not run Not run by author or reviewer

Negative control

Not run; no executable test environment was available.

Findings

Blocking

None.

Non-blocking

None.

Sources

Not verified

The author-reported test results and performance measurements were not independently verified. The full CTest suite, other titles, and Linux and macOS behavior were not run. Both changed files listed in the manifest were read; no changed files were excluded.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6013673180 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25280#pullrequestreview-6013673180). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-22T18:09:24Z. **Review:** APPROVED --- # Reviewed — looks good The reviewed change preserves the existing first-fit search behavior while using `memchr` to find the next free page flag. ## What I ran Read the prepared PR description, commits, manifest, and diff, then read both changed files through the reader pinned to head `b6de80aed7fb20c0b45f4c7da2d8483aeb17c4eb`. No executable tests or other commands were run in this environment. ## Results | Check | Result | Note | |---|---|---| | Changed code review | passed | Both changed files read | | `MemoryPoolTest` | not run | Author reports 21 of 21 cases passed | | Full CTest suite | not run | Not run by author or reviewer | ## Negative control Not run; no executable test environment was available. ## Findings ### Blocking None. ### Non-blocking None. ## Sources - [`MemoryPool.cpp` at reviewed head](https://github.com/boykopovar/AnyPS5/blob/b6de80aed7fb20c0b45f4c7da2d8483aeb17c4eb/core/libs/prx/libkernel/DirectMemory/MemoryPool.cpp#L250-L253) - [`MemoryPoolTest.cpp` at reviewed head](https://github.com/boykopovar/AnyPS5/blob/b6de80aed7fb20c0b45f4c7da2d8483aeb17c4eb/core/libs/tests/MemoryPoolTest.cpp#L129-L142) ## Not verified The author-reported test results and performance measurements were not independently verified. The full CTest suite, other titles, and Linux and macOS behavior were not run. Both changed files listed in the manifest were read; no changed files were excluded. ## To get this to a good state Nothing is required.
ligmaSec commented 2026-12-03 13:55:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T13:55:50Z.

Review: COMMENTED


Built the branch sources against the existing Linux runtime. The memory-pool fixture passed.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6171156601 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25280#pullrequestreview-6171156601). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T13:55:50Z. **Review:** COMMENTED --- Built the branch sources against the existing Linux runtime. The memory-pool fixture passed. AI-assisted: yes.
Plyxen commented 2026-12-03 14:09:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-12-03T14:09:04Z.

Review: APPROVED


I read the diff at b6de80aed7. Windows 11 with GCC 15.2 and Linux (Ubuntu 24.04 in WSL2, GCC 13.3), merged into main at 6c6b29320fe together with other open PRs (so not an isolated build).

  • MemoryPoolTest: pass on both.
  • Control (the same tree with only this PR's source change taken out): it passes too, as it should: the search must return the same page. I checked the result, not the speed.

Not checked: the timing in the body.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6171391475 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25280#pullrequestreview-6171391475). Originally posted by [Plyxen](https://github.com/Plyxen) on 2026-12-03T14:09:04Z. **Review:** APPROVED --- I read the diff at `b6de80aed7`. Windows 11 with GCC 15.2 and Linux (Ubuntu 24.04 in WSL2, GCC 13.3), merged into `main` at `6c6b29320fe` together with other open PRs (so not an isolated build). - `MemoryPoolTest`: pass on both. - Control (the same tree with only this PR's source change taken out): it passes too, as it should: the search must return the same page. I checked the result, not the speed. Not checked: the timing in the body. AI-assisted: yes (Claude Code)
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/25280:upstream-pr/25280'
git switch 'upstream-pr/25280'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/25280'
git switch 'upstream-pr/25280'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/25280'
git switch 'upstream-pr/25280'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/25280'
git switch 'main'
git merge --squash 'upstream-pr/25280'
git switch 'main'
git merge --ff-only 'upstream-pr/25280'
git switch 'main'
git merge 'upstream-pr/25280'
git push origin 'main'
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!25280
No description provided.