Skip to content

GPU: a write through one view notes the other views written instead of opening them - #853

Open
larelgit wants to merge 1 commit into
fxceless:mainfrom
larelgit:perf/view-guard-lazy-aliases
Open

larelgit wants to merge 1 commit into
fxceless:mainfrom
larelgit:perf/view-guard-lazy-aliases

Conversation

@larelgit

Copy link
Copy Markdown

With the view guard (8dd30ab), the first write through any view of a guarded page opens every other view of it read-write, one VirtualProtect each, and the next check makes them all read-only again, one more each. In the first room that is about 4.7 to 4.8 million views opened a run here (the views opened by a write through another counter), so some 9.5 million protection changes on the submitting and copy-back threads.

This change leaves the other views read-only. A write through one view now only notes the other views written (protected, no longer clean). The next check of any of them reports them written, as before, and guards the whole set again (protect_aliases, which protect now also uses). A write through one of those other views still faults once and is opened by the handler, as before.

Why the rest stays right:

  • protected still means exactly "read-only", so writing (before the kernel writes into title memory) opens these blocks as it opens any guarded block.
  • guard already treated a protected block that is not clean as written; views_mapped leaves blocks in that same state.
  • Only open changes for the other views, plus the protected-not-clean branch of guard, which now guards the other views again so a view no copy checks is not left open.

Measured

RTX 5080, Ryzen 7 7800X3D, 32 GB. Diagnostics build, the same checkpoint in the first room (cell window), median ms a frame over 260-355 s of each run. The first run of each binary is listed apart.

On main (9376fd6), alternated:

Build Runs ms/frame Preparing (copies) Cell wall / window mesh / shirt print
main 3 186, 189, 188 (first run 192) 70-72 ms (39-41) there in all
this branch 3 184, 181, 185 (first run 183) 65.5-67.7 ms (35.5-37.1) there in all
main, VICTORY_VIEW_GUARD=0 3 172, 167, 174 59-61 ms (29-31) wall missing in 2 of 3

On 8dd30ab, alternated: main 182-184 (5 runs), this change 178-181 (3 runs, first run 179); wall drawn in all.

Counters per run on 9376fd6: views opened by a write through another 4,848,705 and 4,653,814 on main; with this change 707,948, 661,846 and 732,331 views noted written (only views that were clean count), and no view is opened that way. Guard faults are about the same (558-583 against 538-552).

So this takes back about 4 ms (mean 187.7 to 183.3) of the guard's 15-20 ms here. The rest is elsewhere: #812 (Peppacodes) measures the walk over absent blocks at 26 ms of the submitting thread on 9376fd6, which this does not touch.

Tests

  • New watch::tests::a_view_no_copy_checks_is_guarded_again_by_the_checked_one: a write through the other view opens only that view and leaves the checked one read-only; the next check reports it and guards the other view again; a later write through the checked view is still seen.
  • victory-gpu tests: 160 passed, 0 failed, 4 ignored on f85101b (145 passed on 9376fd6).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings (on 9376fd6): nothing in the changed files; the three findings main itself has (placed_filler_twins, sort_unstable_by_key, depth_written) are still there.

The branch is rebased onto f85101b, which does not touch watch.rs; the runs above are of the same change on 9376fd6 and 8dd30ab.

#763 (AscilCH) also edits open's alias loop; whichever goes in second has a small conflict there.

