perf(libc): release exact resident mappings without repeated queries #7470

Merged
Dripl1x merged 4 commits from upstream-pr/7470 into main 2026-10-21 01:07:26 +00:00
Dripl1x commented 2026-10-18 08:47:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dripl1x on 2026-10-18T08:47:25Z.


What

This PR is part of a series of graphics and memory-management performance improvements for AnyPS5, with SuperTuxKart as the main profiling workload. This is item 07/10; the UI Lab startup/cache fix follows as a separate eleventh PR. Each topic's measurements are distinguished from the combined result.

Release a known complete resident allocation using the maintained resident-run metadata. Partial, split and mixed-protection cases keep the existing query and release path.

Tested

Pinned benchmark base: 6447ed1ed7fd11c7eef60df336e8d66fac271188. Tested topic snapshot: 97c11bcb94f90852fcebf7d23dc066dc2feec6a3. Windows 11 Pro build 26300, Ryzen 7 5800H, RTX 3070 Laptop, NVIDIA 617.42. Frozen runtime module hashes and raw traces were verified. No opt-in optimization flags are required.

3/3 memory/write-watch cases passed on main and this topic. A process-local diagnostic counted actual VirtualQuery calls during unmap and verified all 65,536 bytes after remapping: ordinary exact 64-KiB release 9 -> 0 calls; mixed protection 44 -> 44; partial 16-KiB release with live neighbors 22 -> 22. The diagnostic hook is outside the PR.

SuperTuxKart captures for the bot's before/after requirement: Windows 11 Pro build 26300, Ryzen 7 5800H, RTX 3070 Laptop GPU, NVIDIA 617.42, WinLibs GCC 15.2.0 r7, Release; SuperTuxKart (PPSA69421) tutorial prompt over the main menu, 1920x1080 internal rendering in a maximized 2560x1369 window, warm shader caches, audio muted, no input; APS5_TRACE_SECONDS=20:8 with APS5_TRACE_EVENTS=1048576, console output not redirected, no profiling switches; 2026-10-21, captures in the order main, #7470, #7472, main, order main, PR, (#7472), main.

Capture Build Commit FPS p50 / p90 / p99 ms
rv21-a3-main-6447 main 6447ed1ed7fd 6447ed1ed7fd 9.574 104.0 / 107.5 / 109.8
rv21-a6-main-6447 main 6447ed1ed7fd 6447ed1ed7fd 9.623 103.3 / 106.5 / 112.0
rv21-a4-7470 this PR 7c345db5a501 9.572 103.5 / 108.7 / 120.3

The FPS difference is within the run-to-run spread of main; this PR claims no FPS change. What it saves is shown under Where it helps.

