Repository navigation
Conversation
…l a view change ClampRangeSize walks every 16 KiB page of a partly mapped range for each draw and dispatch that binds it. Each thread now keeps the length it found for a range while the probe and backing epochs are unchanged, behind the temporary switch KYTY_CLAMP_MEMO.
The in-run A/B decided: KYTY_CLAMP_MEMO is removed and ClampRangeSize always remembers the mapped length.
simnJS
left a comment
There was a problem hiding this comment.
ForgetProbes publishes the epoch before clearing the old probe bits. A clamp overlapping a protection change can cache the old prefix under the new epoch, and the entry survives the callback. Please cache only results covered by tracked changes, or make publication distinguish an invalidation in progress. Please also preserve fresh VirtualQuery results for unreported Windows pages. Cover repeated clamps around a protection-only change and a Windows range whose protection changes without a backing callback.
…ange is backed IsBacked walks every 16 KiB page of a range up to its first unbacked page, so for a partly mapped range it walks the whole mapped prefix on each call, before the remembered length is looked up. Look it up first; a range's backing changes only together with the backing epoch the remembered length is checked against. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EqZu9J6tUMvmRP7RkxVCQr
|
Follow-up commit 73b5cce:
Measured on the PPSA28416 Jakku race, current
Tests on 73b5cce, same configuration as the description: shim suite 109 of 110, the same two as before not passing ( AI-assisted. |
|
Please add a regression test that keeps a reader thread alive across a commit or reset: populate its cache before the change, then have the same thread check the new length after the change completes. The current test starts a fresh thread after each change, so its cross-thread check never exercises invalidation of an existing cache entry. |
|
I closed the companion PR I mistakenly opened against the contributor fork. The focused review fix is still available as one commit based on this PR's current head |
What
ClampRangeSizewalks every 16 KiB page of a buffer range that is only partly mapped, for each draw and dispatch that binds it (RenderExecutor::FindBuffers). A title that binds a few V#s describing 2–4 GiB, of which a few hundred MB are mapped, pays that walk tens of thousands of times per second for the same answer. This is the targeted fix suggested in #24 ("cache the clamp result per buffer range until an unmap").The change: each thread keeps the mapped length it found for a range in a 256-entry table, keyed by (address, size). An entry is used only while
g_probe_epochandg_backing_epochare the ones it was found under.OnViewChangemoves the first before it stores the pages and the second after, andOnProtectionChangemoves the first, so an entry is stored only when neither moved whileMappedPrefixran. A hit also skipsFirstClamp. The measurement switch (KYTY_CLAMP_MEMO, first commit) is removed in the second commit, as START_HERE asks once the A/B has decided.Tested
Linux 7.3, Ryzen 9 5950X, RTX 3080 Ti, NVIDIA 615.71.09, Release (CI configuration, LLVM 22).
Why: PPSA28416 (Star Wars Galactic Racer, Unreal Engine), an Arcade race on Jakku driven by
APS5_PAD_INPUT_FILE,KYTY_GPU_SPIN_US=0, on945dc287bc:perf record -gofkytyGpuExecute: 74 % of its samples inMappedPrefixunderClampRangeSize(DispatchIndirect40 %,PrepareGraphicsBindings23 %,DispatchDirect11 %).ClampRangeSizecalls, ~29,000 of them for a2^31-byte range that is only partly mapped, ~1.0 billion page-table loads, 89 % of the calls repeating a range seen just before, and 20 to 30 page-table changes.In-run A/B,
KYTY_AB=20:KYTY_CLAMP_MEMO KYTY_AB_SETTLE=5, warm caches,tools/kyty_ab_report.py(A = remembered, B = walked):7de61e3451945dc287bc945dc287bc7de61e34517de61e3451the walked arm of the race is slower than on945dc287bc(5.5 vs 6.9 img/s), so something else on the head costs this scene too, and the gain shows less there.clamped buffer range, and neither did PPSA22408 in three minutes of menus, so they don't take this path.Tests,
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer, shim suite (^(kyty_shim_.*|guest_gpu_fault|guest_host_write_filter|agc_kyty_shaders)$), serially, on7de61e3451and on the first commit:7de61e3451VUID-lineskyty_shim_memory_sparse_reads_switch(timeout),kyty_shim_rt_corpus(skipped)kyty_shim_memory: a clamped range inside a guest arena block, after a commit of the first page, a commit of all, a reset of the second half and a commit again, gives the mapped length expected after each change, four times in a row on the same thread and once on a new thread. It runs inkyty_shim_memoryandkyty_shim_memory_plain_reads; both pass on the final commit.tools/check_conventions.py --base 7de61e3451andtools/check_kyty_settings.pypass.Checklist
AnyKyty7de61e3451, merges cleanly on the current head90a48455d2; 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)ClampRangeSizepart of perf(kyty): memory-tracking reads cost about 19 % of Execute in METAL GEAR SOLID 4 (MappedPrefix, IsBacked, StillValid, FirstClamp) #24)🤖 Generated with Claude Code
https://claude.ai/code/session_01EqZu9J6tUMvmRP7RkxVCQr