(Change, runs and this note by Claude Code with Claude Opus 5.5, at the account owner's request.)

🤖 Generated with Claude Code

…f opening them

With the view guard on, the first write through any view of a guarded page
opened every other view of it read-write (one VirtualProtect each), and the
next check guarded them all again (one more each). The other views now stay
read-only: they are only noted written, and guarded again together when a
check finds the pages written. A write through one of them still faults
once and is reported by the next check, as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-25T10:50:56.674383Z d1980ad PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

ExoCalibra added a commit to ExoCalibra/victory-exo that referenced this pull request Nov 25, 2026
ExoCalibra added a commit to ExoCalibra/victory-exo that referenced this pull request Nov 25, 2026
…rtualProtect opening them"

This reverts commit 1d0eefb, reversing
changes made to d39d7c8.
dkdknight added a commit to dkdknight/victory-fork that referenced this pull request Nov 25, 2026
…, small buffers on the card, parallel page merge, absent blocks asked outside the guards' lock, PR fxceless#853 alias guard, GPU_UPLOAD windows, legacy multiply and wide scalar loads); view guard back on in play-lod.ps1

Written by AI agents from this session's leads, reviewed and built here;
measured separately. Switches:
- VICTORY_INDIRECT_CARD_BUDGET (on; =0 as before): the clamp's per-list
  budget counter in card memory, zeroed by the clamp shader's own entry,
  instead of a system-memory buffer with 1-4 atomics per clamp over PCIe
  (after fxceless/victory-fork PR fxceless#220).
- VICTORY_CARD_BUFFERS_MIN_KB (off): card copies for title buffers under
  1 MiB, floor 64 KiB (after PR fxceless#200).
- VICTORY_MERGE_THREADS (4; =1 as before): merge_under_writes reads
  contiguous stale pages in one call and compares them on scoped threads;
  changed_runs skips equal bytes 64 at a time; merging stays in order on
  the submitting thread.
- VICTORY_GUARD_ABSENT_BITS (on; =0 as before): absent blocks still
  uncommitted are dropped from a range's runs before the guards' lock is
  taken (nothing marked clean, unlike parking).
- PR fxceless#853 (Peppacodes et al.) ported: a write through one view no longer
  opens the other views of the page; they are noted written and guarded
  again together (plus clean_bit cleared for the alias).
- VICTORY_UPLOAD_WINDOWS_MB / VICTORY_UPLOAD_WINDOWS_ROOM_MB (off): windows
  in GPU_UPLOAD (ReBAR) heaps, written by the CPU straight into card memory.
- VICTORY_LEGACY_MUL=1|2, VICTORY_SMEM_WIDE=1 (off): plain multiplies for
  exact legacy-multiply cases, scalar buffer loads 4 dwords at a time.
- play-lod.ps1: VICTORY_VIEW_GUARD=0 removed (walls of the cell were
  missing without it: same shot, screenshots).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
oz-stanislav-zhukov added a commit to oz-stanislav-zhukov/victory-fork that referenced this pull request Nov 25, 2026
…ack on Windows)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MamaLeVrai

Copy link
Copy Markdown

Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present. I merged this PR's head d1980ad into main f85101b in a throwaway tree (no conflict). cargo clippy --workspace --all-targets --locked -- -D warnings fails with exactly the errors main itself has on this machine (placed_filler_twins, depth_written, a sort; PR #841 fixes them), also with --all-features; this PR adds none. cargo test --workspace --locked: run 1: 556 passed, 0 failed, 11 ignored; run 2: stopped at indirect::tests::warp_budget_saturates_without_wraparound_and_preserves_draw_fields (the one that fails on main itself most runs here (PR #849 and #847 fix its assertion)) (main alone: 555 passed, 0 failed, 11 ignored). The title was not run, so this says nothing about in-game effect. No game data.

AI-assisted (Claude Code); no game data.

@larelgit

Copy link
Copy Markdown
Author

Measured again on f85101b, this time with the README's new switches on, because with them the submissions are prepared on the layer's own thread and the card is much less of a wall. Same machine, scene and method as in the description. Runs alternated with main (and with a third build not part of this pull request).

Settings in every run: VICTORY_ASYNC_SUBMIT=1 VICTORY_QUEUE2=1 VICTORY_INDIRECT_WINDOW=1 VICTORY_TEXTURE_NO_WAIT=1 (no MERGE_GAP).

Build Runs ms/frame Preparing (copies) Card busy
main f85101b 3 131, 134, 158 70.1 (38.7), 71.9 (38.9), 87.4 (49.2) ms 72-77%
this branch on f85101b 3 129, 140, 141 65.7 (34.5), 72.5 (38.1), 74.9 (39.3) ms 77-79%

main with the same settings in an earlier series the same day: 134, 133, 133.

So with these switches there is no gain to show: the spread between runs (129 to 158) is larger than the about 4 ms this saved with the defaults, and the branch's median (140) is not better than main's (133-134 over six runs). I can't tell from three runs whether it is worse or only noisy; the third main run (158, with copies at 49 ms) is unlike the other five. The defaults numbers in the description stand (three runs each on 9376fd6 and on 8dd30ab). Whether a change that only pays without the switches is worth having is your call; I'm fine with closing this if the switches are to become the defaults.

Picture: cell wall, window mesh and shirt print there in all six runs; no device loss.

(Runs and this note by Claude Code with Claude Opus 5.5, at the account owner's request.)

akus-elinius pushed a commit to akus-elinius/victory-fork that referenced this pull request Nov 25, 2026
…f opening them (fxceless#853)


PR: fxceless#853
Head: d1980ad

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
akus-elinius added a commit to akus-elinius/victory-fork that referenced this pull request Nov 25, 2026
…SET)

fxceless#812 answers from Guards::unclean, and fxceless#853 marks the other views written
by taking them out of clean without adding them to unclean, so the fast
path did not see the write (4 watch tests failed with both; each PR alone
passed). Two changes:
- open: a view marked written also goes into unclean, as open_here does.
- guard_unclean: when a block that is still read-only is protected again,
  protect_aliases, as guard does since fxceless#853.
With this the 14 watch tests pass, also with VICTORY_VIEW_SET=0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PiloteCode added a commit to PiloteCode/victory-fork that referenced this pull request Nov 25, 2026
…not-clean set, and its check guards the other views again

With the view set (fxceless#812) an asking is answered from the view blocks that are
not clean. The write through another view (fxceless#853) now leaves the checked view
read-only and only takes it out of the clean set: it has to go into the
not-clean set too, or its next check finds nothing written and its copies
keep the bytes from before the write. That check, like the walk, guards the
other views of the page again (the write opened the one it went through).
PiloteCode added a commit to PiloteCode/victory-fork that referenced this pull request Nov 25, 2026
…celess#24/fxceless#104), null CBVs (fxceless#304), tables at list cuts (fxceless#742), heap entries (fxceless#589), barriers (fxceless#787), depth-stencil UAV barriers (fxceless#214), windows ending at recorded writes (fxceless#663), sRGB views (fxceless#644), wide accesses across pages (fxceless#846), view-guard costs (fxceless#812/fxceless#853), the fill latch (fxceless#860), pipeline waits (fxceless#709), robustness; opt-in fxceless#868/fxceless#845
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants