Repository navigation
perf(libc): release exact resident mappings without repeated queries - #7470
Conversation
Complete the publication checklist and series cross-links for boykopovar#7470. No source or test changes.
|
Windows test: a 2 MiB resident direct mapping, map + write + The fast path skips the AI-assisted: yes (Claude Code); results above were run on this machine. |
|
@wachi35676 Thanks for checking the lifecycle path and pointing out the skipped validation. Fixed in 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. |
|
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.
|
|
This pull request is labeled |
|
Updated the description: before/after summary lines from the same machine and SuperTuxKart scene (main AI-assisted: yes (Claude Code) |
|
@Dripl1x Thanks. The fast path reads correctly to me: for a run that is exactly one private allocation, it does the same One test ask. 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 |
… one run The test throws exceptions but did not link libc, so with -fno-asynchronous-unwind-tables it failed to link (no __gxx_personality_v0) on the supported WinLibs toolchain; the Windows CI job does not run on pull requests. The valid case now maps 2 MiB at a 2-MiB boundary, so the mapping is one resident run and both Reset calls take the exact-run path, and the test requires that run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@oneandonlydean Thanks, confirmed on Windows 11 with WinLibs GCC 15.2.0 r7. With the old test both Fixed in
A temporary probe (not part of the PR) counted
|
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:8withAPS5_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.rv21-a3-main-64476447ed1ed7fd6447ed1ed7fdrv21-a6-main-64476447ed1ed7fd6447ed1ed7fdrv21-a4-74707c345db5a501The 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
Configuration differences
Frame and GPU times (ms)
Top phases (ms per frame)
tools/trace_digest.pyoutput (first capture of each side; all digests are in the evidence archive)rv21-a3-main-6447seconds 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 6447ed1, 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)
Threads (ms per frame)
rv21-a4-7470seconds 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 7c345db, 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)
Threads (ms per frame)
Where it helps
About 105 resident releases per frame go through
WindowsMappings::reset.2185dbf92eWindowsMappings::reset (release)calls per frameWindowsMappings::reset (release)µs per callWindowsMappings::reset (release)ms per frameCounters come from a local probe build that is not part of this PR (
review-probe.patchin the evidence archive): the same counters and timers were inserted into main2185dbf92eand 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 withAPS5_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.resettiming 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; theVirtualQuerycount is the direct effect.Other homebrew checks
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:8withAPS5_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.2185dbf92e#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
6447ed1ed7fd; merges cleanly into current main2185dbf92e(git merge-tree, 2026-10-21); related overlaps are listed aboveNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)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.
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.pyandperformance_compare.pyoutput, 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 linklibc, 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 inb5bb956530. All four tests now pass throughctest -R windows_mappings_release, and a temporary probe shows that bothResetcalls 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.