Repository navigation
Conversation
Batch::flush ran each copy's Shadow::update on the submitting thread: a world frame's ~80 copies move ~265 MB through one ReadProcessMemory thread. Each copy appears once in the batch (pending is keyed by its shadow), so the updates touch disjoint state and run via the existing texture::in_parallel (up to 4 threads); the current-range merge stays serial and in the original order. Synthetic test: 16 copies x 64 pages (64 MiB) flush in ~6.5 ms parallel vs ~7.9 ms serial on a 12-core B580 host, same bytes copied. No game data; synthetic pools only. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
|
Claimed on #1633 in comment 7195935695 (parallelize the serial submission-prep buffer copies). Head 4ed54fc. Will post |
Dukestar69
left a comment
There was a problem hiding this comment.
Reviewed the diff and verified locally on Windows 11 x64 (RTX 5090):
- Parallelizing disjoint
Shadow::updatecalls inBatch::flushviatexture::in_parallel(deduplicated perShadowinpending, re-ordered by index before updatingself.current) is clean and sound. cargo test -p victory-gpu --lib host::batch:: -- --test-threads=1(RTX 5090): 2 passed, 0 failed (includingmany_copies_refresh_in_parallel_and_copy_the_same_bytes).cargo test -p victory-gpu --lib shadow:: -- --test-threads=1(RTX 5090): 10 passed, 0 failed.cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
fuzeofficlal
left a comment
There was a problem hiding this comment.
Looks good. Batch::add deduplicates entries by Arc::as_ptr(shadow) via self.pending, so each work[i] in Batch::flush (crates/victory-gpu/src/host.rs:2440-2484) operates on a distinct Shadow, and sorting done by index before updating self.current keeps the state merge deterministic. Distinct shadows overlapping the same 64 KiB pages or physical-page aliases still serialize page protection and dirty-set transitions safely through GUARDS -> Changed.0 inside watch::Tracked::take_split.
Verified merged onto origin/main (63bcca43) on a 16C/32T host with RTX 5090 and WARP:
cargo xtask policy(191 files ok) andcargo clippy --locked -p victory-gpu --all-targets -- -D warnings(default and--features diagnostics) pass cleanly.host::batch::(2/2) andshadow::tests::(9/9) pass on both RTX 5090 and WARP (--features diagnostics,VICTORY_D3D12_DEBUG=1).- Measured 64 MiB flush (
many_copies_refresh_in_parallel_and_copy_the_same_bytes): 4.84 ms parallel vs 7.75 ms serial (default build); 6.09 ms vs 9.34 ms on RTX 5090 and 6.61 ms vs 9.08 ms on WARP (diagnostics+ Debug Layer). - Stress-tested 20 rounds of parallel
Batch::flushwith 1 outer 2 MiB shadow, 8 distinct overlapping inner shadows, 1twin_viewsphysical-alias shadow, and 4 active non-marked GPU write snapshots (sync_before) on both RTX 5090 and WARP underVICTORY_D3D12_DEBUG=1: all pages matched across every overlapping/aliased shadow with zero lost dirty marks or deadlocks.
Minor non-blocking observation: PREPARING[0] (host.rs:2458) now sums per-worker thread microseconds inside in_parallel (matching PREPARING[2] in texture.rs:549), while copystat::C::FlushUs tracks wall-clock flush time.
|
Measured in game on an RTX 5090 (driver 620.73.04), Linux, GE-Proton11-14 Wine with its vkd3d-proton, GTA VI's opening prison yard, warm cache; base is
About 2 ms off preparing, inside the spread of the controls (77-81 ms). In this scene refreshes cost ~24 ms of preparing, of which the change checks are ~13.5 ms and waiting on AI-assisted (Claude); measured on my machine, no game data shared. |
|
Closing: this duplicates #2051 (@0xkn0wh3r3, "a submission's refreshes copy on several threads"), which does the same thing at the same level — drains The one thing of mine worth carrying over is the measurement, since #2051's body has none. Windows 11, Intel Arc B580, 12 cores, synthetic (no game data): 16 write-watched pools of 64 pages (64 MiB) dirty in one ~1.2-1.3x on the pure copy path — the synthetic ceiling is low because same-process |
What
Batch::flushran each pending copy'sShadow::updateon the submitting thread, one after another. A world frame asks for ~80 copies moving ~265 MB through a singleReadProcessMemorythread.Each copy appears at most once in the batch (
pendingis keyed by the shadow's pointer), so the updates touch disjoint state —ShadowisSend + Sync(shadow.rs:137-139) and holds its own locks; the copy itself isReadProcessMemory, which is thread-safe. The flush now drains the refreshes and runs the updates through the existingtexture::in_parallel(up to 4 threads, same helper the texture refresh uses). Thecurrent-range merge stays serial afterwards, in the original order, so its result is unchanged.copystat/PREPARINGaccounting is atomic and per-item, unchanged in meaning.Claimed on #1633 (parallelize serial submission-prep buffer copies). Implemented at the
Batch::flushlevel, across shadows — not insideShadow::update— to stay clear of NEW-… partial-page-granularity work on that function.Measurement (Windows 11, Intel Arc B580 host, 12 cores, synthetic only — no game data)
New test
host::batch::many_copies_refresh_in_parallel_and_copy_the_same_bytes: 16 write-watched pools x 64 pages (64 MiB), all pages dirty, oneBatchholding all 16 copies:~1.2-1.3x on the pure copy path (same-process RPM already saturates ~8 GB/s single-thread on this host, so the synthetic ceiling is low); the test asserts the host copies hold exactly the title's bytes after both passes. On the real frame the per-copy kernel work that dominates (write-watch queries, soft faults on fresh snapshot buffers, the unmapped-page fallback walks) also runs inside
update, so the ~927 ms copy phase of the 1,842 ms world frame is what this parallelizes across up to 4 threads — title-side number to be taken by whoever can run it.Verification
cargo clippy --workspace --all-targets --locked -- -D warnings— cleancargo clippy --workspace --all-targets --all-features --locked -- -D warnings— cleancargo test -p victory-gpu --lib --locked --no-fail-fast— 230 passed, 2 failed: the known B580 baseline failures pristine main also fails (descriptor::host::tests::dynamic_slots_are_held_until_released,memory::tests::lists_share_a_table_and_copies_keep_their_views, Test report: RTX 5070 (Blackwell), Windows 11, 70564ae: 471 passed, 5 failed, 7 ignored (4 from the 1,000,000 view heap cap) #1744/Test report: Intel UHD (Raptor Lake Xe-LP), 70564ae: victory-shader 201 passed, 8 failed (3 missing-feature skips, 5 different results) #1829)rustfmt --config-path rustfmt.toml --edition 2024 --check crates/victory-gpu/src/host.rs— 85 diff hunks, identical to the origin/main baseline of the same file (repo is deliberately not default-fmt clean; no new hunks)cargo xtask policy— 193 files okNo game data used anywhere; synthetic pools only.