Repository navigation
perf(agc): widen small epoch collects to their 64 KiB block on Windows - #6273
Conversation
|
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 ready for review whenever someone has time. It's a small change: one function in
I'm happy to rebase again, re-measure on current |
|
GTA V (PPSA04264), Windows 11, RTX 4090, i9-13900K. Where GTA's collects go. On main 3bbd232 + #9181 + #9159 (GTA needs both in the open world), one ~8 min run had 11.8M collect walks covering 5.08 TB, 34.2 s in total, plus 74M collect-memo hits. That is ~430 KiB per walk on average, so most of the time is in large walks, which this PR does not widen. An older profile agrees: on main 47a266c + #6488 + #6848 (10-17), GetWriteWatch collects took ~5 % of the committer. I have no counter for walks of 64 KiB or less, so GTA may gain little; not an argument against the PR. Pitfall: arming. On main, a collecting Offer. I can run GTA open world on your head + #9181 + #9159, one run each: resumed faults, collect time, committer µs/draw. AI-assisted: yes (Claude Code) |
…to their 64 KiB block on Windows) at fdcbb83
|
Independent Windows/NVIDIA qualification of this patch, AI-assisted: yes (Codex).
No ASTRO's PLAYROOM or other retail performance benefit is claimed. I identified this path while profiling that title, but these results qualify component correctness on another Windows GPU; matched retail measurements remain separate work. This supports the existing PR rather than duplicating its implementation. |
|
Windows data point from Stray (PPSA02100 01.002.000), opening scene after New Game, scripted pad, warm cache. Windows 11 Pro, i9-14900K, RTX 5080 (NVIDIA 617.42), WinLibs GCC 15.2.0 Release.
In this scene the committer bounds the frame (busy 41 of 55 ms; queue worker 0 waits for its room 35 % of its samples). A committer sampler on |
|
A data point, not a test of this exact code. On Soul Hackers 2 gameplay (Windows, RTX 5090, I tried the same idea locally: an opt-in switch that widened small epoch collects to their 64 KiB block on Windows, only when the whole block was inside one resident direct-memory run. Walks per epoch went down by about 15%, but time per epoch stayed the same (about 47-48 us), and gameplay stayed at 210-237 submissions per 10 s against 212-233 without it. In this title the walks are spread over different blocks, so widening did not help. I did not run this PR's own code. |
Linux widens a collect of at most one 64 KiB block to the whole block within an epoch (boykopovar#1310), so the memo serves the block's other ranges. Windows kept the requested range because it was not tested there. On Windows with boykopovar#5596's resident direct memory every walk is a GetWriteWatch call, and ASTRO BOT's hub walks about 50k ranges of at most 64 KiB per 10 s on queue 0. Windows coverage does not know which pages of a block are committed or inaccessible, and a walk refuses such a range before it collects anything. So a widened walk that fails is retried over the requested pages; without that, a collect beside uncommitted pages of its block fails. The new uncommitted-pages test resets its range before releasing it, so the arena does not hand the next test an address inside memory that is still committed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
a78974c to
a6aae73
Compare
|
Rebased onto
Thanks @B-Howell for the NVIDIA qualification and the negative control, @dantdmdarealguy for the Stray A/B and the committer profile, and @klosixgaming-arch for the Soul Hackers 2 data. AI-assisted: yes (Claude Code) |
|
A/B of this PR on current
* This boot took 85 s instead of ~25 s, and its first 10 s window counted 24.4 FPS before the scene settled. Its later windows match the other runs. Over the settled windows (40-90 s) of all runs, Write faults. I added a counter to a local-only
The reporting thread was running and printed all 17-18 windows, so on current
The PR read more over the whole run (14,578 vs 8,778 MiB), almost all of it before the hub. In the hub both arms read about 36 MiB per 10 s. So on current AI-assisted: yes (Claude Code) |
✅ NVIDIA GPU test: passedPR head
Unstable on main (1, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (5, not counted against this PR)Validation IDs already present on main (4 IDs in 404 tests)Skipped (39)ReproduceAutomated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
|
stale+rebase 1. Freshness Envelope
2. Findings
3. Cross-PR Ledger
|
# Conflicts: # docs/dev/debt/libSceAgcDriver.md
✅ NVIDIA GPU test: passedPR head
Unstable on main (2, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (3, not counted against this PR)Validation IDs already present on main (4 IDs in 525 tests)Skipped (49)ReproduceAutomated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
What
Within a collect epoch, #1310 widens a collect of at most one 64 KiB block to the whole block, so the epoch's collect memo serves the block's other ranges. It left Windows on the requested range because it was not tested there. Windows now widens too.
MEM_WRITE_WATCHmemory, and a walk over it is aGetWriteWatchcall for each resident run it touches. With perf(agc): keep Windows host imports of write-watched private memory watched #6060, its host imports stay watched as well.main+ perf(agc): keep Windows host imports of write-watched private memory watched #6060, queue worker 0 spends 12.4 % of its samples inGuestArenaCollectWrites→WindowsMappings::collectResident, mostly fromShaderResources::fastRevalidateon every draw. A local counter showed about 50k walks of at most 64 KiB per 10 s.WriteWatchCoverage) does not know which pages of a block are committed or inaccessible.WindowsMappings::Collectrefuses such a range before it collects anything (collectable). So a widened walk that fails is retried over the requested pages.agc_driver_image_table_reuse's Windows expectation (CpuWriteResolutions) to Linux's count. Main made the same change in e3dd06f (since perf(agc): stores beside a range in its 64 KiB block leave the range unchanged #6346 the unchanged proof is answered per page on Windows too), so the PR no longer touches that test.Linux is unchanged: the widening block is the same, and the retry is Windows-only.
Tested
Windows 11 Pro 26200, Ryzen 7 5800X3D, Radeon RX 9070 XT (driver 32.0.23033.1002), WinLibs GCC 15.2.0 r7, Release.
CheckWidenedCollectBesideUncommittedPages(agc_write_tracking, Windows):a collect beside uncommitted pages of its block failed.agc_driver_image_table_reusepasses.ctest, the whole suite on this commit (rebased ontomainc0be1f6): 1,250 of 1,254 pass.agc_driver_quad_pixel_mask(implicit-LOD sample with quad pixel mask 2: pixel (0, 0) channel 2 is 2, expected 0) fails the same on this GPU withmain'sGuestMemory.cpp. It is from feat(agc): emulate PA_SC_AA_MASK sample masks #6015's sample masks, not this change.agc_driver_layered_volume_vertex_no_gplalso fails on this GPU without this change: onmaine34c479, and on perf(agc): keep Windows host imports of write-watched private memory watched #6060's head with and without its switch.guest_gameupdateandguest_vr_setup_dialogdon't start on this machine ("Process not started").tools/check_conventions.py --base origin/mainpasses.The frame-rate runs below were on
mainab9a476, before the rebase; the tests above ran on the rebased commit.ASTRO BOT (PPSA21564 01.007.000),
-lvl hub_crashsite(the full Crash Site hub), no input, warm shader cache (1,904 hits, 0 misses),APS5_NO_SNAPSHOT_CHECK=1 APS5_RESOURCE_CACHE_ENTRIES=4096.mainab9a476 + perf(agc): keep Windows host imports of write-watched private memory watched #6060, and B is A + this PR.libSceAgcDriver.prxdiffers. Runs alternate.Trace summary lines,
APS5_TRACE_SECONDS=300:30in the same scene, no otherAPS5_TRACE_*/APS5_PROFILE_*switch, log not redirected. In every capture, queue worker 0's event buffer filled about 5.6 s into the window (trace_dropped). The four traces are available on request.Driver.Packetms/frame0e4cea2533e776e7495c50a10e4cea2533e776e7495c50a10e4cea2533e7is A (mainab9a476 + #6060) and76e7495c50a1is B (A + this PR's commit, cherry-picked). A's two captures and B's two were taken in separate sessions on the same day; the FPS rows above alternate.Summary lines (A1, B1, A2, B2)
Related: #1201's pipelining commit keeps a thread's collected ranges for the whole epoch (
EpochCollectMap). That covers a separate repeat: the 64-entry memo ring is smaller than a queue-0 epoch here. The two changes add up. With an epoch-long memo, the widening cut the hub's walks on queue worker 0 from 81k to 57k and their time from 686 to 578 ms per 10 s (local counter). This tree plus #1201 (with @Raghav314's and @eliyarson's ordering fixes),APS5_PIPELINED_DRAWS=1, runs the hub at 5.33 / 5.36 FPS.Update (2026-10-29)
Rebased onto
mainedf6804 as a6aae73.GuestMemory.cppconflicted where main now reads the collect epoch throughHostThreadSlot. It is resolved as in @B-Howell's qualification copy (984029f):HostThreadSlot<std::uint64_t, CollectEpochSlot>::Get()and every other main change stay;CheckWidenedCollectBesideUncommittedPagesare unchanged;agc_driver_image_table_reuseexpectation, which main has had since e3dd06f.Validation layer, the same 15 focused tests as on 2026-10-23, on
mainedf6804 and on a6aae73, in one build tree (main = the same tree checked out at edf6804 and rebuilt).VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_NO_SHADER_CACHE=1,ANYPS5_REQUIRE_VULKAN=1,ctest -V -j1 --timeout 600.was not found but was requested by env var VK_INSTANCE_LAYERS. A second pass withVK_LOADER_DEBUG=layershows 8 insertions ofVK_LAYER_KHRONOS_validationon each, one per Vulkan test; it passes 15 of 15 too.VUID-VkDeviceCreateInfo-pNext-pNextfromvkCreateDevice, 24 times each, as before. This change adds no new VUID.tools/check_conventions.py --base origin/mainpasses.Main's newer write tracking (raised by @tibzejoker):
armResident, so a widened collect inside a resident run write-protects nothing; it stays oneGetWriteWatchcall over the block.WindowsMappings::Collectstill arms the settled subpages of a shared view's aliases. A widened collect settles every subpage of its block, so it can arm up to 16 subpages where the requested range armed one. Resumed write faults per 10 s onmainand on this PR are being measured.noteRefusedWalkbefore the retry: the block's unreported pages are stamped, and blocks with compared shared pages are marked refused. Callers holding an older generation for that block then compare bytes. The retry's own generation is newer than the mark.Update (2026-10-23)
Rebased onto
main3bd7173 (a78974c). Only the debt file conflicted, where two new entries sat next to this one.Validation layer, as CONTRIBUTING asks for AGC driver changes.
main3bd7173 (the PR's base then: itsGuestMemory.cppandWriteTracking.cppin the same tree) and on a78974c.VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_NO_SHADER_CACHE=1,ANYPS5_REQUIRE_VULKAN=1,ctest -V.agc_write_tracking,agc_write_tracking_metadata_commit,agc_write_watch_coverage;agc_driver_image_table_reuse;agc_shared_write_partial_collectand_two_pass;agc_driver_guest_memory_lifetimeand its_copy,_direct,_locked,_heap,_heap_uncachedvariants;agc_driver_depth_bits_guest_memory,windows_write_watch,guest_memory.was not found but was requested by env var VK_INSTANCE_LAYERS.VUID-VkDeviceCreateInfo-pNext-pNextfromvkCreateDevice, 24 times each. The 1.3.296 layer does not know a structure in the device'spNextchain. This change adds no new VUID.Update (2026-10-19)
Rebased onto
main3ddbc4a (246b029). Only the debt file conflicted: #4650's depth-range entry and this one now sit side by side. The image-table test change dropped out of the diff because main has it (e3dd06f), so the PR is the collect widening with its retry, the new write-tracking test and the debt entry.On the rebased commit, Windows 11 Pro 26200, Ryzen 7 5800X3D, RX 9070 XT (Adrenalin 26.8.1):
agc_write_trackingandagc_driver_image_table_reusepass 3 of 3 (ctest --repeat until-fail:3).CheckWidenedCollectBesideUncommittedPagesresets its range before releasing it, asCheckStoredAllSincedoes.CheckVersionRangesandCheckCollectBoundarieson main release theirs without a reset. Release alone leaves the committed host allocation in place, so a test added after them that resets its own block hits "cannot release part of a host allocation" (a local experiment of ours did). Nothing on main runs into it, so this PR leaves them alone.Update (2026-10-16)
#6060 has merged since this was opened, and so has #1201 (pipelined draws, with its per-epoch collect map). This branch still merges cleanly. I retested it merged onto
main5d9dcc4:agc_write_trackingandagc_driver_image_table_reusepass 3 of 3.ctest -R "agc_|guest_memory|write_watch": 602 of 605.agc_driver_quad_pixel_maskandagc_driver_layered_volume_vertex_no_gplfail on this GPU without this change, as noted above.agc_driver_gpu_indirect_arguments_misaligned_writer_aheaddoes not build under MinGW onmainitself:alignas(65536)exceeds the object file maximum of 8192. test(agc): align the indirect arguments block at run time #6452 fixes that.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