Repository navigation
perf(libc): walk shared views in order and remember collectable ranges in Windows write collects - #5062
Conversation
|
Review note (static): AI-assisted (Claude Code). |
|
Thanks for checking. That path can't reach a collected range:
So no proven range can contain memory those two calls change. AI-assisted (Claude Code). |
|
Heads-up: #3864 changes the same code. It keeps an iterator hint for the view lookup, skips ranges already in |
|
All good, I will rebase. I imagine your PR will be merged first. |
|
Thanks for coordinating. I can’t predict maintainer merge order, and I don’t think either change is a functional prerequisite for the other. #5062 is clean on current main with its listed checks completed; #3864 still needs its requested rebase and a repeat of the original PPSA28416 measurement on the new base. If #5062 merges first, please rebase #3864 onto it; if #3864 merges first, I’ll rebase #5062 and retain both changes. |
d0cc992 to
3ea67da
Compare
3ea67da to
b14d844
Compare
|
Checked the diff: |
|
@adriadam10 thanks! The checklist was missing the newer "GPUs tested" line; it's filled in now (n/a, libc only), and |
What
A clearing write collect on Windows (
WindowsMappings::Collectwithclear) first checks the whole range withcollectable(), then walks it. Both looked up the shared-view map once per 16 KiB page (views.find(base)). A title that maps gigabytes of direct memory as shared views has hundreds of thousands of entries in that map. A collect over a 36 MB render target then costs thousands of tree searches, each a chain of cache misses, before any page is reported.Collectandcollectable()take onelower_boundat the start of the range and step the iterator forward (viewAt). A jump past a clean range or a private region falls back tolower_bound. The pages reported and the order are unchanged.collectable()keeps the ranges it proved, merged, incollectableRanges. A clearing collect inside a proven range skips the check. Every call that can change the answer clears the set:Commit,Map,SetProtectionandreset(behindResetandCommit's placeholder replacement).Pin,Unpin,HandleWriteand the host-write calls change neither view membership nor a view's protection, so they leave it.#4875 also edits
Collect, but a different part: theGetWriteWatchbuffer sizing on the private-memory path. The two touch different lines.Tested
System: Windows 11 (26200), Ryzen 7 7800X3D, RTX 5070, WinLibs GCC 15.2, Release,
BUILD_TESTING=ON, rebased onmain872f523.Suites: after the rebase onto 872f523 (it walks the resident views from fix(libc): track writes to singly mapped direct memory without faults on Windows #5596 through the same in-order lookup, and keeps fix(libc): forget a released section's pages even while views remain on Windows #5730's shared section slots), with every test executable rebuilt: the full
ctestpasses 1140 of 1140 (skips as onmain), includingctest -R "guest_memory|write_watch|libc|libkernel"(9 of 9) andctest -R "^agc"(494 of 494,agc_driver_stencil_ref_exportskipped as onmain).No new test. The change only affects speed: the pages reported are the same, so no test can fail on
mainand pass here. The existingCheckFailedCollectKeepsWritesinguest_memoryproves a shared range collectable,mprotects half of it to no access, and requires the next clearing collect to fail and keep the write. With the clear inSetProtectionremoved, it fails atGuestMemory.cpp:1363, so it guards the cache.tools/check_conventions.py --base origin/mainpasses.Minecraft Dungeons II (PPSA16064), gameplay at the Squid Coast spawn, standing still. This is not a clean-
mainA/B: the title needs patches that are not inmainyet to reach gameplay (perf(agc-driver): join the imports of adjacent large ranges when a buffer is bound across them #4515/perf(agc-driver): join the imports of adjacent ranges of any size that a buffer is bound exactly over #4517, feat(agc): depth planes sampled as 2D arrays, cubes and integer views #425 and local ones). Both sides are the same build with and without each step, captured with the feat(agc): record a present window as a Chrome trace and a summary line #4526 trace,APS5_TRACE_SECONDS=25:15opened 25 s after the HUD appears. Each A/B had a warm-up boot per side and interleaved runs.libc.prx, not Windows. After both steps the collect samples fell from 461 to 254 in comparable runs; what remains is mostlyVirtualProtectre-arming written views.About 6% at p50 together. I can attach the traces.
Not run: Linux and macOS (the change is in the Windows-only
WindowsMappings), AMD, cleanmainin a title; the MCD2 numbers below were measured before this rebase and were not rerun.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)