Repository navigation
Memory by address: the arenas' writes are told, the kernel is not asked about them - #1062
Conversation
…ed about them With the title's ray tracing on (VICTORY_BVH_BUILDER=1), every list that reaches memory by address refreshes every arena whole, and each submission asked the kernel which pages of them were written: 18-21 arenas of 64 MiB and the directory, 5-9 GB of page tables walked a frame, 6.5-11.9 ms of the submitting thread (i7-13700K, diagnostics build), to find the few pages memory.rs itself had just written. Only memory.rs writes the arenas and the directory. It now tells the journal of each write (watch::owner_wrote), and ranges that are owned this way are answered from the journal alone: 1.7-2.0 GB asked a frame, 2.8-4.1 ms. On the boat of the opening, 4K, RTX 4080: "preparing" 23.5-24.9 ms -> 19.2-19.4 ms a frame with the builder on. Without the builder nothing measurable changes. VICTORY_MEMORY_OWNED=0 asks the kernel as before. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Checked this on Windows at
The saving, synthetically. I wrote an ignored test on my fork,
That 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. Read through. In Conflict with #1094. That PR replaces Synthetic only: no game files. |
|
Independent live RT-on ( Targeted
Visuals & caveats:
Automated checks: Clean merge-tree on Not tested: boat / free-roam scenes or AI-assisted test run and summary. |
|
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, Before I saw this PR, I wrote a local variant:
I ran alternating sessions on the same exe, with the variant on a switch:
* The device was removed; the boat figure is partial.
Measurements prepared with an AI assistant (Claude Code); the runs were played on my machine. |
|
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). |
|
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). |
Conflicts:
- shadow.rs: upstream's Copied { pages, ranges } replaces trustno1-coder#1298's tuple;
trustno1-coder#1298's batched nothing_new_with keeps its shape on it (Copied::ranged
replaces ranged_in); trustno1-coder#1184's lazy landing and its tests follow (pages,
arena). An unused copy_all of trustno1-coder#1298's and the VICTORY_WIDE_CHUNK tests
(helpers dropped earlier) are left out.
- watch.rs: trustno1-coder#1062's owned memory is told in asked() beside trustno1-coder#1298's binary
search, and counted as known by is_published() (so the batched
nothing_new sees it too, sampled before the journal's lock).
- structure.rs: upstream's trustno1-coder#1103 (ours came adapted through trustno1-coder#1226).
- lib.rs: both modules.
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