[pr-performance][memory] watch,inplace,xmem: batch view guards, shard LAZY map, and pre-arm overflow aliases asynchronously #219
Loading…
Reference in a new issue
No description provided.
Delete branch "hingeowl/Darner:pr/batched-view-guards"
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?
Re-submitted from the previous CodeFloe repository (original commit
5315f0a8d09a0f71cd1ff1b638981eef2525aad7, preserving original authorship by Ethan Anderson) so it is not lost after the forge move.What it changes
map_lazy) from unguarding live aliased views viatitle_memory_soft_view, unguarding physical aliases only when a soft view materializes (title_memory_made_real).xmem'sLAZYmap 64 ways with cache-line-aligned occupancy bits.protect_hereand coalesces contiguousVirtualProtectcalls inunguard.watch::guard_ahead+Journal::guard_ahead+ batchedcover_manybeforewide_each_scopedinBatch::refresh_front_spans_with, usinginplace::view_spaninstead of repeatedVirtualQueryloops.VirtualProtectcalls per guard pass (default 24 viaDARNER_GUARD_ASYNC_BUDGET) and pre-arms overflow aliases on a dedicateddarner-guard-bgthread paused duringask_onceandwide_each_scoped.Notes
main(f3840d7).mainhas not been run yet.CHANGES NEEDED
Review of
d8325feab.async_guard_workercan run beforeASYNC_GUARD.get_or_initpublishes its value: the initializer spawns the thread atcrates/darner-gpu/src/watch.rs:4635, while the worker returns immediately whenASYNC_GUARD.get()is stillNoneat lines 4657-4661. If scheduled in that window, the worker exits permanently, so queued overflow aliases are never pre-armed. Pass the initialized state to the worker or start it only after publication, and cover the startup ordering with a test.Windows validation: G1 PASS; G2 PASS;
cargo xtask policyPASS (555 files ok);inplacetests — 15 passed, 0 failed;xmemtests — 53 passed, 0 failed, 1 ignored. Theshadow::testsselector matched 0 tests.Not run in-game.
AI-assisted: yes (GitHub Copilot, Auto mode).
Replay A/B on RTX 5070 Ti: no measurable difference
Measured
d8325feab6merged on top of release v2026.12.03.02, against the plain release, on a ~6.5 minute replay route (same save, recorded controller input) through a cutscene, a scene cut and a stretch of free play.Crashes: none in any run (no device loss, no host GPU failure). Fps means are within the release's own run-to-run spread, so: no measurable difference on this route. With only 3 release runs, that spread is not well known yet; differences under ~2-3% can't be resolved here.
Config: RTX 5070 Ti 16 GB, Ryzen 7 9800X3D, 32 GB RAM, Windows 11;
scripts\play-nvidia.ps1 -Build release(Series X, 1440p native, DLSS Quality, no frame generation, fullscreen, no fps cap). Each build had one unmeasured warm-up run first. The release base excludes its first measured run, which was still compiling shaders (about 3,300 compiles during the route).Measured unattended on a replay bench (same save, recorded controller input); numbers and text prepared with Claude.
Fixed in
b44d45c:enqueue_async_aliasesnow publishesASYNC_GUARDviaget_or_initfirst, then spawnsdarner-guard-bgviaASYNC_GUARD_STARTED: Onceand passesstate: &'static AsyncGuardStatedirectly intoasync_guard_worker(state)so the worker cannot observeNoneand exit on startup. Added unit testasync_guard_worker_starts_after_state_publication_and_drains_queue.Validation on
b44d45c:cargo test -p darner-gpu --lib --locked -- async_guard_worker_starts_after_state_publication_and_drains_queue— 1 passed, 0 failed.cargo clippy -p darner-gpu --all-targets --all-features --locked -- -D warnings— passed.Ready for re-review.
cam-cityABBA Benchmark on RTX 4090 + 7950X3D: No Improvement (Flat on Clean Run, Regression on B2)Tested
b44d45cagainstmain(f3840d7) in a full ABBA sequence (A1 -> B1 -> B2 -> A2) on the full 172 scam-cityroute usingbench-kit(with thefoot.pypinsfix update), with warm pipelines.Per-Run Results (
all tagged rows, ~176 s)prep_ms(med)card_idle_ms(med)card_lists_ms(med)pipe_mademain(f3840d7)b44d45c)b44d45c)main(f3840d7)mainSegment Breakdown (Median Frame Time)
110.73, 113.98 ms(mean112.36 ms) → B =109.99, 117.50 ms(mean113.75 ms, +1.2%)82.33, 81.53 ms(mean81.93 ms) → B =81.49, 88.84 ms(mean85.17 ms, +3.9%)Summary
cam-city:B1(pipe_made=0,pipe_wait_ms=0) landed insidemain's A1–A2 spread (87.77 msmedian /10.60overall FPS vsmain87.34–92.13 ms/10.44–10.47FPS), whileB2regressed to102.36 msmedian /9.10overall FPS (pipe_made=2,52.2 scumulativepipe_wait_ms, plus slowerprep_msacross both segments).main.cam-bench.pyclean checks (RESULT: camera route flown, clean) with zero crashes or device losses.Environment
621.14), AMD Ryzen 9 7950X3D, Windows 11 Pro (build26300).cargo build --release --locked -p darner --features bench-remote.bench-kit(pinsfixfoot.py),cam-city(172 s), Series X profile, HW RT enabled (DARNER_HW_RT=1,DARNER_BVH_BUILDER=1),play.rsDEFAULT_ENVtuning, no frame generation.Re-measured
b44d45con RTX 5070 Ti: no regression on this routeFollow-up to the measurement above (which was on
d8325feab6, before thedarner-guard-bgstart fix). A second card and route next to the 4090 ABBA above: here neitherb44d45crun is slower than the release.b44d45cmerged on top of release v2026.12.03.02 (f3840d73), against the plain release, same ~6.5 minute replay route (same save, recorded controller input). The release baseline now has 11 runs from the same day.b44d45cConfig: RTX 5070 Ti 16 GB, Ryzen 7 9800X3D, 32 GB RAM, Windows 11;
scripts\play-nvidia.ps1 -Build release(Series X, 1440p native, DLSS Quality, no frame generation, fullscreen, no fps cap). One unmeasured warm-up run first.Measured unattended on a replay bench (same save, recorded controller input); numbers and text prepared with Claude.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.