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

Open
github-bot wants to merge 1 commit from github-bot/gh-853 into main AGit
Owner

@⁠larelgit on GitHub · 2026-11-25 10:47 UTC · original
larelgit:perf/view-guard-lazy-aliases → main · +71 −26 · 2 files · 1 commits · open

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

**@⁠larelgit** on GitHub · 2026-11-25 10:47 UTC · [original](https://github.com/fxceless/victory-fork/pull/853) `larelgit:perf/view-guard-lazy-aliases` → `main` · +71 −26 · 2 files · 1 commits · open 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](https://claude.com/claude-code)
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 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:52:34 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-25 10:47 UTC · original · edited 2026-11-25 10:50 UTC

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.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-25 10:47 UTC · [original](https://github.com/fxceless/victory-fork/pull/853#issuecomment-7160182109) · edited 2026-11-25 10:50 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"d1980ad43d42d4665ada02ede1ec887047ede853","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-25T10:50:56.674383Z">2026-11-25T10:50:56.674383Z</relative-time> | `d1980ad` | PR opened | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). 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. </details> </details>
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-25 12:23 UTC · original

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.

**@⁠MamaLeVrai** on GitHub · 2026-11-25 12:23 UTC · [original](https://github.com/fxceless/victory-fork/pull/853#issuecomment-7162309395) 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.
Author
Owner

@⁠larelgit on GitHub · 2026-11-25 12:49 UTC · original

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.)

**@⁠larelgit** on GitHub · 2026-11-25 12:49 UTC · [original](https://github.com/fxceless/victory-fork/pull/853#issuecomment-7162900166) 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.)
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/853/head:github-bot/gh-853'
git switch 'github-bot/gh-853'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-853'
git switch 'github-bot/gh-853'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-853'
git switch 'github-bot/gh-853'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-853'
git switch 'main'
git merge --squash 'github-bot/gh-853'
git switch 'main'
git merge --ff-only 'github-bot/gh-853'
git switch 'main'
git merge 'github-bot/gh-853'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.