Summary lines (main first, then this PR)
{"commit":"6447ed1ed7fd","dirty":false,"env":{"APS5_TRACE_EVENTS":"1048576","APS5_TRACE_SECONDS":"20:8"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","resolution":"1920x1080","window":{"spec":"seconds 20:8","first_present":39,"ms":8042.799},"presents":77,"frame_ms":{"p50":103.957,"p90":107.464,"p99":109.753,"max":109.753},"gpu_busy_ms_per_present":5.263,"worker_busy_pct":{"queue worker 0x0":2.995},"top_phases_ms_per_frame":{"Driver.Packet":3.081,"Driver.Packet.draw":2.485,"Driver.Draw":2.431,"Driver.Draw.shader_compile_and_link":1.442,"Driver.Present":0.839,"Shader.DrawStage":0.759,"Driver.Present.queue_present":0.584,"Vulkan.QueuePresent":0.583},"trace_dropped":false,"trace":"aps5-trace-6447ed1ed7fd-3204.json.gz"}
{"commit":"6447ed1ed7fd","dirty":false,"env":{"APS5_TRACE_EVENTS":"1048576","APS5_TRACE_SECONDS":"20:8"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","resolution":"1920x1080","window":{"spec":"seconds 20:8","first_present":40,"ms":8001.567},"presents":77,"frame_ms":{"p50":103.326,"p90":106.501,"p99":111.961,"max":111.961},"gpu_busy_ms_per_present":5.280,"worker_busy_pct":{"queue worker 0x0":2.974},"top_phases_ms_per_frame":{"Driver.Packet":3.045,"Driver.Packet.draw":2.466,"Driver.Draw":2.411,"Driver.Draw.shader_compile_and_link":1.424,"Driver.Present":0.848,"Shader.DrawStage":0.773,"Driver.Present.queue_present":0.598,"Vulkan.QueuePresent":0.596},"trace_dropped":false,"trace":"aps5-trace-6447ed1ed7fd-52092.json.gz"}
{"commit":"7c345db5a501","dirty":false,"env":{"APS5_TRACE_EVENTS":"1048576","APS5_TRACE_SECONDS":"20:8"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","resolution":"1920x1080","window":{"spec":"seconds 20:8","first_present":40,"ms":8044.109},"presents":77,"frame_ms":{"p50":103.526,"p90":108.721,"p99":120.332,"max":120.332},"gpu_busy_ms_per_present":5.217,"worker_busy_pct":{"queue worker 0x0":2.973},"top_phases_ms_per_frame":{"Driver.Packet":3.059,"Driver.Packet.draw":2.482,"Driver.Draw":2.428,"Driver.Draw.shader_compile_and_link":1.457,"Driver.Present":0.862,"Shader.DrawStage":0.795,"Driver.Present.queue_present":0.610,"Vulkan.QueuePresent":0.608},"trace_dropped":false,"trace":"aps5-trace-7c345db5a501-34076.json.gz"}
tools/performance_compare.py (first capture of each side)

Performance comparison

Capture Commit Trace Presents Window (ms)
baseline 6447ed1ed7 aps5-trace-6447ed1ed7fd-3204.json.gz 77 8042.799
candidate 7c345db5a5 aps5-trace-7c345db5a501-34076.json.gz 77 8044.109
  • Compare captures from the same machine, title and scene; summaries do not record the CPU, title or scene.
  • Changes are candidate minus baseline. A negative frame-time change means a shorter frame interval.
  • A missing top phase is unreported, not zero; its change is unavailable.
  • Recorded configuration differs; these measurements do not isolate the code change.

Configuration differences

Setting Baseline Candidate
window.first_present 39 40

Frame and GPU times (ms)

Metric Baseline Candidate Change Change (%)
frame_ms.p50 103.957 103.526 -0.431 -0.415
frame_ms.p90 107.464 108.721 +1.257 +1.170
frame_ms.p99 109.753 120.332 +10.579 +9.639
frame_ms.max 109.753 120.332 +10.579 +9.639
mean_frame_ms 104.452 104.469 +0.017 +0.016
gpu_busy_ms_per_present 5.263 5.217 -0.046 -0.874

Top phases (ms per frame)

Metric Baseline Candidate Change Change (%)
Driver.Draw 2.431 2.428 -0.003 -0.123
Driver.Draw.shader_compile_and_link 1.442 1.457 +0.015 +1.040
Driver.Packet 3.081 3.059 -0.022 -0.714
Driver.Packet.draw 2.485 2.482 -0.003 -0.121
Driver.Present 0.839 0.862 +0.023 +2.741
Driver.Present.queue_present 0.584 0.610 +0.026 +4.452
Shader.DrawStage 0.759 0.795 +0.036 +4.743
Vulkan.QueuePresent 0.583 0.608 +0.025 +4.288
tools/trace_digest.py output (first capture of each side; all digests are in the evidence archive)

rv21-a3-main-6447

seconds 20:8 from present 39: 77 presents, frame p50 104.0 / p90 107.5 / p99 109.8 / max 109.8 ms, GPU busy 5.3 ms per present
NVIDIA GeForce RTX 3070 Laptop GPU, NVIDIA 617.42, Windows 10.0.26300, 1920x1080, commit 6447ed1ed7, dropped: no

{"commit":"6447ed1ed7fd","dirty":false,"env":{"APS5_TRACE_EVENTS":"1048576","APS5_TRACE_SECONDS":"20:8"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","resolution":"1920x1080","window":{"spec":"seconds 20:8","first_present":39,"ms":8042.799},"presents":77,"frame_ms":{"p50":103.957,"p90":107.464,"p99":109.753,"max":109.753},"gpu_busy_ms_per_present":5.263,"worker_busy_pct":{"queue worker 0x0":2.995},"top_phases_ms_per_frame":{"Driver.Packet":3.081,"Driver.Packet.draw":2.485,"Driver.Draw":2.431,"Driver.Draw.shader_compile_and_link":1.442,"Driver.Present":0.839,"Shader.DrawStage":0.759,"Driver.Present.queue_present":0.584,"Vulkan.QueuePresent":0.583},"trace_dropped":false,"trace":"aps5-trace-6447ed1ed7fd-3204.json.gz"}

Slowest frames (largest slices inside each, inclusive)

  • present 66: 109.8 ms at 2839 ms: Driver.WorkerWait (queue worker 0x0) 106.2, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 106.1, batch (gpu) 5.3, Driver.Packet (queue worker 0x0) 2.5
  • present 69: 109.4 ms at 3154 ms: Driver.WorkerWait (queue worker 0x0) 105.4, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 105.3, batch (gpu) 5.3, Driver.Packet (queue worker 0x0) 2.9
  • present 59: 108.1 ms at 2104 ms: Driver.WorkerWait (queue worker 0x0) 104.5, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 104.5, batch (gpu) 5.3, Driver.Packet (queue worker 0x0) 2.4

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
queue worker 0x0 2.5 (2 %) 101.0 (97 %) 1.0 3.8 Driver.Packet 2.5
presenter 0.8 (1 %) 0.0 (0 %) 103.6 0.1 Driver.Present 0.8
gpu 5.3 (5 %) 0.0 (0 %) 99.2 0.0 batch 5.3

rv21-a4-7470

seconds 20:8 from present 40: 77 presents, frame p50 103.5 / p90 108.7 / p99 120.3 / max 120.3 ms, GPU busy 5.2 ms per present
NVIDIA GeForce RTX 3070 Laptop GPU, NVIDIA 617.42, Windows 10.0.26300, 1920x1080, commit 7c345db5a5, dropped: no

{"commit":"7c345db5a501","dirty":false,"env":{"APS5_TRACE_EVENTS":"1048576","APS5_TRACE_SECONDS":"20:8"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","resolution":"1920x1080","window":{"spec":"seconds 20:8","first_present":40,"ms":8044.109},"presents":77,"frame_ms":{"p50":103.526,"p90":108.721,"p99":120.332,"max":120.332},"gpu_busy_ms_per_present":5.217,"worker_busy_pct":{"queue worker 0x0":2.973},"top_phases_ms_per_frame":{"Driver.Packet":3.059,"Driver.Packet.draw":2.482,"Driver.Draw":2.428,"Driver.Draw.shader_compile_and_link":1.457,"Driver.Present":0.862,"Shader.DrawStage":0.795,"Driver.Present.queue_present":0.61,"Vulkan.QueuePresent":0.608},"trace_dropped":false,"trace":"aps5-trace-7c345db5a501-34076.json.gz"}

Slowest frames (largest slices inside each, inclusive)

  • present 105: 120.3 ms at 6767 ms: Driver.WorkerWait (queue worker 0x0) 116.0, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 115.9, batch (gpu) 5.3, Driver.Packet (queue worker 0x0) 3.2
  • present 107: 111.9 ms at 6999 ms: Driver.WorkerWait (queue worker 0x0) 107.7, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 107.6, batch (gpu) 5.3, Driver.Packet (queue worker 0x0) 3.1
  • present 106: 111.5 ms at 6887 ms: Driver.WorkerWait (queue worker 0x0) 107.4, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 107.3, batch (gpu) 5.3, Driver.Packet (queue worker 0x0) 3.1

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
queue worker 0x0 2.4 (2 %) 101.0 (97 %) 1.1 3.9 Driver.Packet 2.4
presenter 0.8 (1 %) 0.0 (0 %) 103.6 0.1 Driver.Present 0.9
gpu 5.3 (5 %) 0.0 (0 %) 99.2 0.0 batch 5.3

Where it helps

About 105 resident releases per frame go through WindowsMappings::reset.

Measured main 2185dbf92e main + series
WindowsMappings::reset (release) calls per frame 105.1 95.9
WindowsMappings::reset (release) µs per call 32.40 27.89
WindowsMappings::reset (release) ms per frame 3.41 2.67
VirtualQuery calls per frame 992.1 575.4

Counters come from a local probe build that is not part of this PR (review-probe.patch in the evidence archive): the same counters and timers were inserted into main 2185dbf92e and into main with all eleven series PRs merged (#7464 in its rebased form), anchored on function definitions present in both trees. Runs were in the mirrored order main, series with #7464 reduced to its wake only, series, series, reduced series, main, in the scene above with APS5_PROFILE_DRAW=1; values are medians of two runs over the same 8-second window as the trace, starting 20 s after the first flip, per flip. These runs carry profiling overhead and are not used for FPS. Each optimised function below is changed by this PR only; counters show where the work goes, not an isolated FPS gain. reset timing differs between the two series variants measured that night (19.1 µs per call in the other one), so treat the per-call time as a range; the VirtualQuery count is the direct effect.

Other homebrew checks

Workload Control FPS This topic FPS Scope
vkQuake 54.590 57.519 Moving demo; small differences need matched camera repeats
Syobon Action 30.276 30.288 Approximately 30-FPS cap
Middle Ages Ping Pong 59.940 59.941 Approximately 60-FPS cap

UI Lab: the 21 default concepts were rendered and visually reviewed in a navigation cycle for this topic. Artwork was present; this covers default navigation, not all themes or every widget interaction.

Known baseline rendering issue: vkQuake still has intermittent flickering and an intermittently black floor on main and the tested performance branches. These changes do not fix it. Yamagi Quake II gameplay stops at unsupported last-provoking-vertex flat interpolation, and UZDoom at unsupported clip/cull-distance handling on the baseline; neither supplies a valid gameplay FPS comparison.

Dependencies, series and overlap

The project overlap scan found no conflicting open PR for this topic. The fast path only covers a complete ordinary resident release; no GPU import lifetime or partial-release semantics are changed.

The project overlap scan compared the local topics against 785 open PRs and checked merges into main e5c2b3c325e485ba7fd417c47c46f48aa2c89115. This topic merges cleanly in that snapshot. Some other PRs already conflict with main, so the tool cannot compare all their shared-file hunks; the full report is retained with the common series evidence package. No exact duplicate was identified in the inspected implementations. This is not a certification that every conflicting foreign branch is composition-tested.

Conventions and whitespace checks passed for the tested topic range. The benchmark base remains pinned for comparability; this is not a fresh-current-main build/test claim. Measurements and focused tests refer to the pinned source revisions above; no full-suite CI run is claimed.

Re-checked on 2026-10-21: this head still merges cleanly into main 2185dbf92e. #6658, which the earlier combined runs carried, merged into main on 2026-10-20.

Combined series result

Re-measured on 2026-10-21 on current main 2185dbf92e (Windows 11 Pro build 26300, Ryzen 7 5800H, RTX 3070 Laptop GPU, NVIDIA 617.42, WinLibs GCC 15.2.0 r7, Release; SuperTuxKart (PPSA69421) tutorial prompt over the main menu, 1920x1080 internal rendering in a maximized 2560x1369 window, warm shader caches, audio muted, no input; APS5_TRACE_SECONDS=20:8 with APS5_TRACE_EVENTS=1048576, console output not redirected, no profiling switches). Runs in the order A-B-C-D-D-C-B-A, two per configuration; FPS is presents over the 8-s window.

Configuration FPS, run 1 / run 2
main 2185dbf92e 9.18 / 9.03
main + #7464 + #7465 20.85 / 22.02
main + all eleven PRs of the series 29.01 / 28.70

#7464 and #7465 make the largest step together: the title's per-frame host imports disappear (see their PRs). With #7464 reduced to its CPU-label wake only, the whole series measured 10.07 / 9.01 FPS against main 9.24 / 9.30 in a separate block of the same session. Combined numbers are not the gain of any single PR. The combined builds are local merges of the published (#7465-#7470, #7472, #7474) and rebased (#7464, #7471, #7473) heads into main 2185dbf92e; the commits in their summary lines are those merges, not pushed. Summary lines, traces and digests: series-evidence.zip.

Checklist

  • Based on pinned main 6447ed1ed7fd; merges cleanly into current main 2185dbf92e (git merge-tree, 2026-10-21); related overlaps are listed above
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • 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 (library-only change; game test hardware above)
  • AI-assisted: yes

The current head includes the review correction and validation recorded below.

Series index

These are the ten performance topics from the same profiling effort, followed by a separate UI Lab cache-preservation fix. Membership in the series does not imply a dependency.

Item Pull request Required dependency
01 #7464: perf(agc): keep unimported label stores on the CPU #6658
02 #7465: perf(agc): defer small host imports until first GPU use none
03 #7466: perf(agc): validate host imports through their registered owner none
04 #7467: perf(libc): avoid repeated Windows path component scans none
05 #7468: perf(libkernel): find direct-memory aliases through the physical index none
06 #7469: perf(libkernel): find free direct-memory ranges in allocation order none
07 #7470: perf(libc): release exact resident mappings without repeated queries none
08 #7471: perf(libc): collect resident writes directly into the output buffer none
09 #7472: perf(libc): reuse saved direct-memory buffers when unreferenced none
10 #7473: perf(libc): skip write-watch queries for proven clean resident ranges #7471
11 #7474: fix(agc): preserve pipeline caches on immediate guest exit none

Reproduction evidence

Series traces, summary lines, module hashes, focused-test logs and UI contact sheets. Game measurements use the pinned base and source revisions described above; assets contain no game binaries.

Update of 2026-10-21: 7470-evidence.zip (traces, summary lines, trace_digest.py and performance_compare.py output, loaded-module hashes), counters where.json and the probe review-probe.patch with probe_window.py.

Review correction (2026-10-18)

Thanks for checking the lifecycle path and pointing out the skipped validation. Fixed in 7c345db5a501: the exact resident path now checks the actual AllocationBase, MEM_PRIVATE type and complete allocation extent before evicting any metadata. Added a valid release/remap test with split host protections and three mismatched-metadata tests. Each mismatched case fails against the previous PR implementation (97c11bcb94), which loses the resident metadata before rejecting the release, and passes on main and on this PR. Correction of 2026-10-21: the earlier "all four pass" was not a run of the project's test target. That target did not link with the supported WinLibs toolchain, because it did not link libc, which provides __gxx_personality_v0. Its valid case also never reached the exact-run path: the mapping crossed a 2-MiB boundary and split into two resident runs. Both are fixed in b5bb956530. All four tests now pass through ctest -R windows_mappings_release, and a temporary probe shows that both Reset calls of the valid case take the exact-run path (reply of 2026-10-21). I am not claiming an isolated lifecycle speedup from the noisy timing results.

The three corrections (#7467, #7469 and #7470) were also checked together against the previous series in a same-scene SuperTuxKart A-B-B-A repeat: 32.680 -> 32.722 FPS (1920x1080 internal rendering, maximized 2560x1369 client, warm caches, trace seconds 20-28, RTX 3070 Laptop/NVIDIA 617.42). Focus and loaded-module hashes were verified. This combined check does not assign a separate FPS gain to this PR. #7473 is being validated separately.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4907703098 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7470). Originally posted by [Dripl1x](https://github.com/Dripl1x) on 2026-10-18T08:47:25Z. --- ### What This PR is part of a series of graphics and memory-management performance improvements for AnyPS5, with SuperTuxKart as the main profiling workload. This is **item 07/10**; the UI Lab startup/cache fix follows as a separate eleventh PR. Each topic's measurements are distinguished from the combined result. Release a known complete resident allocation using the maintained resident-run metadata. Partial, split and mixed-protection cases keep the existing query and release path. ### Tested Pinned benchmark base: `6447ed1ed7fd11c7eef60df336e8d66fac271188`. Tested topic snapshot: `97c11bcb94f90852fcebf7d23dc066dc2feec6a3`. Windows 11 Pro build 26300, Ryzen 7 5800H, RTX 3070 Laptop, NVIDIA 617.42. Frozen runtime module hashes and raw traces were verified. No opt-in optimization flags are required. 3/3 memory/write-watch cases passed on main and this topic. A process-local diagnostic counted actual VirtualQuery calls during unmap and verified all 65,536 bytes after remapping: ordinary exact 64-KiB release 9 -> 0 calls; mixed protection 44 -> 44; partial 16-KiB release with live neighbors 22 -> 22. The diagnostic hook is outside the PR. SuperTuxKart captures for the bot's before/after requirement: Windows 11 Pro build 26300, Ryzen 7 5800H, RTX 3070 Laptop GPU, NVIDIA 617.42, WinLibs GCC 15.2.0 r7, Release; SuperTuxKart (PPSA69421) tutorial prompt over the main menu, 1920x1080 internal rendering in a maximized 2560x1369 window, warm shader caches, audio muted, no input; `APS5_TRACE_SECONDS=20:8` with `APS5_TRACE_EVENTS=1048576`, console output not redirected, no profiling switches; 2026-10-21, captures in the order main, #7470, #7472, main, order main, PR, (#7472), main. | Capture | Build | Commit | FPS | p50 / p90 / p99 ms | |---|---|---|---:|---| | `rv21-a3-main-6447` | main `6447ed1ed7fd` | `6447ed1ed7fd` | 9.574 | 104.0 / 107.5 / 109.8 | | `rv21-a6-main-6447` | main `6447ed1ed7fd` | `6447ed1ed7fd` | 9.623 | 103.3 / 106.5 / 112.0 | | `rv21-a4-7470` | this PR | `7c345db5a501` | 9.572 | 103.5 / 108.7 / 120.3 | The FPS difference is within the run-to-run spread of main; this PR claims no FPS change. What it saves is shown under **Where it helps**. <details> <summary>Summary lines (main first, then this PR)</summary> ```json {"commit":"6447ed1ed7fd","dirty":false,"env":{"APS5_TRACE_EVENTS":"1048576","APS5_TRACE_SECONDS":"20:8"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","resolution":"1920x1080","window":{"spec":"seconds 20:8","first_present":39,"ms":8042.799},"presents":77,"frame_ms":{"p50":103.957,"p90":107.464,"p99":109.753,"max":109.753},"gpu_busy_ms_per_present":5.263,"worker_busy_pct":{"queue worker 0x0":2.995},"top_phases_ms_per_frame":{"Driver.Packet":3.081,"Driver.Packet.draw":2.485,"Driver.Draw":2.431,"Driver.Draw.shader_compile_and_link":1.442,"Driver.Present":0.839,"Shader.DrawStage":0.759,"Driver.Present.queue_present":0.584,"Vulkan.QueuePresent":0.583},"trace_dropped":false,"trace":"aps5-trace-6447ed1ed7fd-3204.json.gz"} {"commit":"6447ed1ed7fd","dirty":false,"env":{"APS5_TRACE_EVENTS":"1048576","APS5_TRACE_SECONDS":"20:8"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","resolution":"1920x1080","window":{"spec":"seconds 20:8","first_present":40,"ms":8001.567},"presents":77,"frame_ms":{"p50":103.326,"p90":106.501,"p99":111.961,"max":111.961},"gpu_busy_ms_per_present":5.280,"worker_busy_pct":{"queue worker 0x0":2.974},"top_phases_ms_per_frame":{"Driver.Packet":3.045,"Driver.Packet.draw":2.466,"Driver.Draw":2.411,"Driver.Draw.shader_compile_and_link":1.424,"Driver.Present":0.848,"Shader.DrawStage":0.773,"Driver.Present.queue_present":0.598,"Vulkan.QueuePresent":0.596},"trace_dropped":false,"trace":"aps5-trace-6447ed1ed7fd-52092.json.gz"} {"commit":"7c345db5a501","dirty":false,"env":{"APS5_TRACE_EVENTS":"1048576","APS5_TRACE_SECONDS":"20:8"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","resolution":"1920x1080","window":{"spec":"seconds 20:8","first_present":40,"ms":8044.109},"presents":77,"frame_ms":{"p50":103.526,"p90":108.721,"p99":120.332,"max":120.332},"gpu_busy_ms_per_present":5.217,"worker_busy_pct":{"queue worker 0x0":2.973},"top_phases_ms_per_frame":{"Driver.Packet":3.059,"Driver.Packet.draw":2.482,"Driver.Draw":2.428,"Driver.Draw.shader_compile_and_link":1.457,"Driver.Present":0.862,"Shader.DrawStage":0.795,"Driver.Present.queue_present":0.610,"Vulkan.QueuePresent":0.608},"trace_dropped":false,"trace":"aps5-trace-7c345db5a501-34076.json.gz"} ``` </details> <details> <summary><code>tools/performance_compare.py</code> (first capture of each side)</summary> **Performance comparison** | Capture | Commit | Trace | Presents | Window (ms) | | --- | --- | --- | ---: | ---: | | baseline | 6447ed1ed7fd | aps5-trace-6447ed1ed7fd-3204.json.gz | 77 | 8042.799 | | candidate | 7c345db5a501 | aps5-trace-7c345db5a501-34076.json.gz | 77 | 8044.109 | - Compare captures from the same machine, title and scene; summaries do not record the CPU, title or scene. - Changes are candidate minus baseline. A negative frame-time change means a shorter frame interval. - A missing top phase is unreported, not zero; its change is unavailable. - Recorded configuration differs; these measurements do not isolate the code change. **Configuration differences** | Setting | Baseline | Candidate | | --- | --- | --- | | window.first_present | 39 | 40 | **Frame and GPU times (ms)** | Metric | Baseline | Candidate | Change | Change (%) | | --- | ---: | ---: | ---: | ---: | | frame_ms.p50 | 103.957 | 103.526 | -0.431 | -0.415 | | frame_ms.p90 | 107.464 | 108.721 | +1.257 | +1.170 | | frame_ms.p99 | 109.753 | 120.332 | +10.579 | +9.639 | | frame_ms.max | 109.753 | 120.332 | +10.579 | +9.639 | | mean_frame_ms | 104.452 | 104.469 | +0.017 | +0.016 | | gpu_busy_ms_per_present | 5.263 | 5.217 | -0.046 | -0.874 | **Top phases (ms per frame)** | Metric | Baseline | Candidate | Change | Change (%) | | --- | ---: | ---: | ---: | ---: | | Driver.Draw | 2.431 | 2.428 | -0.003 | -0.123 | | Driver.Draw.shader_compile_and_link | 1.442 | 1.457 | +0.015 | +1.040 | | Driver.Packet | 3.081 | 3.059 | -0.022 | -0.714 | | Driver.Packet.draw | 2.485 | 2.482 | -0.003 | -0.121 | | Driver.Present | 0.839 | 0.862 | +0.023 | +2.741 | | Driver.Present.queue_present | 0.584 | 0.610 | +0.026 | +4.452 | | Shader.DrawStage | 0.759 | 0.795 | +0.036 | +4.743 | | Vulkan.QueuePresent | 0.583 | 0.608 | +0.025 | +4.288 | </details> <details> <summary><code>tools/trace_digest.py</code> output (first capture of each side; all digests are in the evidence archive)</summary> `rv21-a3-main-6447` **seconds 20:8** from present 39: 77 presents, frame p50 104.0 / p90 107.5 / p99 109.8 / max 109.8 ms, GPU busy 5.3 ms per present NVIDIA GeForce RTX 3070 Laptop GPU, NVIDIA 617.42, Windows 10.0.26300, 1920x1080, commit 6447ed1ed7fd, dropped: no ```json {"commit":"6447ed1ed7fd","dirty":false,"env":{"APS5_TRACE_EVENTS":"1048576","APS5_TRACE_SECONDS":"20:8"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","resolution":"1920x1080","window":{"spec":"seconds 20:8","first_present":39,"ms":8042.799},"presents":77,"frame_ms":{"p50":103.957,"p90":107.464,"p99":109.753,"max":109.753},"gpu_busy_ms_per_present":5.263,"worker_busy_pct":{"queue worker 0x0":2.995},"top_phases_ms_per_frame":{"Driver.Packet":3.081,"Driver.Packet.draw":2.485,"Driver.Draw":2.431,"Driver.Draw.shader_compile_and_link":1.442,"Driver.Present":0.839,"Shader.DrawStage":0.759,"Driver.Present.queue_present":0.584,"Vulkan.QueuePresent":0.583},"trace_dropped":false,"trace":"aps5-trace-6447ed1ed7fd-3204.json.gz"} ``` **Slowest frames** (largest slices inside each, inclusive) - present 66: 109.8 ms at 2839 ms: Driver.WorkerWait (queue worker 0x0) 106.2, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 106.1, batch (gpu) 5.3, Driver.Packet (queue worker 0x0) 2.5 - present 69: 109.4 ms at 3154 ms: Driver.WorkerWait (queue worker 0x0) 105.4, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 105.3, batch (gpu) 5.3, Driver.Packet (queue worker 0x0) 2.9 - present 59: 108.1 ms at 2104 ms: Driver.WorkerWait (queue worker 0x0) 104.5, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 104.5, batch (gpu) 5.3, Driver.Packet (queue worker 0x0) 2.4 **Threads** (ms per frame) | thread | busy | wait | untraced | in slices < 20 us | largest | |---|---|---|---|---|---| | queue worker 0x0 | 2.5 (2 %) | 101.0 (97 %) | 1.0 | 3.8 | Driver.Packet 2.5 | | presenter | 0.8 (1 %) | 0.0 (0 %) | 103.6 | 0.1 | Driver.Present 0.8 | | gpu | 5.3 (5 %) | 0.0 (0 %) | 99.2 | 0.0 | batch 5.3 | `rv21-a4-7470` **seconds 20:8** from present 40: 77 presents, frame p50 103.5 / p90 108.7 / p99 120.3 / max 120.3 ms, GPU busy 5.2 ms per present NVIDIA GeForce RTX 3070 Laptop GPU, NVIDIA 617.42, Windows 10.0.26300, 1920x1080, commit 7c345db5a501, dropped: no ```json {"commit":"7c345db5a501","dirty":false,"env":{"APS5_TRACE_EVENTS":"1048576","APS5_TRACE_SECONDS":"20:8"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","resolution":"1920x1080","window":{"spec":"seconds 20:8","first_present":40,"ms":8044.109},"presents":77,"frame_ms":{"p50":103.526,"p90":108.721,"p99":120.332,"max":120.332},"gpu_busy_ms_per_present":5.217,"worker_busy_pct":{"queue worker 0x0":2.973},"top_phases_ms_per_frame":{"Driver.Packet":3.059,"Driver.Packet.draw":2.482,"Driver.Draw":2.428,"Driver.Draw.shader_compile_and_link":1.457,"Driver.Present":0.862,"Shader.DrawStage":0.795,"Driver.Present.queue_present":0.61,"Vulkan.QueuePresent":0.608},"trace_dropped":false,"trace":"aps5-trace-7c345db5a501-34076.json.gz"} ``` **Slowest frames** (largest slices inside each, inclusive) - present 105: 120.3 ms at 6767 ms: Driver.WorkerWait (queue worker 0x0) 116.0, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 115.9, batch (gpu) 5.3, Driver.Packet (queue worker 0x0) 3.2 - present 107: 111.9 ms at 6999 ms: Driver.WorkerWait (queue worker 0x0) 107.7, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 107.6, batch (gpu) 5.3, Driver.Packet (queue worker 0x0) 3.1 - present 106: 111.5 ms at 6887 ms: Driver.WorkerWait (queue worker 0x0) 107.4, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 107.3, batch (gpu) 5.3, Driver.Packet (queue worker 0x0) 3.1 **Threads** (ms per frame) | thread | busy | wait | untraced | in slices < 20 us | largest | |---|---|---|---|---|---| | queue worker 0x0 | 2.4 (2 %) | 101.0 (97 %) | 1.1 | 3.9 | Driver.Packet 2.4 | | presenter | 0.8 (1 %) | 0.0 (0 %) | 103.6 | 0.1 | Driver.Present 0.9 | | gpu | 5.3 (5 %) | 0.0 (0 %) | 99.2 | 0.0 | batch 5.3 | </details> ### Where it helps About 105 resident releases per frame go through `WindowsMappings::reset`. | Measured | main `2185dbf92e` | main + series | |---|---:|---:| | `WindowsMappings::reset (release)` calls per frame | 105.1 | 95.9 | | `WindowsMappings::reset (release)` µs per call | 32.40 | 27.89 | | `WindowsMappings::reset (release)` ms per frame | 3.41 | 2.67 | | VirtualQuery calls per frame | 992.1 | 575.4 | Counters come from a local probe build that is not part of this PR (`review-probe.patch` in the evidence archive): the same counters and timers were inserted into main `2185dbf92e` and into main with all eleven series PRs merged (#7464 in its rebased form), anchored on function definitions present in both trees. Runs were in the mirrored order main, series with #7464 reduced to its wake only, series, series, reduced series, main, in the scene above with `APS5_PROFILE_DRAW=1`; values are medians of two runs over the same 8-second window as the trace, starting 20 s after the first flip, per flip. These runs carry profiling overhead and are not used for FPS. Each optimised function below is changed by this PR only; counters show where the work goes, not an isolated FPS gain. `reset` timing differs between the two series variants measured that night (19.1 µs per call in the other one), so treat the per-call time as a range; the `VirtualQuery` count is the direct effect. ### Other homebrew checks | Workload | Control FPS | This topic FPS | Scope | |---|---:|---:|---| | vkQuake | 54.590 | 57.519 | Moving demo; small differences need matched camera repeats | | Syobon Action | 30.276 | 30.288 | Approximately 30-FPS cap | | Middle Ages Ping Pong | 59.940 | 59.941 | Approximately 60-FPS cap | UI Lab: the 21 default concepts were rendered and visually reviewed in a navigation cycle for this topic. Artwork was present; this covers default navigation, not all themes or every widget interaction. Known baseline rendering issue: vkQuake still has intermittent flickering and an intermittently black floor on main and the tested performance branches. These changes do not fix it. Yamagi Quake II gameplay stops at unsupported last-provoking-vertex flat interpolation, and UZDoom at unsupported clip/cull-distance handling on the baseline; neither supplies a valid gameplay FPS comparison. ### Dependencies, series and overlap The project overlap scan found no conflicting open PR for this topic. The fast path only covers a complete ordinary resident release; no GPU import lifetime or partial-release semantics are changed. The project overlap scan compared the local topics against 785 open PRs and checked merges into main `e5c2b3c325e485ba7fd417c47c46f48aa2c89115`. This topic merges cleanly in that snapshot. Some other PRs already conflict with main, so the tool cannot compare all their shared-file hunks; the full report is retained with the common series evidence package. No exact duplicate was identified in the inspected implementations. This is not a certification that every conflicting foreign branch is composition-tested. Conventions and whitespace checks passed for the tested topic range. The benchmark base remains pinned for comparability; this is not a fresh-current-main build/test claim. Measurements and focused tests refer to the pinned source revisions above; no full-suite CI run is claimed. Re-checked on 2026-10-21: this head still merges cleanly into main `2185dbf92e`. #6658, which the earlier combined runs carried, merged into main on 2026-10-20. ### Combined series result Re-measured on 2026-10-21 on current main `2185dbf92e` (Windows 11 Pro build 26300, Ryzen 7 5800H, RTX 3070 Laptop GPU, NVIDIA 617.42, WinLibs GCC 15.2.0 r7, Release; SuperTuxKart (PPSA69421) tutorial prompt over the main menu, 1920x1080 internal rendering in a maximized 2560x1369 window, warm shader caches, audio muted, no input; `APS5_TRACE_SECONDS=20:8` with `APS5_TRACE_EVENTS=1048576`, console output not redirected, no profiling switches). Runs in the order A-B-C-D-D-C-B-A, two per configuration; FPS is presents over the 8-s window. | Configuration | FPS, run 1 / run 2 | |---|---| | main `2185dbf92e` | 9.18 / 9.03 | | main + #7464 + #7465 | 20.85 / 22.02 | | main + all eleven PRs of the series | 29.01 / 28.70 | #7464 and #7465 make the largest step together: the title's per-frame host imports disappear (see their PRs). With #7464 reduced to its CPU-label wake only, the whole series measured 10.07 / 9.01 FPS against main 9.24 / 9.30 in a separate block of the same session. Combined numbers are not the gain of any single PR. The combined builds are local merges of the published (#7465-#7470, #7472, #7474) and rebased (#7464, #7471, #7473) heads into main `2185dbf92e`; the commits in their summary lines are those merges, not pushed. Summary lines, traces and digests: [series-evidence.zip](https://github.com/Dripl1x/AnyPS5/releases/download/review-20261021/series-evidence.zip). ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on pinned main `6447ed1ed7fd`; merges cleanly into current main `2185dbf92e` (git merge-tree, 2026-10-21); related overlaps are listed above - [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) - [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 (library-only change; game test hardware above) - [x] AI-assisted: yes The current head includes the review correction and validation recorded below. ### Series index These are the ten performance topics from the same profiling effort, followed by a separate UI Lab cache-preservation fix. Membership in the series does not imply a dependency. | Item | Pull request | Required dependency | |---|---|---| | 01 | [#7464: perf(agc): keep unimported label stores on the CPU](https://github.com/boykopovar/AnyPS5/pull/7464) | #6658 | | 02 | [#7465: perf(agc): defer small host imports until first GPU use](https://github.com/boykopovar/AnyPS5/pull/7465) | none | | 03 | [#7466: perf(agc): validate host imports through their registered owner](https://github.com/boykopovar/AnyPS5/pull/7466) | none | | 04 | [#7467: perf(libc): avoid repeated Windows path component scans](https://github.com/boykopovar/AnyPS5/pull/7467) | none | | 05 | [#7468: perf(libkernel): find direct-memory aliases through the physical index](https://github.com/boykopovar/AnyPS5/pull/7468) | none | | 06 | [#7469: perf(libkernel): find free direct-memory ranges in allocation order](https://github.com/boykopovar/AnyPS5/pull/7469) | none | | 07 | [#7470: perf(libc): release exact resident mappings without repeated queries](https://github.com/boykopovar/AnyPS5/pull/7470) | none | | 08 | [#7471: perf(libc): collect resident writes directly into the output buffer](https://github.com/boykopovar/AnyPS5/pull/7471) | none | | 09 | [#7472: perf(libc): reuse saved direct-memory buffers when unreferenced](https://github.com/boykopovar/AnyPS5/pull/7472) | none | | 10 | [#7473: perf(libc): skip write-watch queries for proven clean resident ranges](https://github.com/boykopovar/AnyPS5/pull/7473) | #7471 | | 11 | [#7474: fix(agc): preserve pipeline caches on immediate guest exit](https://github.com/boykopovar/AnyPS5/pull/7474) | none | ### Reproduction evidence [Series traces, summary lines, module hashes, focused-test logs and UI contact sheets](https://github.com/Dripl1x/AnyPS5/releases/tag/performance-series-20261018). Game measurements use the pinned base and source revisions described above; assets contain no game binaries. Update of 2026-10-21: [7470-evidence.zip](https://github.com/Dripl1x/AnyPS5/releases/download/review-20261021/7470-evidence.zip) (traces, summary lines, `trace_digest.py` and `performance_compare.py` output, loaded-module hashes), counters [where.json](https://github.com/Dripl1x/AnyPS5/releases/download/review-20261021/where.json) and the probe [review-probe.patch](https://github.com/Dripl1x/AnyPS5/releases/download/review-20261021/review-probe.patch) with [probe_window.py](https://github.com/Dripl1x/AnyPS5/releases/download/review-20261021/probe_window.py). ### Review correction (2026-10-18) Thanks for checking the lifecycle path and pointing out the skipped validation. Fixed in `7c345db5a501`: the exact resident path now checks the actual AllocationBase, MEM_PRIVATE type and complete allocation extent before evicting any metadata. Added a valid release/remap test with split host protections and three mismatched-metadata tests. Each mismatched case fails against the previous PR implementation (`97c11bcb94`), which loses the resident metadata before rejecting the release, and passes on main and on this PR. Correction of 2026-10-21: the earlier "all four pass" was not a run of the project's test target. That target did not link with the supported WinLibs toolchain, because it did not link `libc`, which provides `__gxx_personality_v0`. Its valid case also never reached the exact-run path: the mapping crossed a 2-MiB boundary and split into two resident runs. Both are fixed in `b5bb956530`. All four tests now pass through `ctest -R windows_mappings_release`, and a temporary probe shows that both `Reset` calls of the valid case take the exact-run path ([reply of 2026-10-21](https://github.com/boykopovar/AnyPS5/pull/7470#issuecomment-6305065605)). I am not claiming an isolated lifecycle speedup from the noisy timing results. The three corrections (#7467, #7469 and #7470) were also checked together against the previous series in a same-scene SuperTuxKart A-B-B-A repeat: 32.680 -> 32.722 FPS (1920x1080 internal rendering, maximized 2560x1369 client, warm caches, trace seconds 20-28, RTX 3070 Laptop/NVIDIA 617.42). Focus and loaded-module hashes were verified. This combined check does not assign a separate FPS gain to this PR. #7473 is being validated separately.
wachi35676 commented 2026-10-18 12:32:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by wachi35676 on 2026-10-18T12:32:24Z.


Windows test: a 2 MiB resident direct mapping, map + write + sceKernelMunmap cycle. main takes 1220–1301 µs and this PR 1283–1399 µs. That is no measurable difference, consistent with the -0.99% SuperTuxKart capture in the description.

The fast path skips the AllocationBase/MEM_PRIVATE checks, which throw on main when the metadata disagrees, and the PR adds no test for that. The 462 related tests pass.

AI-assisted: yes (Claude Code); results above were run on this machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6249953573 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7470#issuecomment-6249953573). Originally posted by [wachi35676](https://github.com/wachi35676) on 2026-10-18T12:32:24Z. --- Windows test: a 2 MiB resident direct mapping, map + write + `sceKernelMunmap` cycle. `main` takes 1220–1301 µs and this PR 1283–1399 µs. That is no measurable difference, consistent with the -0.99% SuperTuxKart capture in the description. The fast path skips the `AllocationBase`/`MEM_PRIVATE` checks, which throw on `main` when the metadata disagrees, and the PR adds no test for that. The 462 related tests pass. AI-assisted: yes (Claude Code); results above were run on this machine.
Dripl1x commented 2026-10-18 13:14:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dripl1x on 2026-10-18T13:14:50Z.


@wachi35676 Thanks for checking the lifecycle path and pointing out the skipped validation. Fixed in 7c345db5a501: the exact resident path now checks the actual AllocationBase, MEM_PRIVATE type and complete allocation extent before evicting any metadata. Added a valid release/remap test with split host protections and three mismatched-metadata tests. All four pass; each mismatched case fails against the previous PR implementation because it loses the resident metadata before rejecting the release. I am not claiming an isolated lifecycle speedup from the noisy timing results.

The three corrections (#7467, #7469 and #7470) were also checked together against the previous series in a same-scene SuperTuxKart A-B-B-A repeat: 32.680 -> 32.722 FPS (1920x1080 internal rendering, maximized 2560x1369 client, warm caches, trace seconds 20-28, RTX 3070 Laptop/NVIDIA 617.42). Focus and loaded-module hashes were verified. This combined check does not assign a separate FPS gain to this PR. #7473 is being validated separately.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6250353351 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7470#issuecomment-6250353351). Originally posted by [Dripl1x](https://github.com/Dripl1x) on 2026-10-18T13:14:50Z. --- @wachi35676 Thanks for checking the lifecycle path and pointing out the skipped validation. Fixed in `7c345db5a501`: the exact resident path now checks the actual AllocationBase, MEM_PRIVATE type and complete allocation extent before evicting any metadata. Added a valid release/remap test with split host protections and three mismatched-metadata tests. All four pass; each mismatched case fails against the previous PR implementation because it loses the resident metadata before rejecting the release. I am not claiming an isolated lifecycle speedup from the noisy timing results. The three corrections (#7467, #7469 and #7470) were also checked together against the previous series in a same-scene SuperTuxKart A-B-B-A repeat: 32.680 -> 32.722 FPS (1920x1080 internal rendering, maximized 2560x1369 client, warm caches, trace seconds 20-28, RTX 3070 Laptop/NVIDIA 617.42). Focus and loaded-module hashes were verified. This combined check does not assign a separate FPS gain to this PR. #7473 is being validated separately.
github-actions[bot] commented 2026-10-18 13:36:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-18T13:36:07Z.


Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 5021 core/libs/prx/libc/CMakeLists.txt
PR 6044 core/libs/prx/libc/CMakeLists.txt
PR 6819 core/libs/prx/libc/CMakeLists.txt
PR 7081 core/libs/prx/libc/CMakeLists.txt
PR 7201 core/libs/prx/libc/CMakeLists.txt
PR 7715 core/libs/prx/libc/CMakeLists.txt
PR 8150 core/libs/prx/libc/CMakeLists.txt
PR 8352 core/libs/prx/libc/CMakeLists.txt
PR 8520 core/libs/prx/libc/CMakeLists.txt
PR 8658 core/libs/prx/libc/CMakeLists.txt
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6250555909 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7470#issuecomment-6250555909). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-18T13:36:07Z. --- <!-- pr-overlap --> Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `core/libs/prx/libc/CMakeLists.txt` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/prx/libc/CMakeLists.txt` | | [PR 6819](https://www.github.com/boykopovar/AnyPS5/pull/6819) | `core/libs/prx/libc/CMakeLists.txt` | | [PR 7081](https://www.github.com/boykopovar/AnyPS5/pull/7081) | `core/libs/prx/libc/CMakeLists.txt` | | [PR 7201](https://www.github.com/boykopovar/AnyPS5/pull/7201) | `core/libs/prx/libc/CMakeLists.txt` | | [PR 7715](https://www.github.com/boykopovar/AnyPS5/pull/7715) | `core/libs/prx/libc/CMakeLists.txt` | | [PR 8150](https://www.github.com/boykopovar/AnyPS5/pull/8150) | `core/libs/prx/libc/CMakeLists.txt` | | [PR 8352](https://www.github.com/boykopovar/AnyPS5/pull/8352) | `core/libs/prx/libc/CMakeLists.txt` | | [PR 8520](https://www.github.com/boykopovar/AnyPS5/pull/8520) | `core/libs/prx/libc/CMakeLists.txt` | | [PR 8658](https://www.github.com/boykopovar/AnyPS5/pull/8658) | `core/libs/prx/libc/CMakeLists.txt` |
github-actions[bot] commented 2026-10-18 21:44:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-18T21:44:48Z.


This pull request is labeled perf, so it needs the summary line of a capture on main and one with the change, from the same title, scene and machine, as the Performance report form asks. Please paste both aps5-summary.jsonl lines, attach the two traces and add the output of tools/trace_digest.py.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6255522676 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7470#issuecomment-6255522676). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-18T21:44:48Z. --- <!-- pr-labels-perf --> This pull request is labeled `perf`, so it needs the summary line of a capture on `main` and one with the change, from the same title, scene and machine, as the Performance report form asks. Please paste both `aps5-summary.jsonl` lines, attach the two traces and add the output of `tools/trace_digest.py`.
Dripl1x commented 2026-10-20 23:34:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dripl1x on 2026-10-20T23:34:23Z.


Updated the description: before/after summary lines from the same machine and SuperTuxKart scene (main 6447ed1ed7fd 9.57 / 9.62 FPS, this PR 7c345db5a501 9.57 FPS, so no FPS claim), trace_digest.py and performance_compare.py output, and probe counters that show where this change saves work in that scene: about 105 resident releases per frame go through WindowsMappings::reset; VirtualQuery calls drop from 992 to 575 per frame, and reset from 32.4 to about 27.9 µs per call (19.1 µs in the other series variant measured that night, so read it as a range). Traces, digests and the probe patch are in the evidence release. The head is unchanged and still merges cleanly into current main.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6304200362 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7470#issuecomment-6304200362). Originally posted by [Dripl1x](https://github.com/Dripl1x) on 2026-10-20T23:34:23Z. --- Updated the description: before/after summary lines from the same machine and SuperTuxKart scene (main `6447ed1ed7fd` 9.57 / 9.62 FPS, this PR `7c345db5a501` 9.57 FPS, so no FPS claim), `trace_digest.py` and `performance_compare.py` output, and probe counters that show where this change saves work in that scene: about 105 resident releases per frame go through `WindowsMappings::reset`; `VirtualQuery` calls drop from 992 to 575 per frame, and `reset` from 32.4 to about 27.9 µs per call (19.1 µs in the other series variant measured that night, so read it as a range). Traces, digests and the probe patch are in the [evidence release](https://github.com/Dripl1x/AnyPS5/releases/tag/review-20261021). The head is unchanged and still merges cleanly into current main. AI-assisted: yes (Claude Code)
oneandonlydean commented 2026-10-21 00:16:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-21T00:16:28Z.


@Dripl1x Thanks. The fast path reads correctly to me: for a run that is exactly one private allocation, it does the same evict plus VirtualFree(MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER) as the generic loop, and the generic loop's split and coalesce afterwards have nothing to do.

One test ask. CheckValidRelease doesn't reach the new success path. Reserve(nullptr, 2 MiB) returns a base that is usually not 2 MiB aligned, and resident runs stop at every 2 MiB chunk boundary, so the mapping becomes two runs and run->second.end != end sends both Reset calls through the old loop. I printed the runs at each reset (built with llvm-mingw and run under wine): the base was 0xe0000 into a chunk, with runs [+0, +0x120000) and [+0x120000, +0x200000). The three mismatch cases do enter the new branch, but they also fail on main, so every case in the file passes with or without the change.

Could you make the valid case one run, e.g. reserve 4 MiB, map 2 MiB at the 2 MiB-aligned address inside it, then Reset and remap as now? With that change, the fast path ran in both resets and the data checks held. Under wine, though, so the Windows CI run is the real proof.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6304766700 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7470#issuecomment-6304766700). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-21T00:16:28Z. --- @Dripl1x Thanks. The fast path reads correctly to me: for a run that is exactly one private allocation, it does the same `evict` plus `VirtualFree(MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER)` as the generic loop, and the generic loop's split and coalesce afterwards have nothing to do. One test ask. `CheckValidRelease` doesn't reach the new success path. `Reserve(nullptr, 2 MiB)` returns a base that is usually not 2 MiB aligned, and resident runs stop at every 2 MiB chunk boundary, so the mapping becomes two runs and `run->second.end != end` sends both `Reset` calls through the old loop. I printed the runs at each `reset` (built with llvm-mingw and run under wine): the base was 0xe0000 into a chunk, with runs `[+0, +0x120000)` and `[+0x120000, +0x200000)`. The three mismatch cases do enter the new branch, but they also fail on `main`, so every case in the file passes with or without the change. Could you make the valid case one run, e.g. reserve 4 MiB, map 2 MiB at the 2 MiB-aligned address inside it, then `Reset` and remap as now? With that change, the fast path ran in both resets and the data checks held. Under wine, though, so the Windows CI run is the real proof.
Dripl1x commented 2026-10-21 00:39:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dripl1x on 2026-10-21T00:39:06Z.


@oneandonlydean Thanks, confirmed on Windows 11 with WinLibs GCC 15.2.0 r7. With the old test both Reset calls went through the generic loop: in my runs the 2-MiB reservation never started on a 2-MiB boundary either.

Fixed in b5bb956530:

  • The valid case now reserves 4 MiB and maps 2 MiB at the 2-MiB-aligned address inside it. After each Map the test requires that the mapping is a single resident run (ResidentSpan of its last byte returns exactly the mapping), so it fails if the setup ever stops reaching the exact-run path. Cleanup coalesces the reservation's placeholders before releasing it.
  • Building it through CMake also showed that the test executable did not link with the supported toolchain. It throws exceptions, the libraries are compiled with -fno-asynchronous-unwind-tables, and __gxx_personality_v0 comes from libc, which the test did not link. It now links libc and uses configure_windows_unwind, like the other libc tests. The PR checks could not catch this because the windows CI job runs only on push. The description's earlier note that all four tests pass cannot have come from the project's CMake build with this toolchain, since that build could not link the old target. The run below is the first one through it.

A temporary probe (not part of the PR) counted VirtualQuery calls per Reset. Each combination ran three times, with the same result every time:

Test Header First Reset Second Reset
old main generic, 15 generic, 13
old this PR generic, 15 generic, 13
new main generic, 11 generic, 9
new this PR exact run, 5 exact run, 3

ctest -R windows_mappings_release passes 4/4. As you noted, the new test also passes on main: the exact-run path leaves the same state and only skips queries. So the test checks the precondition and the data, not a difference in behaviour.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6305065605 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7470#issuecomment-6305065605). Originally posted by [Dripl1x](https://github.com/Dripl1x) on 2026-10-21T00:39:06Z. --- @oneandonlydean Thanks, confirmed on Windows 11 with WinLibs GCC 15.2.0 r7. With the old test both `Reset` calls went through the generic loop: in my runs the 2-MiB reservation never started on a 2-MiB boundary either. Fixed in `b5bb956530`: - The valid case now reserves 4 MiB and maps 2 MiB at the 2-MiB-aligned address inside it. After each `Map` the test requires that the mapping is a single resident run (`ResidentSpan` of its last byte returns exactly the mapping), so it fails if the setup ever stops reaching the exact-run path. Cleanup coalesces the reservation's placeholders before releasing it. - Building it through CMake also showed that the test executable did not link with the supported toolchain. It throws exceptions, the libraries are compiled with `-fno-asynchronous-unwind-tables`, and `__gxx_personality_v0` comes from `libc`, which the test did not link. It now links `libc` and uses `configure_windows_unwind`, like the other libc tests. The PR checks could not catch this because the `windows` CI job runs only on push. The description's earlier note that all four tests pass cannot have come from the project's CMake build with this toolchain, since that build could not link the old target. The run below is the first one through it. A temporary probe (not part of the PR) counted `VirtualQuery` calls per `Reset`. Each combination ran three times, with the same result every time: | Test | Header | First `Reset` | Second `Reset` | |---|---|---|---| | old | main | generic, 15 | generic, 13 | | old | this PR | generic, 15 | generic, 13 | | new | main | generic, 11 | generic, 9 | | new | this PR | exact run, 5 | exact run, 3 | `ctest -R windows_mappings_release` passes 4/4. As you noted, the new test also passes on main: the exact-run path leaves the same state and only skips queries. So the test checks the precondition and the data, not a difference in behaviour.
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!7470
No description provided.