Repository navigation
perf(libc): collect resident writes directly into the output buffer - #7471
1 commit merged into
Conversation
Complete the publication checklist and series cross-links for boykopovar#7471. No source or test changes.
|
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 is equivalent by inspection: when A clean 2 MiB resident collect takes 1.68–1.90 µs on AI-assisted: yes (Claude Code); results above were run on this machine. |
|
@wachi35676 Thanks for checking the equivalence and running the related Windows tests. Agreed that the clean 2 MiB measurements are within noise on your machine; the change removes the intermediate copy, but those timings do not establish a repeatable isolated speedup. |
|
This pull request is labeled |
2f59a75 to
9d5f832
Compare
|
Rebased onto main AI-assisted: yes (Claude Code) |
b13183e
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 08/10; the UI Lab startup/cache fix follows as a separate eleventh PR. Each topic's measurements are distinguished from the combined result.
Collect writes from a stable resident mapping directly into the caller's output buffer. Preserve capacity, fresh-page accounting, unaligned starts and reset behavior while avoiding two temporary collections.
Tested
Rebased onto main
2185dbf92eon 2026-10-21; head9d5f8326bf(published head2f59a758d; the metadata-only commit is dropped). One conflict, at a test insertion point incore/libs/tests/GuestMemory.cpp, where main's two #7448 release tests and this PR's test now both stay. Windows 11 Pro build 26300, Ryzen 7 5800H, RTX 3070 Laptop GPU, NVIDIA 617.42, WinLibs GCC 15.2.0 r7, Release.guest_memoryandguest_mmap_fixed_anonymous3/3 each; conventions pass.3/3 memory/write-watch cases passed. The behavioral test also passes on main. Coverage includes capacities zero and one, output sentinels, unaligned starts, clear=false, retention of unreported dirty pages and a 2-MiB resident-run boundary.
SuperTuxKart captures: 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, order main, ..., this PR, ..., this PR, ..., main.rv21-b01-main2185dbf92e2185dbf92e8drv21-b10-main2185dbf92e2185dbf92e8drv21-b04-74719d5f8326bfc6rv21-b07-74719d5f8326bfc6No FPS change is claimed (9.46 / 9.41 against main 9.24 / 9.30).
Summary lines (main first, then this PR)
{"commit":"2185dbf92e8d","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","cpu":"AMD Ryzen 7 5800H with Radeon Graphics","cpu_threads":16,"memory_mib":64863,"title_id":"PPSA69421","title":"SuperTuxKart","content_version":"00.001.000","resolution":"1920x1080","window":{"spec":"seconds 20:8","first_present":29,"ms":8010.110},"presents":74,"frame_ms":{"p50":108.090,"p90":112.897,"p99":124.353,"max":124.353},"gpu_busy_ms_per_present":5.636,"worker_busy_pct":{"queue worker 0x0":2.746},"top_phases_ms_per_frame":{"Graphics.Draw":10.680,"Graphics.Draw.draw_and_resource_release":10.368,"Vulkan.DrawFromRecipe":8.398,"Graphics.DrawWithRecipe":8.370,"Graphics.DrawWithRecipe.draw_and_resource_release":8.357,"Driver.Packet":2.928,"Recorder.Submit":2.900,"Driver.Packet.draw":2.337},"trace_dropped":false,"trace":"aps5-trace-2185dbf92e8d-7560.json.gz"} {"commit":"2185dbf92e8d","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","cpu":"AMD Ryzen 7 5800H with Radeon Graphics","cpu_threads":16,"memory_mib":64863,"title_id":"PPSA69421","title":"SuperTuxKart","content_version":"00.001.000","resolution":"1920x1080","window":{"spec":"seconds 20:8","first_present":30,"ms":8062.500},"presents":75,"frame_ms":{"p50":104.995,"p90":119.916,"p99":129.746,"max":129.746},"gpu_busy_ms_per_present":5.551,"worker_busy_pct":{"queue worker 0x0":2.786},"top_phases_ms_per_frame":{"Graphics.Draw":10.928,"Graphics.Draw.draw_and_resource_release":10.606,"Vulkan.DrawFromRecipe":8.516,"Graphics.DrawWithRecipe":8.487,"Graphics.DrawWithRecipe.draw_and_resource_release":8.473,"Driver.Packet":2.954,"Recorder.Submit":2.930,"Driver.Packet.draw":2.376},"trace_dropped":false,"trace":"aps5-trace-2185dbf92e8d-46644.json.gz"} {"commit":"9d5f8326bfc6","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","cpu":"AMD Ryzen 7 5800H with Radeon Graphics","cpu_threads":16,"memory_mib":64863,"title_id":"PPSA69421","title":"SuperTuxKart","content_version":"00.001.000","resolution":"1920x1080","window":{"spec":"seconds 20:8","first_present":32,"ms":8035.594},"presents":76,"frame_ms":{"p50":104.207,"p90":112.738,"p99":126.658,"max":126.658},"gpu_busy_ms_per_present":5.540,"worker_busy_pct":{"queue worker 0x0":2.857},"top_phases_ms_per_frame":{"Graphics.Draw":10.084,"Graphics.Draw.draw_and_resource_release":9.769,"Vulkan.DrawFromRecipe":7.869,"Graphics.DrawWithRecipe":7.842,"Graphics.DrawWithRecipe.draw_and_resource_release":7.828,"Driver.Packet":2.978,"Recorder.Submit":2.906,"Driver.Packet.draw":2.414},"trace_dropped":false,"trace":"aps5-trace-9d5f8326bfc6-47024.json.gz"} {"commit":"9d5f8326bfc6","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","cpu":"AMD Ryzen 7 5800H with Radeon Graphics","cpu_threads":16,"memory_mib":64863,"title_id":"PPSA69421","title":"SuperTuxKart","content_version":"00.001.000","resolution":"1920x1080","window":{"spec":"seconds 20:8","first_present":30,"ms":8071.984},"presents":76,"frame_ms":{"p50":105.237,"p90":111.993,"p99":119.844,"max":119.844},"gpu_busy_ms_per_present":5.532,"worker_busy_pct":{"queue worker 0x0":2.792},"top_phases_ms_per_frame":{"Graphics.Draw":9.955,"Graphics.Draw.draw_and_resource_release":9.651,"Vulkan.DrawFromRecipe":7.596,"Graphics.DrawWithRecipe":7.566,"Graphics.DrawWithRecipe.draw_and_resource_release":7.554,"Driver.Packet":2.917,"Recorder.Submit":2.899,"Driver.Packet.draw":2.329},"trace_dropped":false,"trace":"aps5-trace-9d5f8326bfc6-42900.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-b01-mainseconds 20:8 from present 29: 74 presents, frame p50 108.1 / p90 112.9 / p99 124.4 / max 124.4 ms, GPU busy 5.6 ms per present
NVIDIA GeForce RTX 3070 Laptop GPU, NVIDIA 617.42, Windows 10.0.26300, 1920x1080, commit 2185dbf, dropped: no
{"commit":"2185dbf92e8d","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","cpu":"AMD Ryzen 7 5800H with Radeon Graphics","cpu_threads":16,"memory_mib":64863,"title_id":"PPSA69421","title":"SuperTuxKart","content_version":"00.001.000","resolution":"1920x1080","window":{"spec":"seconds 20:8","first_present":29,"ms":8010.11},"presents":74,"frame_ms":{"p50":108.09,"p90":112.897,"p99":124.353,"max":124.353},"gpu_busy_ms_per_present":5.636,"worker_busy_pct":{"queue worker 0x0":2.746},"top_phases_ms_per_frame":{"Graphics.Draw":10.68,"Graphics.Draw.draw_and_resource_release":10.368,"Vulkan.DrawFromRecipe":8.398,"Graphics.DrawWithRecipe":8.37,"Graphics.DrawWithRecipe.draw_and_resource_release":8.357,"Driver.Packet":2.928,"Recorder.Submit":2.9,"Driver.Packet.draw":2.337},"trace_dropped":false,"trace":"aps5-trace-2185dbf92e8d-7560.json.gz"}Slowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
rv21-b04-7471seconds 20:8 from present 32: 76 presents, frame p50 104.2 / p90 112.7 / p99 126.7 / max 126.7 ms, GPU busy 5.5 ms per present
NVIDIA GeForce RTX 3070 Laptop GPU, NVIDIA 617.42, Windows 10.0.26300, 1920x1080, commit 9d5f832, dropped: no
{"commit":"9d5f8326bfc6","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","cpu":"AMD Ryzen 7 5800H with Radeon Graphics","cpu_threads":16,"memory_mib":64863,"title_id":"PPSA69421","title":"SuperTuxKart","content_version":"00.001.000","resolution":"1920x1080","window":{"spec":"seconds 20:8","first_present":32,"ms":8035.594},"presents":76,"frame_ms":{"p50":104.207,"p90":112.738,"p99":126.658,"max":126.658},"gpu_busy_ms_per_present":5.54,"worker_busy_pct":{"queue worker 0x0":2.857},"top_phases_ms_per_frame":{"Graphics.Draw":10.084,"Graphics.Draw.draw_and_resource_release":9.769,"Vulkan.DrawFromRecipe":7.869,"Graphics.DrawWithRecipe":7.842,"Graphics.DrawWithRecipe.draw_and_resource_release":7.828,"Driver.Packet":2.978,"Recorder.Submit":2.906,"Driver.Packet.draw":2.414},"trace_dropped":false,"trace":"aps5-trace-9d5f8326bfc6-47024.json.gz"}Slowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Where it helps
Resident write collection in the SuperTuxKart scene (the series includes #7473, which skips clean resident runs; the counters below show the two together and do not separate this PR's direct output from #7473's skipped queries):
2185dbf92ecollectResidentcalls per framecollectResidentµs per callcollectResidentms 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.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
#7448 adds a physical-release lifetime test at the same GuestMemory.cpp insertion sites. Keep both independent tests when rebasing. Series item 10 builds on this direct-output collector.
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
main(2185dbf92e, rebased 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 published head adds publication metadata only; its complete source tree is identical to the tested snapshot above.
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: 7471-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.