Repository navigation
Conversation
…s several GetWriteWatch refuses a range that spans more than one allocation, and the runtime reserves title memory allocation by allocation, so a buffer over several of them was taken as not write-watched and copied whole on every refresh, even where every part of it is watched. When the question for the whole range fails, ask it again per allocation. Parts never committed cannot have been written. If a committed part is not write-watched, nothing changes: the range falls back as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Of the write-watch questions still refused in the world, almost all were ranges inside one allocation reserved but not committed at all, copied whole (as zeros) on every refresh. Nothing can have written there, so answer them with no writes; once the title commits the memory, the range is asked about normally. Also keep the test allocations instead of freeing them: the journal keeps their pages, and a later test given the same addresses found them written. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Plan only requested pages outside pending GPU writes. Use a verified reservation extent for dense groups and share a fresh observation within each group. Query journal chunks against the oldest valid shadow bytes. Adapt the clean guarded-memory path from PR Marvisak#393 and the guarded view lookup cache from PR Marvisak#490. Remap and allocation notifications invalidate their proof. Preserve exact byte coverage and journal observations across mixed allocations, including the wholly reserved case examined in Marvisak#515. Co-authored-by: KaiserBloo <kaiserbloo@protonmail.com> Co-authored-by: wrothgaril <211408787+wrothgaril@users.noreply.github.com>
|
Tested the allocation-by-allocation query on Windows alongside #514. All nine watch tests passed. This included the reserved-then-committed range and the range spanning two write-watched allocations. This was an integrated run; I did not measure a standalone performance delta. |
by_allocation asks allocation by allocation with WRITE_WATCH_FLAG_RESET. When a later allocation in the range is committed but not write-watched, it returned None and dropped the pages the earlier allocations had reported, although the kernel had cleared them. The caller then copied its own range whole, but the journal never learned of those writes, so another host copy over the same pages would not copy them again. Hand those pages back and record them in the journal before falling back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Update: #185 has since been reworked (commits Measured on the same machine and input (RTX 5080, Linux / proton-cachyos, world frames, median over the same window after world entry, with #493 in all three): old #185 6.1 s per frame; old #185 + #436, #462, #515, #600 4.3 s; new #185 alone 2.9 s, with 0.07 GB copied whole per frame against 1.3 GB. If #185 lands, this PR is not needed. Without #185 it still helps AI-assisted (Claude Code). |
|
Correction to my comment above: the third commit does not fix a bug in AI-assisted (Claude Code). |
Require the second query to identify the same reservation and cover the fallback classification directly in the synthetic test. Credit desp for the per-allocation and never-committed handling in Marvisak#515 that informed 481fb1a, and for the Wine compatibility implementation in 9e94c21. Co-authored-by: desp <me@desp.lol>
mercuryVM
left a comment
There was a problem hiding this comment.
Tested d9cb908 on Windows 11, RTX 5070, MSVC: cargo test -p victory-gpu -- --test-threads=1 46 passed, including a_range_over_several_watched_allocations_is_watched. Clippy's 1 warning is the existing one in host.rs.
by_allocationwalksVirtualQueryregions grouped byAllocationBaseand asksGetWriteWatchonce per committed allocation. A wholly reserved range correctly reports no writes, because nothing uncommitted can have been written.- The failure path matters most and is handled: the earlier allocations'
GetWriteWatchcalls already reset their bits in the kernel, so those pages go intolostand are stamped into the journal instead of being dropped. - As your status note says, this and #185's reworked
watch::writesoverlap. On mercuryVM/VIctory main (which doesn't have #185) this helps on its own. If #185 lands upstream, this should be closed rather than rebased.
AI-assisted (Claude Code).
… by allocation when a range spans several Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Test report on a 6 GB / 16 GB laptop. On this machine this PR made write-watch time worse: 475 → 1,605 ms per world frame, alone on the base below. Setup: RTX 3050 6 GB Laptop (NVIDIA, driver 32.0.16.2124), i7-13700H, 16 GB RAM, Windows 11 26300, diag build. Title 1.0.2.1, Series X profile, the story load. Base tree:
My guess, not verified: the expensive part here is asking inside one huge allocation. #776 measured a 2.2 GB allocation at about 2.2 ms per asking. Splitting a range into per-allocation askings then multiplies the expensive ones. #393 avoids most askings, and with it the time stays low either way (29 ms with all three, 14 ms without this PR). One run per row, spread about ±10%. AI use: Claude Code (Claude Opus 5.5) built the trees, ran the title on my machine and drafted this report; results are from the runs described. |
…itives, capture), verified together Merges #124 #119 #515 #934 #484 #143 #1191 #278 #553 #153 #270 #1158 #1204 #1220 #488 #1146 #631 onto main (ffe310e), each head unchanged, no conflicts, no changes of mine. cargo clippy --workspace --all-targets --locked -- -D warnings, with and without --all-features, is clean and cargo test --workspace --locked passes (372 passed, 8 ignored; main has 342 passed, 6 ignored). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ures, device, DXGI, objects, primitives, capture) Kept from our side: - watch.rs: the per-submission journal (Journal.round, new_round, covered, cover, writes_once) and the WatchKernelUs/WatchGuardUs/WatchPages counters; the guard timing now wraps the PR's by-allocation fallback, and the per-allocation kernel askings (#515) count into WatchKernelUs and WatchPages too. Both sets of watch tests kept. - texture.rs: our version (CommittedRegions, RUNTIME_WRITES and the last.checked skip, changed-subresource detiling, mip drop, widened packed16) with the PR's footprint fix on top: upload footprints end at the last row's data bytes (GetCopyableFootprints row sizes), detiling goes through detile_plane, title_written_flags, overflow-checked committed() and refresh range, and the PR's tests. #143 was already merged; the SCRATCH -> UNWATCHED_SCRATCH rename is left out (no #472 here). - copystat.rs: our counters and lines, plus the PR's process memory line. - primitive.rs: our position+color fast path, plus the PR's zero and overflowing stride guards in the generic path. - #124, #119, device.rs and object.rs changes were already in our tree. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The tests #1418 brought (#515's per-allocation askings) reserve address space, release it and allocate again at fixed addresses, while ours free views and blocks and remap: run in parallel they took each other's addresses (and their journal entries), and a remapping reset the guards another test had just made, so 1 run in ~5 failed. The tests that take ranges or remap now run one at a time, and the new ones forget the journal's pages of their range first, as written_pages_... already did. No assertion changed; the journal and per-allocation code are as merged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…on when a range spans several
…on when a range spans several
Status (2026-11-24): not needed if #185 lands as it is now. #185 was reworked after this PR was opened (
481fb1a,8bec415,5aca0db;481fb1arefers to "the wholly reserved case examined in #515"): it groups write-watch questions by reservation up front and handles what this PR handles; the two conflict inwatch::writes. Measured (world frames, median): old #185 + this and #436, #462, #600 4.3 s per frame, new #185 alone 2.9 s. Without #185 this still helpsmain's ordinary refreshes. (Correction: the third commit fixes a case this PR's own first commit introduced, not one inmain, whose single question resets nothing when it fails.) Details in the comments below; the rest of this description is as written before.Problem
watch::writesasksGetWriteWatchabout a whole range at once. The kernel refuses a range that spans more than one allocation, and the runtime reserves title memory allocation by allocation, so a buffer over several of them was taken as not write-watched:writesreturnedNoneand its range was copied whole on every refresh, although every part of it is watched.In the world (with #185's direct SRV refreshes), a diagnostic counting the failed questions per buffer showed thousands per frame, on ranges of 133 KB to 3.9 MB on average, starting in allocations that are only partly committed (for example a 64 KiB allocation at
0x756000000with its last 56 KiB reserved). They came to 1.6–5 GB of whole copies per frame.Change
crates/victory-gpu/src/watch.rsonly. When the question for the whole range fails,by_allocationasks it again allocation by allocation (VirtualQueryfor the boundaries). Parts never committed cannot have been written and are not asked about. If a committed part is not write-watched, nothing changes:writesfalls back to guarding orNoneas before. A range inside one allocation is not asked again.Measured
RTX 5080, Linux (proton-cachyos, vkd3d-proton 3.2.0), Series X 1.0.2.1, diagnostics build with #185, #436, #462, #440, #493 (+#336), #259, #177, #151, Enter into story mode at about 35 s. Before: the same stack without this change and without #464; after: with this change and #464 (unmapped guarded view blocks, the same kind of waste for view memory), so the two effects are not separated here:
Frame time does not follow the bytes: what is left of a frame is mostly CPU time per refreshed range (87,000–105,000 direct SRV ranges took 2.7–6.4 s), not bytes copied. Part of that may be this change asking
VirtualQueryfor allocation boundaries again on each refused range; caching them is a possible follow-up.Of the questions still failing at first, 98 % were ranges inside one allocation reserved but not committed at all; the second commit answers those with no writes (nothing can have written there; once committed, the range is asked about normally).
Both commits, measured (same stack, with #514 in place of #464; #514 includes it), 7.5 min, about 6 min in the world, no GPU hang:
What remains of a frame is mostly the number of questions, not bytes: in late frames copies were 36–99 MB and still took 4.5–7.6 s. The whole-range question fails first for almost every refreshed range (they span several allocations), and
by_allocationthen took 0.4–0.9 s per frame (59,000–141,000 calls, 93,000–279,000VirtualQuerycalls). Remembering which ranges span several allocations, and their boundaries, is the next step.Third commit: a fix
by_allocationasks withWRITE_WATCH_FLAG_RESET. When an allocation later in the range is committed but not write-watched, it returnedNoneand dropped the pages the earlier allocations had reported, which the kernel had already cleared. The caller copied its own range whole, so it saw them, but the journal never did, so another host copy over the same pages would not copy those writes. The third commit hands those pages back and records them before falling back;writes_found_before_a_refusal_are_keptfails without it (the write is gone:[]instead of the page) and passes with it.Tests
New
a_range_never_committed_has_no_writes: a reservation not committed has no writes; committed and written afterwards, the write is found. Newa_range_over_several_watched_allocations_is_watched: two adjacent write-watched allocations, written in each, asked about as one range. It fails onmain(writesreturnsNone) and passes with the change. Both test allocations are kept rather than freed, since the journal is shared and a later test given the same addresses would find their pages written. Thewatchtests pass, also merged with #464 (itsunmapped_blocks_are_reported_once_until_mappedincluded).cargo clippyreports nothing new inwatch.rs.Related
VirtualQueryabout every region of the range, so one committed page anywhere in it is enough to ask the kernel normally;a_range_never_committed_has_no_writescommits and writes after the first question and checks the write is found.AI-assisted (Claude Code).
🤖 Generated with Claude Code