Perf/memory guard batching #1884

Open
github-bot wants to merge 5 commits from github-bot/gh-1884 into main AGit
Owner

@⁠VlREX on GitHub · 2026-11-25 00:04 UTC · original
VlREX:perf/memory-guard-batching → main · +150 −2 · 2 files · 5 commits · open

Optimize GPU memory guard batching by sorting and deduplicating alias pages and replacing repeated active-writer scans with a sorted sweep. Synthetic stress model: 4,063,488 linear comparisons reduced to 8,688 sweep checks, excluding sorting. Two independent reference implementations verified 421,875 cases with zero disagreements. Six Rust regression tests included. Native Windows/Rust validation and FPS benchmarking pending. AI-assisted (ChatGPT).

**@⁠VlREX** on GitHub · 2026-11-25 00:04 UTC · [original](https://github.com/Marvisak/VIctory/pull/1884) `VlREX:perf/memory-guard-batching` → `main` · +150 −2 · 2 files · 5 commits · open Optimize GPU memory guard batching by sorting and deduplicating alias pages and replacing repeated active-writer scans with a sorted sweep. Synthetic stress model: 4,063,488 linear comparisons reduced to 8,688 sweep checks, excluding sorting. Two independent reference implementations verified 421,875 cases with zero disagreements. Six Rust regression tests included. Native Windows/Rust validation and FPS benchmarking pending. AI-assisted (ChatGPT).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:47:35 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 08:17 UTC · original · edited 2026-11-25 20:23 UTC

Automated triage for the maintainers.

Needs work. The verdict is unchanged.

Since the last review (a175fff → c14ab1d):

  • docs/memory-guard-batching.md is gone.
  • The over-long assertion in page_batch.rs is wrapped.
  • CI (check) now runs on this head and passes.

The code itself is unchanged: page_batch::eligible sorts and dedups the pages before protect in crates/victory-gpu/src/watch.rs and sweeps sorted writer ranges. It still reads as correct to me.

The benefit is still not shown. @⁠CocoBeans64's native run (RX 6800 XT, 13f91ca) found no regressions and no crashes, but it measured the PR together with #2358. Over two runs per side, frame time and fps did not change beyond the ~6 % noise between identical baseline runs. So no gain is visible at frame level.

What would change the verdict: the guard counters this code affects, before and after, from one session of this PR alone. The diagnostics copystat line already prints them: "protecting … ms" in the watch-time section and "guards: … ms in the handler, … protect calls for … pages". If those show a real cut in protect time or calls, the module earns its place. If they don't, it adds 120 lines for nothing measurable. The PR title is also still the branch name ("Perf/memory guard batching"); please make it descriptive.

CI: passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 08:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/1884#issuecomment-7156837250) · edited 2026-11-25 20:23 UTC <!-- victory-triage v1 head=c14ab1d8144ac2a681eb7a56e34d432af5c8412d verdict=needs-work at=2026-11-25T20:22:45Z --> Automated triage for the maintainers. **Needs work.** The verdict is unchanged. **Since the last review (`a175fff` → `c14ab1d`):** - `docs/memory-guard-batching.md` is gone. - The over-long assertion in `page_batch.rs` is wrapped. - CI (`check`) now runs on this head and passes. The code itself is unchanged: `page_batch::eligible` sorts and dedups the pages before `protect` in `crates/victory-gpu/src/watch.rs` and sweeps sorted writer ranges. It still reads as correct to me. The benefit is still not shown. @⁠CocoBeans64's native run (RX 6800 XT, `13f91ca`) found no regressions and no crashes, but it measured the PR together with #2358. Over two runs per side, frame time and fps did not change beyond the ~6 % noise between identical baseline runs. So no gain is visible at frame level. What would change the verdict: the guard counters this code affects, before and after, from one session of this PR alone. The `diagnostics` copystat line already prints them: "protecting … ms" in the watch-time section and "guards: … ms in the handler, … protect calls for … pages". If those show a real cut in protect time or calls, the module earns its place. If they don't, it adds 120 lines for nothing measurable. The PR title is also still the branch name ("Perf/memory guard batching"); please make it descriptive. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠CocoBeans64 on GitHub · 2026-11-25 19:29 UTC · original

Native Windows run as asked, on Windows 10 22H2 (19045), RX 6800 XT (driver 32.0.21045.5002), Ryzen 7 7800X3D. The PR is merged with #2358 on 13f91ca, plus an Agility SDK runtime (#84), diag build.
cargo test -p victory-gpu: 201 passed, 1 failed. The failure, a_texture_written_in_one_format_reads_in_another_through_a_placed_view, fails the same way on 13f91ca without the PR (#1999).
Benchmark: the same saved game in the prologue, menus by hand, then a scripted camera loop. The figures cover the 300 s after the world shows. Two runs per side:

fps (median) ms/frame (mean) preparing copies GPU copying back
13f91ca 1.5 / 1.5 877 / 773 318 / 297 183 / 147 234 / 198 175 / 177
+ #1884 + #2358 1.6 / 1.5 757 / 764 305 / 289 166 / 152 191 / 196 166 / 156

Two identical baseline runs differ by about 6 % in mean frame time.
No regression and no crash; no fps change beyond that noise.

**@⁠CocoBeans64** on GitHub · 2026-11-25 19:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/1884#issuecomment-7172379863) Native Windows run as asked, on Windows 10 22H2 (19045), RX 6800 XT (driver 32.0.21045.5002), Ryzen 7 7800X3D. The PR is merged with #2358 on `13f91ca`, plus an Agility SDK runtime (#84), diag build. `cargo test -p victory-gpu`: 201 passed, 1 failed. The failure, `a_texture_written_in_one_format_reads_in_another_through_a_placed_view`, fails the same way on `13f91ca` without the PR (#1999). Benchmark: the same saved game in the prologue, menus by hand, then a scripted camera loop. The figures cover the 300 s after the world shows. Two runs per side: | | fps (median) | ms/frame (mean) | preparing | copies | GPU | copying back | |---|---|---|---|---|---|---| | `13f91ca` | 1.5 / 1.5 | 877 / 773 | 318 / 297 | 183 / 147 | 234 / 198 | 175 / 177 | | + #1884 + #2358 | 1.6 / 1.5 | 757 / 764 | 305 / 289 | 166 / 152 | 191 / 196 | 166 / 156 | Two identical baseline runs differ by about 6 % in mean frame time. No regression and no crash; no fps change beyond that noise.
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/1884/head:github-bot/gh-1884'
git switch 'github-bot/gh-1884'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1884'
git switch 'github-bot/gh-1884'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1884'
git switch 'github-bot/gh-1884'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1884'
git switch 'main'
git merge --squash 'github-bot/gh-1884'
git switch 'main'
git merge --ff-only 'github-bot/gh-1884'
git switch 'main'
git merge 'github-bot/gh-1884'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1884
No description provided.