Repository navigation
perf(agc): find a host import among the last ones found first - #8896
Conversation
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
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.
|
|
AMD/Linux data point: neutral on a title that does far more host-import work than Stray, and holds no queue worker at saturation. Setup
The two sides overlap: AI-assisted: yes (Claude Code); results above were run on this machine. |
HostImportFor walks the import map under the import mutex for every in-place vertex input, index buffer and label it serves, most of them for the same few buffers. It now first checks the last four imports a lookup found, while the map is the one they came from: the imports epoch moves with every retire and trim and the map's size with every insert. Imports in the map never overlap, so the one that contains the range is the map's answer. A hit counts its use as a map lookup does, so imports age out of their eviction protection after as many lookups as before. APS5_NO_RECENT_IMPORTS looks every import up in the map. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2d681c7 to
5da8601
Compare
|
I force-pushed a fix to this branch (2d681c7 → 5da8601). main's The cause: a lookup served from the recent imports counted one use, but a map lookup counts two (
I checked both commits cherry-picked onto main 853baf3, with the validation layers on. The old head fails AI-assisted: yes (analysis, fix and text with Claude Code; the test runs are from my machine). |
|
Protocol note on my measurement above (comment 6339022896): it does not meet the performance-report protocol's "do not redirect the log" rule. The game ran under AI-assisted: yes (Claude Code) |
|
A Windows regression run of
AI-assisted: yes (Claude Code) |
What
HostImportForwalks the import map (std::map<std::uint64_t, HostImport>,upper_boundthen one step back) under the import mutex for every range it serves. On Stray (PPSA02100) that is every in-place vertex input and index buffer of every draw, and every label write, about 12,000 lookups per frame, nearly all of them for the same few buffers. In my stack-sample profile of the draw committer on a build where the committer bounds the frame,HostImportForwas 4.7 % of the committer's samples, almost all of it in the map walk.A lookup now first checks the last four imports a lookup found (
recentImportsinHostImports, under the same mutex), and walks the map only when none of them contains the range:epochbefore the entry leaves the map,ClearHostImportsclears the map and bumps it, and every insert changes the map's size. SorecentEpoch == epoch && recentSize == imports.size()means no entry was added or removed since they were found.importRunAtretires the imports a new run covers before inserting it. So the one import that contains the range is the map's answer.lastUseas the map hit did.APS5_NO_RECENT_IMPORTS=1looks every import up in the map (row added todocs/dev/ENVIRONMENT.md).Tested
Linux (CachyOS, kernel 7.2.10, scx_lavd), Ryzen 9 9950X, RTX 3090 (NVIDIA 615.78.08), GCC 16.2.1, Release. Measured at 590a2b4747 on
main7e95bde; the head is the same change rebased ontomain3fb6a12 (only #7082's test line conflicted), and the tests below pass again on it.agc_host_import_retire_tests,RecentImportFollowsReplacement: a repeated lookup finds the same import, the heap grows, the grown run replaces the first import, and the next lookup of the first range must return the replacement. It passes with this change and fails against a copy whose cache ignores the epoch and size (it serves the retired import).VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_REQUIRE_VULKAN=1andANYPS5_NO_SHADER_CACHE=1, these pass with no VUIDs:agc_host_import_retire_tests,agc_host_import_sparse_tests,agc_driver_host_import_at_map_tests,agc_driver_host_import_teardown_tests,agc_driver_host_import_windows_testsandagc_driver_bda_device_tests.tools/check_conventions.py --base origin/mainpasses.tools/pr_overlap.py --branchfound one overlap, fix(agc): keep failed import handles out of cleanup #7082, which added its test at the same place inHostImportRetireHold.cpp'smain; it has since been merged, and the head is rebased over it. Of the pull requests it could not compare (they conflict withmain), perf(memory): restrict registry work to affected ranges #1324 and perf(libSceAgcDriver): keep storage surfaces tracked around unwatching host imports #4448 changeHostImportFor's lookup as well; whichever of these lands later needs a small rebase.Stray at the start of Dead City, stock
engine.ini, glibc, one run at a time, six rounds ofmain7e95bde, this change and a second candidate, with this change andmainfirst or last in alternate rounds, and onlyAPS5_TRACE_SECONDS=185:20set:main7e95bdeEach cell is frame p50 / GPU busy per present / the draw committer's busy time per frame, in ms, from
tools/trace_digest.py. Left out:mainrun after its build, which spent the window in the menus compiling shaders;main5f7e302 run I measured yesterday (1,196 ms, 99.6 %), and a plainmain7e95bde run fell into it later the same night (962 ms), so it is not something this change introduces.On
main, Stray in this scene is bound by queue worker 0 (97-98 % busy), and the committer is busy about 48 ms of a ~167 ms frame. So the change can't show in the frame time here, and the committer's time stays within the spread between runs. It pays where the committer bounds the frame. On my local stack (showcase/stray-stack), where it is,HostImportForwas 4.7 % of the committer's samples, and this change was worth +2.6 % FPS there (17.48 to 17.93, four balanced rounds, all four won).Traces, summaries and digests: https://github.com/teepean/AnyPS5/releases/tag/perf-recent-host-imports-20261021 (every run's
aps5-summary.jsonlanddigest.md, and the traces of the median pair and of the 0.9 FPS run).Summary lines of the median runs
main7e95bde:{"commit":"7e95bde794ae","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"185:20"},"gpu":"NVIDIA GeForce RTX 3090","driver":"NVIDIA 615.78.08","os":"Linux 7.2.10-1-cachyos","cpu":"AMD Ryzen 9 9950X 16-Core Processor","cpu_threads":32,"memory_mib":126359,"title_id":"PPSA02100","title":"Stray","content_version":"01.005.000","resolution":"3840x2160","window":{"spec":"seconds 185:20","first_present":3609,"ms":20107.641},"presents":122,"frame_ms":{"p50":166.122,"p90":205.840,"p99":213.640,"max":219.133},"gpu_busy_ms_per_present":52.716,"worker_busy_pct":{"queue worker 0x0":97.662,"queue worker 0x20":99.237},"top_phases_ms_per_frame":{"Driver.Packet":323.943,"Driver.Packet.memory_wait":163.095,"Driver.Packet.draw":99.874,"Driver.Draw":99.195,"Graphics.Draw":77.248,"Graphics.Draw.draw_and_resource_release":67.001,"Driver.Draw.shader_compile_and_link":66.556,"Shader.DrawStage":58.299},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":5.088,"events_lost":835942,"totals_full":false}},"trace":"aps5-trace-7e95bde794ae-1040149.json.gz"}this change:
{"commit":"590a2b4747d8","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"185:20"},"gpu":"NVIDIA GeForce RTX 3090","driver":"NVIDIA 615.78.08","os":"Linux 7.2.10-1-cachyos","cpu":"AMD Ryzen 9 9950X 16-Core Processor","cpu_threads":32,"memory_mib":126359,"title_id":"PPSA02100","title":"Stray","content_version":"01.005.000","resolution":"3840x2160","window":{"spec":"seconds 185:20","first_present":3635,"ms":20110.837},"presents":119,"frame_ms":{"p50":168.974,"p90":205.231,"p99":213.535,"max":218.555},"gpu_busy_ms_per_present":55.420,"worker_busy_pct":{"queue worker 0x0":97.709,"queue worker 0x20":99.132},"top_phases_ms_per_frame":{"Driver.Packet":332.048,"Driver.Packet.memory_wait":166.952,"Driver.Packet.draw":102.513,"Driver.Draw":101.829,"Graphics.Draw":79.728,"Graphics.Draw.draw_and_resource_release":69.020,"Driver.Draw.shader_compile_and_link":67.170,"Shader.DrawStage":58.645},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":4.707,"events_lost":856510,"totals_full":false},"draw committer":{"events_full_after_s":19.179,"events_lost":11519,"totals_full":false}},"trace":"aps5-trace-590a2b4747d8-1018458.json.gz"}Checklist
main; no other open PR implements the same functionsNotImplemented_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)🤖 Generated with Claude Code