[pr-performance] Remote: pins written with the guarded copy, not WriteProcessMemory (cam-city median frame 111 -> 65-77 ms) #361
Loading…
Reference in a new issue
No description provided.
Delete branch "cafe/remote-pins-safecopy"
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?
Contributor role (optional)
1577752157942198273(Cafe#9189)What it changes
bench-remotebuilds,DARNER_REMOTE) writes every pin withWriteProcessMemoryon our own process, at each Present and at every 8 ms pad poll.WriteProcessMemoryasks the kernel about each page (NtQueryVirtualMemory) under the process's address-space lock, whichGetWriteWatch(crate::watch) takes exclusively. In a CPU profile (WPR) of the kit's cam-city flight, the submitting threads waited about 370 ms a second inGetWriteWatchfor that lock, and the pin writes were the main holder. So benchmark runs measured a slower Darner than players get.write_ownnow triessafecopy::copyfirst (a plain copy with a fault exit, no kernel call) and falls back toWriteProcessMemoryonly when that fails, so pins on pages the copy cannot write (read-only image data withDARNER_REMOTE_PATCH=1) work as before. Onlybench-remotebuilds run this code; release builds are unchanged. (#115 fixed the same lock contention forreadable_len.)How it was tested
Tested revision:
mainf3840d73d+ the four translator forms of #312 + this commit (1df3ea537),bench-remoterelease build, against the same build without this commit.Changes a default: no (benchmark builds only).
A/B result (RTX 2080 Ti, the kit's cam-city route, whole 172 s flight, pipelines warm, the kit unchanged, hardware-accelerated GPU scheduling on):
WriteProcessMemory)prep_ms, median)card_idle_ms, median)card_lists_ms, median)The card's own time does not change; the frames were waiting on the CPU side. Earlier, with GPU scheduling off and the same copy without the fallback: 114.7, 118.6 -> 94.5, 97.0 ms (7.4, 8.2 -> 10.3, 10.0 fps).
Gates on
1df3ea537:cargo build --locked --release -p darner --features bench-remoteok;cargo clippy --locked --release -p darner-gpu --all-targets --features bench-remote -- -D warningsok;cargo clippy --locked --release -p darner-shader -p darner-gpu --all-targets -- -D warningsok. Not run: tests (nothing here has a test; the remote needs a running title).Kit check: the kit's own checks passed in every run (camera at the start, pins status 1, route end reached).
Gameplay: RTX 2080 Ti, Windows 10 22H2, Series S profile, 2560x1440 output, DLSS Performance, hardware ray tracing, no frame generation.
Hardware dependence: none expected (a CPU-side lock); measured on one PC only.
Coverage gaps: one route; not measured with
DARNER_REMOTE_PATCH=1pins in the image (they take the fallback, as before).Note: the kit itself also writes the same rows from outside with
WriteProcessMemorybefore pinning them (foot.hover), which holds the same lock; skipping those 8 duplicated writes took the route a further 95 -> 88 ms (one run). That is in the kit, not in this repository.Checklist
main.docs/asset-policy.md.Checked for overlap
readable_len); #150 (write-watch tests) and #152 (A/B docs) touch nearby topics, not this code.A/B on a second card and PC: RTX 5070 12 GB. The fix does here what it says, with a larger effect.
Setup: i9-14900F, 32 GB, Windows 11 (build 26300), driver 621.40. Series X profile, 2560x1440 output, DLSS Quality, hardware ray tracing, no frame generation. The kit's cam-city route and bench-base save, the flight itself unchanged. A =
mainf3840d7, B = this PR's head1df3ea5, bothcargo build --locked --release -p darner --features bench-remote, same translator, shared warm shader cache. Flights alternated B, A, (a third config, not part of this), three rounds. Figures are the two scored parts of each flight (tag_seg1 and 2 of the record).prep_ms, mediancard_idle_ms, mediancard_lists_ms, medianAs in your table, the card's own time does not move; the difference is all on the CPU side. Every flight listed passed the kit's own checks (camera on 100 % of updates, route end reached).
One flight not in the table: the first attempt at A3 hung partway through the route (
0x887A0006, no page fault in the device-removed data) and was flown again. That is 1 hang in 4 flights without the fix and 0 in 6 flights with it, too few to say anything about the cause.Limits: one PC; free physical memory was low during the flights (about 0.6-1.5 GB), so the absolute numbers are probably worse than on a PC with more RAM; the game's F1 settings are the ones from the author's wrapper with ray tracing and DLSS set as above.
Written with an AI assistant (Claude); the figures are measured on this PC.
cam-cityABBA Benchmark on RTX 4090 + 7950X3D: Confirmed ~20% CPU-Side WinTested
1df3ea5againstmain(f3840d7) in a full ABBA sequence (A1 -> B1 -> B2 -> A2) on the full 172 scam-cityroute usingbench-kit(with thefoot.pypinsfix update).Per-Run Results (
all tagged rows, ~174–176 s)prep_ms(med)card_idle_ms(med)card_lists_ms(med)pipe_mademain(f3840d7)1df3ea5)1df3ea5)main(f3840d7)mainSegment Breakdown (Median Frame Time)
115.32, 108.08 ms(mean111.70 ms) → B =87.45, 88.11 ms(mean87.78 ms, -21.4%)90.96, 87.40 ms(mean89.18 ms) → B =73.11, 70.83 ms(mean71.97 ms, -19.3%)Summary
B2vsA2, bothpipe_made=3), median frame time drops from92.57 msto78.67 ms(-15.0%) and overall FPS rises from9.74to12.47(+28.0%).prep_ms(-22.8%) andcard_idle_ms(-26.5%) account for nearly the entire improvement while GPUcard_lists_msstays flat (~28–29.5 ms), confirming the CPU-side address-space lock contention fix.main) passedcam-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.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.