Memory by address: the arenas' writes are told, the kernel is not asked about them #1062
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1062"
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?
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by MrSquirrel489 on 2026-11-28T12:26:37Z.
What
With the title's ray tracing on (
VICTORY_BVH_BUILDER=1, F1: RAY TRACING),memory.rsnowtells the write journal of its own writes into the arenas and the directory
(
watch::own,watch::owner_wrote), and the kernel is no longer asked what was written there.VICTORY_MEMORY_OWNED=0asks the kernel as before.Why
Every list that reaches memory by address refreshes every arena whole (
Memory::bring_up), andeach submission asked the kernel (
GetWriteWatch) which pages of all of them were written:18-21 arenas of 64 MiB and the 128 MB directory. That is 5-9 GB of page tables walked a frame
to find the few pages
memory.rsitself had just written (bring,take,fill). The timefollows the megabytes, not the number of askings (5.3 GB: 6.6 ms, 6.6 GB: 7.9 ms, 9.0 GB:
10.8 ms;
upload.rsalready notes the same of one 3.2 GB reservation).Stack samples of
victory-submiton the boat, 60 s:GetWriteWatchis 27.1 % of the threadwith the builder on and 9.5 % with it off; 16.2 % straight from
watch::ask_once(off: 2.1 %).Nothing else writes that memory: the arenas' copies (
shadow::by_address) only read it, andwhat shaders store there stays on the card. A write is told after its bytes are in, so a copy
that began before it has an older asking's number and takes the pages again.
Measured
i7-13700K, RTX 4080 16 GB, Windows 11, 3840x2160, DLSS Performance, Series X profile, release
build. One game at a time, runs alternated with main. The boat of the opening, 175-255 s after
the window, medians of the log's 5-second lines.
Kernel askings a frame, diagnostics build, builder on, the office and the cut to outdoors:
Boat, builder on (each column one run):
"preparing" falls by about 5 ms in every run. Frames a second follow it only as far as the
card's time allows: that varies from run to run by itself (4.6-14.6 ms, with the state of the
dynamic structures, see "Known gaps" in
docs/fork-ray-tracing.md), so single runs overlap.Boat, builder off (launcher's settings), five runs of main and four of the branch, alternated:
main 30.95, 30.43, 31.10, 30.87, 30.87 fps; branch 30.29, 30.54, 31.39, 30.98 fps. No difference
beyond the spread of runs (about 1.5 fps).
Pictures, builder on, the opening unskipped, screenshots every 5 s: the office is lit as on main
(walls, shelf, the shadowed side of faces), outdoors and the boat look the same. The glitter on
faces that main shows now and then with the builder on is still there now and then: it is not
this change's subject. No device removal or crash in 9 runs of the branch.
Tests:
cargo test --locked --workspace --no-fail-fast: 1,127 pass, 0 fail, 49 ignored (one new:watch::tests::memory_its_owner_tells_of_is_answered_without_the_kernel). In an earlier runvictory-loader'sconsole_insn::tests::a_clzero_loop_becomes_plain_storesfailed once andpassed when run again; that crate does not depend on
victory-gpu.cargo clippy -p victory-gpu:no new warning.
Not measured
(branch: 10 s under 5 fps, 25 s at 5-15 fps in one run; main: 50 s and 15 s in one run). One
run each: not a claim.
VICTORY_RELAY=0,VICTORY_ASK_ONCE=0and other non-default paths of the write watch.🤖 Generated with Claude Code
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by jptorres96 on 2026-11-28T13:46:53Z.
Checked this on Windows at
59e7a01(base63b902f), without the game. Ryzen 5 5600X, RTX 4080 SUPER, Windows build 26300, rustc 1.98.1.cargo test --locked -p victory-gpu --lib -- --test-threads=1: 454 passed, 0 failed, 38 ignored, includingmemory_its_owner_tells_of_is_answered_without_the_kernel.cargo clippy -p victory-gpu --all-targets [--all-features] -- -D warnings: clean in both builds once themanual_is_multiple_ofalready onmain(descriptor.rs:1234) is allowed.The saving, synthetically. I wrote an ignored test on my fork,
probe-1062, on top of this branch. It sets up 20 write-watched arenas of 64 MiB, every page touched once. Each frame it writes 40 random 8-byte spots per arena and then callswrites()over every arena whole. It also checks that every page written that frame comes back with a newer write than the frame's start.own+owner_wroteVICTORY_MEMORY_OWNED=0That is about 1.1 ms per GB asked, so your 5.3-9 GB would come to 6-10 ms here. That is in line with your 6.5-11.9 ms, and with the time following the megabytes.
Cost elsewhere.
owned()adds a read ofOWNEDtowrites,asked,nothing_newandask_rest. I ran the #795 probe from my comment there on this branch: per-rangewriteson memory that isn't owned, 1, 4 and 8 threads. It shows nothing abovemain(8 threads: 22 us a range write-watched and 84 us guarded, against 25 and 92 onmain).Read through. In
memory.rs, every write into the arenas and the directory goes throughowner_wrote:fill,gone's cleared entry,take's merge and the piece copy. The one otherwrite_volatileis to the faults buffer, which isn't owned. Thewatch::wrotedropped fromplaceis covered byhold, which callsfill. The onlyVirtualFreeof an arena is the failure path, which callsdisownfirst, so a staleOWNEDrange can't later cover a reservation that something else writes. What the probe can't check is your statement that nothing else writes there, i.e. that what shaders store stays on the card.Conflict with #1094. That PR replaces
nothing_newwith lock-freenothing_new_with/nothing_new_single, so the two don't merge cleanly inwatch.rs. Whichever lands second should add|| owned(first, last)toknownin both new functions. Leaving it out isn't unsafe: they answerfalseand the refresh falls through towrites(), which does handle owned memory. But the arenas would then lose the shortcut. #1094 also mirrorsJournal::noteinto its epoch table, andowner_wrotegoes throughnote, so that part combines without changes.Synthetic only: no game files.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Bj0rnis on 2026-11-28T13:50:20Z.
Independent live RT-on (
VICTORY_BVH_BUILDER=1) verification on RTX 5070 Ti 16 GB + Ryzen 7 9800X3D (Windows 11, 32 GB RAM, driver621.24, Rust 1.98.1,--releasebuild from source at59e7a01, Series X profile, 2560×1440, DLSS Quality, Frame Generation off; opening → prison cell → prison break room, ~27 RT arenas /1,484 MB, ~412–419 BVH build dispatches/frame).Targeted
asking the write watchA/B (same binary,VICTORY_BVH_BUILDER=1):VICTORY_MEMORY_OWNED=0(n=269)VICTORY_MEMORY_OWNED=1(default, n=306)asking the write watchasking the write watchasking the write watchVisuals & caveats:
VICTORY_MEMORY_OWNED=1. (Observed normal run-to-run variance under high VRAM pressure [13.7–13.9 / 14.5 GBVRAM,7.0–7.4 GBshared]: Run 1 [OWNED=1] rendered the phone screen and showed the known waitress face glitter; Run 2 [OWNED=0] had a clean waitress face and a black phone screen.)OWNED=1run was our first cold RT launch (compiling RT/BVH pipelines on the fly,6.7 fpsmedian /22.4 fpspeak), whereas theOWNED=0run had warm RT pipelines (14.6 fpsmedian /18.5 fpsin the 9.3k-draw prison break room /24.3 fpspeak), so raw FPS is not apples-to-apples between the two passes — only the isolatedasking the write watchsaving above.Automated checks: Clean merge-tree on
main(63b902f);cargo test --locked -p victory-gpu --features diagnostics --lib -- watch:: memory::53 passed, 0 failed (includingwatch::tests::memory_its_owner_tells_of_is_answered_without_the_kernel);cargo xtask policy294 files ok.Not tested: boat / free-roam scenes or
VICTORY_BVH_BUILDER=0regression check. No game data, logs, or captures attached.AI-assisted test run and summary.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Rafa7046 on 2026-11-28T19:22:40Z.
Here is a data point from a different implementation of the same idea, plus the boat, which is listed as not tested.
Setup: RTX 5080, 9950X3D, Series X, 1440p, DLSS Performance,
VICTORY_BVH_BUILDER=1,mainat8fc2254. A script plays the prologue cutscenes, then stands one minute on Jason's boat.Before I saw this PR, I wrote a local variant:
fill,take's merge, the piece copy) pushes a mark;refresh_frontdoes its refreshes, the marks go into the copies' CPU side;I ran alternating sessions on the same exe, with the variant on a switch:
* The device was removed; the boat figure is partial.
VICTORY_MEMORY_OWNED=0/1and that counter, before merge, would show whether anything changes beyond the lottery.Measurements prepared with an AI assistant (Claude Code); the runs were played on my machine.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Lancito01 on 2026-11-28T21:20:04Z.
Data point (RTX 3080 10 GB, 32 GB RAM, Series S profile, warm cache, prison window scene ~4.1k draws/frame), on main
9ce3cf9+ #938, one change at a time:So on this title the owned arenas don't seem to take memory out of the GetWriteWatch scan; almost all of the ~9 GB checked is still unchanged each frame. Happy to rerun with extra logging if you want to see which ranges stay watched.
AI-assisted (Claude).
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Lancito01 on 2026-11-28T21:45:16Z.
Follow-up to my data point above: comparing screenshots, the run with this PR drew the prison jumpsuits (Lucia's and the inmates' outside) dark red instead of orange; the runs before and after it on the same base, cache and settings drew them orange. So beside no speed change here, it looks like something written into owned memory is not being seen (stale colour data). One run only, same scene (prison window, ~4.1k draws).
AI-assisted (Claude).