Repository navigation
Conversation
… round of the guard lock Batch::flush brought each copy up to date on its own: a Tracked::take_split per copy, each with written pages taking the global guard lock that the title's write faults and marked copy-back hold too. A world frame made ~3,200 such rounds and spent ~8 ms of its preparing waiting for the lock. Now a flush looks up each copy's written pages in its range under the copy's own lock (shadow::plan, Tracked::written), takes the pages of all of them in one hold of the guard lock (watch::take_written: other mappings guarded once per page, one protection change per run of consecutive pages across copies), then copies each copy's runs (Shadow::copy_taken). take_split and Shadow::update are the same path for one tracker or copy. The copies line counts the guard-lock rounds of takes. Tests: watch::tests::a_batched_take_takes_the_written_pages_of_every_tracker, watch::tests::batched_refreshes_under_concurrent_writes_lose_no_write, host::batch::overlapping_copies_in_one_batch_each_take_the_written_pages.
|
Offscreen Wine/NVIDIA verification of exact production
Coverage distinction: these tests initialize the real RTX 4060 Laptop D3D12 device and inspect persistent host-buffer mappings. They do not dispatch a shader or submit a GPU command list. This is guarding/copy-consistency coverage, not a GPU-execution, loading frame-time, contention, peak-RAM, or title performance measurement. I have not reproduced the separate RTX 5090 frame-time numbers or performed a matched parent benchmark here. Environment: Linux 6.17, 16 GiB RAM, RTX 4060 Laptop 8 GiB/NVIDIA 590.48.1, Wine 11, NVIDIA masking disabled; diagnostic-relaxed-vtable vkd3d AI-assisted verification. 28 Nov CPU-only follow-through, same production
The median reductions are 14.6% / 8.6% in this uncontended synthetic workload; ranges overlap, especially with gaps. This supports the batching mechanism but does not predict a title-frame gain: our actual scene has overlapping watches/protection/fault-handler time, contention and different ranges. No GPU device was initialized or command dispatched in this new measurement. Fresh intended-tree compile36.84s; benchmark1/1 pass in0.92s. The temporary probe was archived then removed, leaving production unchanged. Evidence Mixed-runtime integration, 28 November 08:03 UTCPorted this production change onto the existing dirty local runtime (base
Same Wine 11 / RTX 4060 Laptop / NVIDIA 590.48.1 / diagnostic-relaxed vkd3d Commands used the existing Wine wrapper, |
|
@pickles976 thanks for checking the exact head on a second NVIDIA card, and for spelling out the coverage boundary: right, these fixtures exercise the guard/copy consistency with a real device's host mappings, not GPU execution. The frame-time effect is only from our 5090 runs (two adjacent pairs) and is stated as such in the description. AI-assisted (Claude); no game data shared. |
|
I checked the diagnostics overlap with #3594. The exact heads On Windows WARP the same two-frame synthetic window printed one guard-lock round per frame and copy-back averages of 1.0 eligible, 0.5 wrote bytes and 1.0 withheld. The next window printed zero for all four figures. The existing synthetic byte checks passed, and the diagnostics suite passed 249 project GPU tests plus the SDK identity check, with one ignored. Strict GPU Clippy passed for default and all features. The asset policy check passed. @neonbyte1 and the maintainers can use the tested conflict resolution if both changes are applied. Please retain Git authors on cherry-pick or rebase. If you fold my work into another commit, please include |
|
@andrewpozdnakov7-jpg thanks, that saves a rebase. I'll keep #3585 independent of #3594 (it's a one-line counter overlap, not a behaviour one); whichever lands second takes your AI-assisted (Claude); no game data shared. |
What's wrong
A submission's refreshes are batched per copy (
Batch,crates/victory-gpu/src/host.rs:2399), butBatch::flush(host.rs:2440) then brings each copy up to date on its own:shadow.update(from, to - from)per copy (host.rs:2447) →Shadow::update_tracked(shadow.rs:607) →Tracked::take_split(watch.rs:478). Each take with a written page in its range takes the global guard lock (watch.rs:503), guards the pages' other mappings, makes the pages read-only and drops them from the copy's changed set.The copies only ever read pages recorded as written, so the volume is small (~130 MB a frame here). The cost is the lock: a world frame makes one round of
watch::GUARDSper copy with written pages, 3,229 rounds a frame in our runs. The title's write-fault handler and marked copy-back hold the same lock, so these rounds mostly wait: 7.8 ms a frame inchange checks: … waiting for the guard lock, on the submitting thread, beforeExecuteCommandLists.(The
copies per frameline'sMB checked— 6.3 GB a frame here — is the span asked, not bytes compared:take_splitlooks only at the copy's set of written pages in it.)The fix
Batch::flushworks in three phases:shadow::plan→Tracked::written): for each copy, the written pages in its asked range, read under the copy's own set lock only. A copy with nothing written there stops here. Memory that is not tracked is copied whole, as before.shadow::refresh_planned→watch::take_written): the whole pages of all copies, sorted and deduplicated, in one hold of the guard lock. Each page's other mappings are guarded once, consecutive pages across copies share oneVirtualProtect, then each copy's set drops the pages taken.Shadow::copy_taken, the former tail ofupdate_tracked): per copy, one copy per contiguous run, zeros for unmapped runs, untracked parts whole, snapshot sync where this submission's shaders write.Tracked::take_splitis nowwritten+take_writtenfor one tracker, andShadow::updateisplan+refresh_plannedfor one copy, so there is one take and one refresh path. No switch: the guarantee is the one a single take gives (below), the existing take tests now run throughtake_written, and the change was measured in the title behind a switch first.Why no write is missed. A page leaves a copy's set only under the guard lock, once it is guarded at every mapping (pages that can't be guarded stay changed and are still copied). Copies are read after the take. So a title write before the guard is in the copy; a write after it faults and marks the page again. Writers that don't fault (kernel reads, DirectStorage, remaps, copy-back) mark under the guard lock, so before the page leaves the set (it's in the copy) or after (it's changed again). A page written between the look-up and the take isn't in the plan and stays changed. A page only partly in the asked range is copied in part and stays changed. The window between take and copy is longer than before, but correctness never depended on its length.
The copies line gets
N guard-lock roundsnext to the guard-lock wait (C::TakeRounds, diagnostics only).Run splitting looks up unmapped pages by binary search, removing the O(n²)
unmapped.containsthat #3156 also fixes.Tests
CPU only,
watch.rs:a_batched_take_takes_the_written_pages_of_every_tracker:batched_refreshes_under_concurrent_writes_lose_no_write:taken = whole): both tests fail;GPU, skipped without a device:
host::batch::overlapping_copies_in_one_batch_each_take_the_written_pages(two overlapping copies in one batch, each gets its written pages; a later write is seen by both). The existinga_copy_is_refreshed_once_per_submission_by_the_pages_writtencovers one copy.In the title
RTX 5090, Linux, GE-Proton11-14 Wine with its vkd3d-proton. Stack as listed in #3425, plus overlap and our pending early-release/barrier changes. Prison yard, diag build, two adjacent on/off pairs of the same exe (the change behind a switch there), 420 s each:
Pictures unchanged.
Related
VirtualProtectoutside it. This PR cuts the number of rounds instead; they compose, with a textual overlap intake_split.mainby the dirty bit.None of them batches takes across copies.
Verification
cargo clippy --workspace --all-targets -- -D warnings, with and without--features diagnostics(x86_64-pc-windows-msvc): clean.cargo xtask policy:asset policy: 191 files ok.origin/main.cargo test -p victory-gpu --lib watch::under Wine, with and withoutdiagnostics: 17 passed. Also passes on the default parallel test threads: the round and protection counts the batch test checks are per thread.left: (1, 0)andpage … differs from its copy and is not changed); the second fails the concurrent one.--test-threads=1, filtershost::batch:: shadow:: watch:: host::title_copies:: --skip shadow::run_tests): 31 passed, 0 failed. That ishost::batch2 (both batch tests),host::title_copies2,shadow::tests9 plus 1 othershadow::test, andwatch::tests17.AI-assisted (Claude); measured on my machine, no game data shared.