perf(agc): keep full freed-block lists for a thread whose list is empty #9421
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9421"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-21T21:22:00Z.
Current validation status
Head
87b0ebbcf9is this PR's one commit onmain83462cc57d. Its tree (48b840958f) is identical to8dfa950103, the commit measured below, so these results apply to the head unchanged.Matched trace pair, Windows. Spirit of the Island (PPSA13934), title screen, 125 s per arm,
APS5_TRACE_SUMMARY_EVERY=10, steady state from 20 s. Radeon RX 6700 XT, AMD driver 32.0.21045.16010, Windows 11 22621. OnlylibSceAgcDriver.prxchanges between arms, and the arms alternate. Per arm, fromtools/trace_digest.py --jsonof itsaps5-summary.jsonl:libSceAgcDriver.prxsha256main83462cc57d, run 1290349533376…F148E07D196F…main, run 2290349533376…F148E07D196F…F148E07D196F…Every arm reports the same
VK_EXT_memory_budgetdevice-local heap budget (11235 MiB), with a sampled texture cache budget of 6714–6729 MiB, so the arms are not confounded by a varying heap budget. Frame time is about 10 % lower with this PR (111.4 against 99.9 ms, means of the per-run medians). Most of the gain is in theDriver.Packetphase (about 100 → 90 ms per present). The full comparison, including a sized-delete variant that measured within noise and is not part of this PR, is in this comment. The digests and traces are on disk and available on request. This is one scene on one GPU.Validation layer, paired.
agc_driver_host_allocator,guest_allocator_failuresandagc_driver_graphicsunderVK_LAYER_KHRONOS_validation(ANYPS5_REQUIRE_VULKAN=1, shader cache off), 3 runs per arm on the RX 6700 XT:main83462cc57d3/3 each run with 0 VUID lines; this PR87b0ebbcf93/3 each run with 0 VUID lines.The older measurements and test counts below are historical evidence from
0c6a5bd5938f/a5513aab37e4.What
On Windows, the driver's
operator newanddelete(HostAllocator.cpp, fromfc25ed9a7) keep up to 64 freed blocks per 16-byte size class per thread, or 16 blocks above 256 bytes. When blocks are made on one thread and deleted on another, two things happen at once:The queue worker and the draw committer do this on every draw.
With this change:
agc_driver_host_allocatorgains a case where one thread makes blocks while another deletes them at the same time. It checks:Why the depot, not deeper lists. I counted cache hits and misses per class, using local counters that are not part of this PR, on the Spirit of the Island title screen. All counts are per 10 s:
mainmainwith lists eight times deeper and classes up to 4 KiBOn
main, the deletes that overflowed to the heap matched the misses class for class. Deeper lists barely changed that, so the misses come from blocks crossing threads, not from bursts deeper than a list.Where the time went. A steady-state
APS5_SAMPLE_WORKERprofile of the same screen onmain(the 60–140 s difference of two snapshots) has 15.1 % of the queue worker's samples underAllocateand 8.0 % underoperator delete, almost all insideucrtbase/ntdll.Not a general committer win. tibzejoker measured GTA V (PPSA04264) on an RTX 4090 and i9-13900K: the committer's cost per commit is unchanged with this PR (39.3 → 39.1 µs, one run per tree), while
APS5_MIMALLOC=1lowers it to 34.8 µs. The gain above is measured on Spirit of the Island only.Not changed.
APS5_MIMALLOCopt-in measures 97 ms p50 on this screen, against about 108 ms onmainand 98.5–100.5 ms with this change.Tested
Historical validation before the rebase; the current state is under Current validation status above.
Windows 11 Enterprise 10.0.22621, AMD Radeon RX 6700 XT, AMD proprietary driver 26.10.1, Ryzen 9 5950X, WinLibs GCC 15.2 UCRT, Release.
Speed. Spirit of the Island (PPSA13934) 01.000.000, title screen with no input,
APS5_TRACE_SECONDS=80:20. Both runtimes used the same shader cache and save. Runs alternated main, change, main, change with no build running. Summary lines of the first pair:Notes on these lines:
dirtyis #8310's test change, applied locally only so thatmainbuilds with MinGW (the array-window test'salignas(65536)). It is not part of this PR.totals_full: false), so the summary lines cover the whole window.mainmainA second alternated set used
APS5_TRACE_SUMMARY_EVERY=10, averaging the 10 s intervals after loading. Private memory was read at 110 s:mainmainNo regression on a scene that is not worker-bound. Another Crab's Treasure (PPSA20423), main menu, warm cache, alternated the same way. It is vsync-limited, with the busiest worker 63–71 % busy:
mainmainTests.
agc_driver_host_allocatorpasses, 3 of 3 runs. The new case reports private bytes of 6.6–7.7 MB after round 4 and 5.9–6.6 MB after round 12.patched_libraries,agc_driver_image_array_window_past_layer_limit,agc_driver_sample_order,agc_driver_sample_order_grid_reference,agc_driver_sample_order_recipe_depth_locationsandagc_driver_tessellationfail the same way onmain0c6a5bd59on this machine.guest_raise_in_system_calltimed out under-j 16. Run alone it times out onmaintoo: 3 of 10 runs onmain, 2 of 10 with the change.tools/check_conventions.pypasses.Evidence. Traces (
aps5-trace-*.json.gz), summary files,trace_digest.pyoutput, sampler profiles, the allocation-count lines and the ctest log: 20261021-host-allocator-kept-lists-PPSA13934.tar.gz (27 MB).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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T04:58:21Z.
Review: DISMISSED
The allocator and cross-thread regression are narrowly scoped, and the description gives unusually useful alternating same-machine measurements, memory observations and baseline-failure accounting. The current evidence is nevertheless for an old base: head
a5513aabis 417 commits behind currentmain52439815(merge base0c6a5bd5). The performance summaries compare that old base with the change, and the repository requires a current-main branch and main/change measurements for performance claims.Please rebase onto current
main, rerun the focused allocator test and relevant regression suite, and repeat the same-scene main/change measurements with traces on that rebased head. Update the full-test failure list if it changes. The hosted product build and test jobs are skipped for this path; the 1,868/1,875 CTest result and GPU/title measurements are author-reported. I did not run the Windows-only allocator test locally because this environment has no matching Windows runtime/build.Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-22T05:40:31Z.
Thanks, @MarcZX10. This PR is rebased onto current
main: b79b563db6 on4a17c71757. It's the same change, with no conflicts. On that base:Allocator tests:
agc_driver_host_allocatorandguest_allocator_failurespass on Windows 11 22621 (WinLibs GCC 15.2.0 UCRT r7, Release).Full suite, CPU only: I ran the full
ctest -j 16 --timeout 300on the rebased head and onmain4a17c71757, with the Vulkan driver hidden so that no GPU test runs. The results are identical:main4a17c71757guest_raise_in_host_code(timeout)guest_raise_in_host_code(timeout)guest_raise_in_host_codealso times out intermittently onmainalone on this machine. #9610 covers its siblingguest_raise_exception, which runs past its 30 s budget here. Since #8310 merged, the full tree builds again with MinGW.Still to do: the same-scene main/change trace pair on this rebased head (Spirit of the Island title screen,
APS5_TRACE_SECONDS=80:20, alternating arms) and the GPU-enabled test arms. These are GPU and title runs, which wait for this machine's turn in the launch queue. I'll post the summaries and traces here, and update the failure list if the GPU arms change it.