Repository navigation
Conversation
Lists whose shaders use title memory ask for every host copy there is at each submission (about 4,100 in the world), and again after every title copy. A title run on 940d32f published 254,139 change checks a frame over 92.8 GB, 99.7 % of it unchanged (Marvisak#400). Each of those checks went through the refresh batch's maps and locked the copy's set of changed pages to find it empty: about 330 ns each in a synthetic frame of the same volumes, where they were half of the preparing time. A tracker now keeps the number of its changed pages beside the set, written under the set's lock and read without it, and the refresh batch leaves out a copy whose number is zero. The refresh of such a copy copied nothing before, so the host copies get the same bytes as before; a write that lands while the number is read counts as landing after, as it does with a take. Memory that is not tracked is copied whole as before. The diagnostics line counts the copies left out as skipped. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A world submission asks for every host copy of title memory many times over (lists whose shaders use title memory name every copy there is, about 4,100), and nearly every time nothing was written there. Each ask did real work to find nothing: a hash-map lookup, a queued refresh, a Shadow::update that locked the copy's declared ranges and the tracker's changed pages. Tracked now keeps the number of its changed pages in an atomic, written under the set's lock by a guard around every use of it; Shadow::unchanged is one load. Batch::add returns on it before any bookkeeping, so such a copy queues nothing and is remembered nowhere. Memory copied whole each time is never unchanged and keeps its old path. Adapted from Marvisak/VIctory#2136 (GPL-3.0-or-later), by r4tedx; the tests are theirs, ported to our batch (which keeps ranges per copy and the fx maps). PortWatch: frame preparation work removed, not a visual change.
DenRakEiw
left a comment
There was a problem hiding this comment.
Verified locally merged onto origin/main (940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090, Rust 1.98.1 MSVC):
cargo test -p victory-gpu --lib a_copy_nothing_wrote_is_not_asked_for— passed on RTX 5090cargo clippy -p victory-gpu --all-targets— 0 warningscargo xtask policy— ok (183 files ok)
Clean unchanged() fast-path skipping submission refresh copies when nothing wrote to the tracked range. Looks great.
AI-assisted (Gemini 4 Neon).
|
Independent locked MSVC With the exact #2134 workload and the same test-only counters in both trees, 2 warm-up + 5 scored frames/process in A–B–B–A order: RTX paired preparing medians 147.6→51.1 ms and 123.6→46.2 ms; explicit WARP 129.2→55.5 and 133.7→53.4 ms. Median checks 274,094→1,325 in both adapters. At each scored frame the checked-minus-unchanged bytes, requested bytes/count, guard/protect/open counts, snapshot bytes, marked pages/returned bytes, and title-copy count were equal. Same-pin RTX drift was visible, so these are directional synthetic results, not a precise speedup estimate or gameplay FPS. No title, textures, real shader workload or title threads writing concurrently with preparation in this replay. |
catminou4
left a comment
There was a problem hiding this comment.
Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.
Host copies nothing wrote not requested at submission — avoids redundant copies; check the dirty-tracking covers all write paths (#1963's write-scope tracking related).
…nothing wrote is not asked for at submission, head 937f329) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sak#2115 in; Marvisak#2150 left out for now Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@catminou4 on whether the tracking covers every write path: the skip reads the same thing the refresh read. #1963 is the other direction (what shaders wrote going back into title memory); it does not change which title writes a refresh sees. Thanks to @yualk for the independent run above: its read-back control (cold, untouched, a watched CPU store, a title copy followed by a refresh, a re-armed store returning the expected words on both builds) is a check I did not have, and its counters match mine (274,094 → 1,325 checks, everything else equal). Nothing new was run for this comment. The title was not used in these tests. AI-assisted |
|
Verified head Hardware Benchmark (
|
| Variant | preparing, ms (T1 / T2) |
copying back, ms (T1 / T2) |
change checks |
checked, MB |
changed (copied), MB |
Unchanged check (batch) |
|---|---|---|---|---|---|---|
940d32f + #2134 (RX 7600) |
244.1 / 227.2 | 181.9 / 173.3 | 274,094 | 102,722.0 | 159.1 | 437 ns |
940d32f + #2134 + #2136 (RX 7600) |
126.9 / 108.8 | 208.4 / 179.7 | 1,325 | 3,510.1 | 159.1 | 9–10 ns |
940d32f + #2134 + #2136 + #2147 (RX 7600) |
125.5 / 112.1 | 304.7 / 285.1 | 1,325 | 3,510.1 | 159.1 | 9 ns |
940d32f + #2134 + #2136 + #2147 (WARP) |
104.2 | 240.9 | 1,325 | 3,510.1 | 159.1 | 10 ns |
All 145 victory-gpu lib tests pass (--test-threads=1). PR #2136's own AtomicUsize count + RAII Drop update is sound (Pages::drop updates AtomicUsize with Release while MutexGuard is still held).
Pre-Existing watch.rs Alias Bugs Exposed / Amplified by unchanged()
Two live synthetic repros against 940d32f + #2136 fail as predicted:
Tracked::dropstripsPAGE_READONLYfrom live sibling aliases (watch.rs:255-275): Dropping trackertaover viewasees emptyholders[a]and opensatoPAGE_READWRITE, ignoring live alias trackertboverb. Writes viaastop faulting ->tb.unchanged() == trueandtb.take(b) == [](reprodropping_one_alias_tracker_keeps_live_alias_guardedpanicked).writing(a)vstb.take(b)marksbclean (watch.rs:199-202, 323-335):guard_aliasesignoresprotectfailure whenaisbusy, andtb.take(b)still clearsb->tb.changed(b/PAGE) == falseandtb.unchanged() == truewhileastays unguarded (reprotaking_alias_while_other_mapping_is_busy_keeps_page_changedpanicked).- (Source-level)
changed_here(watch.rs:480-492) callsopen()(PAGE_READWRITE) beforec.pages().insert(page)(which updatesChanged.2) andc.save(page), leaving a concurrency window where another CPU thread writes without faulting whileunchanged()reads0.
(Proposed / uncompiled fix direction:) keep a guarded in Tracked::drop whenever any alias still has holders; propagate protect success from aliases to Changed; mark dirty & save before open() in changed_here.
AI-assisted; synthetic tests only, no game files, dumps, or captures used.
…e opening Three ways a write could go unseen by a tracker of another mapping of the same pages (reported on Marvisak#2136, whose lock-free unchanged() shows them; the first two fail on main 940d32f too): - Dropping the last tracker of one mapping opened its pages although a tracker of another mapping still held them. They stay guarded until the last tracker of every mapping is gone, and are opened then. - Taking a page whose other mapping is being written unseen (writing()) could not guard it there, and still cleared the page. It stays changed. - A fault opened the page before it marked the trackers (and kept the bytes): another thread could write it meanwhile with no fault and find unchanged() true, or the saved bytes already overwritten. All trackers, those of other mappings too, are marked first, then the pages opened. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@nathanbzrr thank you, all three findings hold. Pushed as Bugs 1 and 2 are already on
Both of your repros are now tests ( Verified:
Still open, not new in this PR: alias links are one hop only. A third mapping linked only to AI-assisted; synthetic tests only, no game files, dumps, or captures used. |
…eview-fixed head)
|
In-game counters from one PC: RTX 5070 (driver 616.92), Ryzen 7 7800X3D (max processor state 99 %), Windows 11, diagnostics builds, This is not a same-frame A/B:
The scenes are different moments of the opening. Only the counters this PR controls mean much; the frame times can't be attributed to it.
AI-assisted |
…e opening Three ways a write could go unseen by a tracker of another mapping of the same pages (reported on Marvisak#2136, whose lock-free unchanged() shows them; the first two fail on main 940d32f too): - Dropping the last tracker of one mapping opened its pages although a tracker of another mapping still held them. They stay guarded until the last tracker of every mapping is gone, and are opened then. - Taking a page whose other mapping is being written unseen (writing()) could not guard it there, and still cleared the page. It stays changed. - A fault opened the page before it marked the trackers (and kept the bytes): another thread could write it meanwhile with no fault and find unchanged() true, or the saved bytes already overwritten. All trackers, those of other mappings too, are marked first, then the pages opened. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit f85763e)
|
Automated triage for the maintainers. This pull request no longer merges cleanly into Generated by Claude Code |
Port of Slaktarn700/VIctory 4f9aa10c ("Watch: ask the kernel once per
range per submission under Wine"), adapted to this tree: the journal and
watch::writes are the same; the submission begins in Host::execute_inner
(under the submission lock, before the early refresh), since queue::execute
here only queues the lists.
Run 12 here (RX 9070 XT, Proton Experimental): in the intro about 24,000
write-watch askings per 6 s took 16 s of CPU (about 0.7 ms each, Wine
emulating write watching page by page under one lock), 26 GB checked, 98%
unchanged; preparing was 2.3 s of a 3.4 s frame. Within a submission a range
the kernel already answered for is now answered from the journal; a write
between two askings keeps its dirty bit and shows in the next submission,
as title writes during a submission already do here. Windows is unchanged.
The copy statistics count askings answered from the journal.
Marvisak/VIctory#2136 (r4tedx, skip unchanged copies at the batch) was
looked at first: it adds to Marvisak's tracker what this tree's
Shadow::update already does for guarded memory (clean_spans at a region
epoch), and does not touch write-watched memory, where the cost is here.
Tested: cargo test -p victory-gpu --lib under Wine: the new test
(writes_within_a_submission_show_in_the_next) and the write-watch tests
pass; the other failures are pre-existing or flaky in the parallel run
(each passes alone). Not yet tested in the title.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Main took the same skip meanwhile (1953339, a dense DIRTY bitmap read without a lock) and the alias fixes (a3b0f36, 136e39d, 384b0c0): - shadow.rs: main's Shadow::clean/dirty_bit; Shadow::unchanged dropped. - host.rs: main's `shadow.clean()` skip in Batch::add, which now also counts the skip in the diagnostics `skipped` counter (nothing counted it on main); test a_copy_nothing_wrote_is_not_asked_for kept, in mod batch after main's tests. Main's removal of the texture_checks benchmark kept. - watch.rs: main's version (clean bit, guard_aliases returning unguarded pages, mark before open). Our AtomicUsize count, Pages guard and Tracked::unchanged dropped, with the tests main already has in kind. Kept from f85763e: dropping the last tracker of twin mappings opens both (main left the one kept guarded for the other tracker in the guard set); test the_last_tracker_of_twin_mappings_opens_both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merged Conflicts in Checked on WARP, Windows 11, one test thread: victory-gpu AI-assisted. |
Scope changed with the merge of
main63bcca43(adf58010).mainnow skips a host copy nothing wrote on its own (1953339,Shadow::clean), and has two of the threewatch.rsalias fixes this PR carried (136e39d, 384b0c0). What is left againstmainis two small things:1. The
skippedcounters count againmain'scopies per frameline printsskipped, but nothing onmainincrementsC::SkippedorC::SkippedBytes, so a run onmainalways shows 0 skipped even thoughBatch::addreturns early for every clean copy. This PR counts each early return (diagnosticsonly) and adds the testa_copy_nothing_wrote_is_not_asked_for(host.rs,mod batch), which checks that a clean copy is left out and that a guarded write or a reported write brings back only the page written.2. The last tracker of twin mappings opens both
Tracked::droponmainkeeps mappingaguarded while another mappingbof the same memory still has a tracker. Whenb's tracker then goes, onlybis opened, andastays in the guard set with no holder. That breaks the rule that the guard set never names memory that was freed and allocated again. The fix makesdropalso consider the other mappings of each page it frees, and opens each one that nobody holds on any mapping.openalready does nothing for a page that is not guarded. Test:the_last_tracker_of_twin_mappings_opens_both(watch.rs). The test was not run againstmain.Diff against
main:host.rs+46,watch.rs+33/−6.Checked (synthetic only, no title data)
On
adf58010, Windows 11, WARP, one test thread:cargo test --locked -p victory-gpu --features diagnostics --lib -- --test-threads=1: 248 passed, 0 failed, 1 ignored.cargo clippy --locked -p victory-gpu --features diagnostics --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.The earlier preparing-time figures in this PR's history (225.1 → 100.8 ms in the #2134 benchmark, and the in-game counters) measured the skip that
mainnow has. They no longer describe what this PR changes againstmain.AI-assisted.