Repository navigation
perf(agc): keep full freed-block lists for a thread whose list is empty - #9421
Conversation
MarcZX10
left a comment
There was a problem hiding this comment.
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 a5513aab is 417 commits behind current main 52439815 (merge base 0c6a5bd5). 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.
|
Thanks, @MarcZX10. This PR is rebased onto current
Still to do: the same-scene main/change trace pair on this rebased head (Spirit of the Island title screen, |
a5513aa to
b79b563
Compare
|
GTA V (PPSA04264) data for this PR, in the open world from a resumed save. It's the most CPU-bound title I have: the draw committer runs at 83-88 % busy. Machine: RTX 4090 616.92, i9-13900K, Windows 11, WinLibs GCC 15.2. Base.
So on this title the depot leaves the cost per commit where it was, within noise. Commits per 10 s follow where the save respawns, so the +5 % there is not a signal. mimalloc, the existing opt-in, cuts the cost per commit by about 11 %. Why I tested this PR: in the Story prologue on the base tree, For the opt-in debate on #6067 (no Windows frame-time win, worse p99 on paced titles): GTA is a counter-example among committer-bound titles. A 60 s trace window there went from 416 to 518 presents with AI-assisted: yes (Claude Code) |
|
Thank you, this is the counter-measurement the PR needed. On GTA V the depot leaves the committer's cost per commit where it was: 39.3 µs → 39.1 µs, within noise. So the gain it shows on Spirit of the Island ( Yes, the size histogram would help. Both of your guesses predict different things:
A histogram of request size, per thread, for |
The driver's operator new and delete keep up to 64 freed blocks per 16-byte size class per thread (16 above 256 bytes). When blocks are made on one thread and deleted on another, the deleting thread's list of that class fills and its further deletes go to the heap, while the making thread's list stays empty and its allocations go to the heap too. On the title screen of Spirit of the Island (PPSA13934), with the queue worker and the draw committer both busy, 14.8M of 58M allocations up to 1 KiB in 10 s missed the cache, and the deletes that overflowed to the heap matched the misses class for class. Lists eight times deeper and classes up to 4 KiB still missed 13.7M times, so the misses are blocks crossing threads, not bursts deeper than a list. A delete that finds its thread's list of the class full now hands that whole list to a per-class depot and starts a new one; an allocation that finds its thread's list empty takes a list from the depot before going to the heap. Each depot keeps at most eight lists behind an SRW lock, about 5 MiB over all classes; a full list past that still goes to the heap block by block, as before. With this, 0.44M of 66M allocations up to 1 KiB in 10 s miss on the same screen. A kept list is linked through its first block's second word, so every class (16 bytes and up) can hold it. agc_driver_host_allocator gains a case where one thread makes blocks that another deletes at the same time, checking their bytes up to the delete and that private bytes stay flat over 12 rounds of 200k blocks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Rebased onto |
b79b563 to
87b0ebb
Compare
|
New paired A/B on Windows. Same machine, scene and runtime as the earlier depot runs; only Setup: Spirit of the Island (PPSA13934), title-screen scene, 125 s per arm,
Frame time is about 10% lower with this PR: 111.4 ms against 99.9 ms, the means of the per-run medians.
The first The sized-delete variant measures within noise of this PR. It gives no further gain in this scene, so I'm not proposing it. This is one scene on one GPU. It doesn't contradict @tibzejoker's GTA V result, which showed no change in that title. Traces are on disk and available on request. |
Dismissing a stale review: the requested changes were addressed after it (new head and/or updated description with the asked-for runs) and the merge queue blocks on it. Please request changes again if anything is still open.
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, from fc25ed9) 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:{"commit":"0c6a5bd5938f","dirty":true,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"80:20"},"gpu":"AMD Radeon RX 6700 XT","driver":"AMD proprietary driver 26.10.1 (AMD proprietary shader compiler)","os":"Windows 10.0.22621","cpu":"AMD Ryzen 9 5950X 16-Core Processor","cpu_threads":32,"memory_mib":65457,"title_id":"PPSA13934","title":"Spirit of the Island","content_version":"01.000.000","resolution":"1920x1080","window":{"spec":"seconds 80:20","first_present":1397,"ms":20098.806},"presents":181,"frame_ms":{"p50":110.963,"p90":113.285,"p99":117.065,"max":118.558},"gpu_busy_ms_per_present":52.451,"worker_busy_pct":{"queue worker 0x0":91.516},"top_phases_ms_per_frame":{"Driver.Packet":101.133,"Driver.Packet.draw":85.037,"Driver.Draw":83.365,"Graphics.Draw":69.569,"Driver.Draw.shader_compile_and_link":61.316,"Graphics.Draw.draw_and_resource_release":48.851,"Shader.DrawStage":47.732,"Shader.DrawStage.materialize":27.109},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":3.947,"events_lost":1083461,"totals_full":false},"draw committer":{"events_full_after_s":16.615,"events_lost":55911,"totals_full":false}},"trace":"aps5-trace-0c6a5bd5938f-31300.json.gz"} {"commit":"a5513aab37e4","dirty":true,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"80:20"},"gpu":"AMD Radeon RX 6700 XT","driver":"AMD proprietary driver 26.10.1 (AMD proprietary shader compiler)","os":"Windows 10.0.22621","cpu":"AMD Ryzen 9 5950X 16-Core Processor","cpu_threads":32,"memory_mib":65457,"title_id":"PPSA13934","title":"Spirit of the Island","content_version":"01.000.000","resolution":"1920x1080","window":{"spec":"seconds 80:20","first_present":1450,"ms":20049.537},"presents":203,"frame_ms":{"p50":98.507,"p90":101.066,"p99":105.849,"max":106.631},"gpu_busy_ms_per_present":48.270,"worker_busy_pct":{"queue worker 0x0":91.550},"top_phases_ms_per_frame":{"Driver.Packet":89.805,"Driver.Packet.draw":73.783,"Driver.Draw":72.177,"Graphics.Draw":68.870,"Driver.Draw.shader_compile_and_link":53.037,"Graphics.Draw.draw_and_resource_release":47.931,"Shader.DrawStage":42.179,"Shader.DrawStage.materialize":22.724},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":4.086,"events_lost":1016952,"totals_full":false},"draw committer":{"events_full_after_s":14.886,"events_lost":90248,"totals_full":false}},"trace":"aps5-trace-a5513aab37e4-546624.json.gz"}Notes on these lines:
dirtyis test(agc): align the array window test's texels at run time #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 onmain0c6a5bd on 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)