Skip to content

Fix #721, #722: copy-back writes only changed bytes; mark pages current conditionally - #2009

Open
tharun-37 wants to merge 2 commits into
Marvisak:mainfrom
tharun-37:fix/shadow-copyback
Open

tharun-37 wants to merge 2 commits into
Marvisak:mainfrom
tharun-37:fix/shadow-copyback

Conversation

@tharun-37

Copy link
Copy Markdown

Split from #2000 per review feedback (gpu-only, Windows path). #721: copy_back now writes only changed bytes. #722: page marked current only if title still matches. Builds clean; shadow tests pass.

@jeremygold02

jeremygold02 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Triage verdict — Needs changes (57fdaea)

Evidence

Checks and limits

  • I did not reproduce that interleaving; the updated test assertions count bytes copied and do not schedule a write in this window.

Next step

  • I’d preserve those tests and add a controlled write between the compare and the clean-state transition. Also worth carrying forward its sparse-write cost check: this head makes one write_mapped call per changed run, so a passing dense or small test does not bound that cost. Prior sparse-write discussion

This verification was AI-assisted.

@upipibi

upipibi commented Nov 25, 2026

Copy link
Copy Markdown

Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at 57fdaea. victory-gpu: 141 passed, 2 failed, 2 ignored. This PR adds no test of its own for #721 / #722, so this only shows the existing tests still pass. The 2 are #1744's NVIDIA failures on main (dynamic_slots_are_held_until_released and lists_share_a_table_and_copies_keep_their_views, the heap-cap ones). Same as main on this hardware. Not run: a title.

AI-assisted (Claude Code).

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.

Copy-back writes only changed bytes + pages marked current (#721/#722) — part of a three-way split of #2000 (which fixed #721/#722/#726 in one PR): #2009 covers copy-back, #2010 covers #726's v_med3 NaN fix (shader, macOS-tested separately). Maintainer should compare #2000 vs #2009+#2010 and pick.

github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 25, 2026
… only changed bytes; mark pages current conditionally

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.
Needs work.

The targets are real (#721, #722), and the change in crates/victory-gpu/src/shadow.rs Shadow::copy_back points the right way. It is not ready as is:

What would change the verdict: regression tests for both races and a fix for the per-run write cost (or numbers showing it is fine).

CI: passing (check).


Generated by Claude Code

Xeltax added a commit to Xeltax/VIcky that referenced this pull request Nov 25, 2026
…ck as one (opt-in); copy-back timings

Putting shader writes back into title memory wrote each run of the GPU's
bytes with its own NtWriteVirtualMemory. With the structure builder on, a
frame put back about 350 pieces holding 780,000-910,000 runs (about 2,400
per 64 KiB piece: the builder changes a few bytes here and there in each
node), 248 ms a frame on an RTX 4080.

VICTORY_BACK_JOIN=<n> writes runs no more than n bytes apart as one call,
gaps included (title bytes read just before). With n = 256 the same frames
take 1,300 calls and 1.8 ms of writing; copying back fell from 327-354 ms to
58-65 ms a frame and the frame from 849-916 ms to 502-583 ms (one run each).
Unset or 0: each run alone, as before (upstream Marvisak#2009). The shortcut: a
title write landing in a gap between the read and the write is lost; the
relay's merge already writes whole stretches the same way.

Also: a frame-rate line of the copy-back's pieces, runs, kernel writes and
the time reading and merging, opening guards and writing, and of the
relay's merges.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A4bpLmErkufJL3LGgfR561
@ajsem1337

Copy link
Copy Markdown

Deterministic reproduction of the guarded copy-back race

Following up on the race identified in review, a test simulates a GPU write by changing the host copy. During guarded snapshot copy-back, a test hook makes a second thread write to the tracked title page just before Tracked::taken.

Tested build Marker in title memory per seed Marker in host copy after two more submissions
main (940d32f) 32/32 0/32
main with #2009 (57fdaea) 32/32 0/32

Three seeds on main and two on the PR gave the same result. The other eight cases met their visibility deadlines on both builds.

On #2009 the write lands after the final comparison and before the page is re-protected. That write is marked as already copied. Marking the page current requires validating its bytes after re-protection and preserving later writes, including writes through aliases. Prior review · Related earlier report

Reproducer (test, test-only hook, and the one-line assertion change for this PR): https://gist.github.com/ajsem1337/551639fa596a63f63282956d42917b0c

Found with AI assistance (Codex wrote the original test, Claude Code ported it to main and ran it).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants