GPU: mark retaken aliases without collecting temporary page numbers #3395

Open
github-bot wants to merge 2 commits from github-bot/gh-3395 into main AGit
Owner

@⁠Desamodeth on GitHub · 2026-11-26 21:58 UTC · original
Desamodeth:perf/stream-retake-aliases → main · +1 −2 · 1 files · 2 commits · open

memory::retake_dropped calls watch::retake for ranges withheld until frame end. Each call collected the linked page numbers into a temporary vector while holding the global guard lock. mark updates each tracker's dirty state, so retake can borrow the alias lists under that lock. It marks the original range first, followed by its aliases in the existing order.

Windows x64, Ryzen 7 9800X3D, rustc 1.98.1 release. Results per call on main@63bcca43 and this change:

Source pages × aliases per page CPU time, before → after Temporary peak, before → after Heap requests, before → after
1 × 0 27.9 → 24.9 ns 0 → 0 B 0 → 0
1 × 1 67.5 → 42.2 ns 32 → 0 B 1 → 0
8 × 1 313 → 258 ns 64 → 0 B 2 → 0
64 × 4 6.55 → 6.08 µs 2,048 → 0 B 7 → 0

The synthetic fixture used the production retake, mark, guard mutex, alias map and dirty trackers. Each measured page had a buffer-copy tracker and a texture tracker. The table uses already-dirty copies to isolate temporary storage. Starting from a clean tracker at 64 × 4, both versions retained 5,976 B of dirty-set nodes. Peak live heap growth fell from 8,024 to 5,976 B. The fixture checked the exact marked pages, the untouched texture tracker, and the range end. Timings are medians of 12 batches in alternating order, with allocation counts from a separate binary. Game frame time was not measured.

Windows checks: cargo test -p victory-gpu --lib watch:: -- --test-threads=1 and workspace Clippy with --all-targets -- -D warnings, both with default features and all features. cargo xtask policy also passed.

Coordination claim. AI-assisted with Codex Astra 6.2 High.

**@⁠Desamodeth** on GitHub · 2026-11-26 21:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/3395) `Desamodeth:perf/stream-retake-aliases` → `main` · +1 −2 · 1 files · 2 commits · open `memory::retake_dropped` calls `watch::retake` for ranges withheld until frame end. Each call collected the linked page numbers into a temporary vector while holding the global guard lock. `mark` updates each tracker's dirty state, so `retake` can borrow the alias lists under that lock. It marks the original range first, followed by its aliases in the existing order. Windows x64, Ryzen 7 9800X3D, rustc 1.98.1 release. Results per call on `main@63bcca43` and this change: | Source pages × aliases per page | CPU time, before → after | Temporary peak, before → after | Heap requests, before → after | | --- | ---: | ---: | ---: | | 1 × 0 | 27.9 → 24.9 ns | 0 → 0 B | 0 → 0 | | 1 × 1 | 67.5 → 42.2 ns | 32 → 0 B | 1 → 0 | | 8 × 1 | 313 → 258 ns | 64 → 0 B | 2 → 0 | | 64 × 4 | 6.55 → 6.08 µs | 2,048 → 0 B | 7 → 0 | The synthetic fixture used the production `retake`, `mark`, guard mutex, alias map and dirty trackers. Each measured page had a buffer-copy tracker and a texture tracker. The table uses already-dirty copies to isolate temporary storage. Starting from a clean tracker at 64 × 4, both versions retained 5,976 B of dirty-set nodes. Peak live heap growth fell from 8,024 to 5,976 B. The fixture checked the exact marked pages, the untouched texture tracker, and the range end. Timings are medians of 12 batches in alternating order, with allocation counts from a separate binary. Game frame time was not measured. Windows checks: `cargo test -p victory-gpu --lib watch:: -- --test-threads=1` and workspace Clippy with `--all-targets -- -D warnings`, both with default features and all features. `cargo xtask policy` also passed. [Coordination claim](https://git.gtahub.st/github/Marvisak--VIctory/issues/1633). AI-assisted with Codex Astra 6.2 High.
AI-assisted-by: Codex Astra 6.2 High
The compact alias list in #3229 offers iter() as does Vec, keeping the retake path compatible with either backing storage.

AI-assisted-by: Codex Astra 6.2 High
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 01:06:32 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 22:08 UTC · original · approved these changes

LGTM — verified on Windows against origin/main (63bcca4).

  • Iterating g.alias_of.range(first..last).flat_map(|(_, links)| links) directly in retake avoids a heap allocation on every call since mark only needs &Guards.
  • cargo test -p victory-gpu --lib watch:: -- --test-threads=1: 15 passed, 0 failed.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 22:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/3395#pullrequestreview-6080997462) · **approved these changes** LGTM — verified on Windows against `origin/main` (`63bcca4`). - Iterating `g.alias_of.range(first..last).flat_map(|(_, links)| links)` directly in `retake` avoids a heap allocation on every call since `mark` only needs `&Guards`. - `cargo test -p victory-gpu --lib watch:: -- --test-threads=1`: 15 passed, 0 failed. - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 22:24 UTC · original · approved these changes

Looks good. watch::retake (crates/victory-gpu/src/watch.rs:840-847) cleanly avoids the temporary Vec<usize> allocation by iterating g.alias_of.range(first..last).flat_map(|(_, links)| links.iter()) directly while holding the shared Guards borrow. mark (watch.rs:851-859) only takes &Guards, does not mutate alias_of, and preserves the GUARDS -> Changed.0 lock ordering.

Verified by merging 31a5b6bd onto origin/main (63bcca43):

  • cargo xtask policy (191 files ok) and cargo clippy --locked -p victory-gpu --all-targets -- -D warnings (default and --features diagnostics) pass cleanly.
  • watch::tests:: (15/15) passes on both RTX 5090 and WARP (--features diagnostics, VICTORY_D3D12_DEBUG=1).
  • Also verified with a multi-alias retake test covering 0, 1, and multiple aliased pages alongside a non-copy tracker: all aliased copy trackers are marked dirty, non-copy trackers remain clean, untouched pages stay clean, and existing page guards stay protected.
**@⁠fuzeofficlal** on GitHub · 2026-11-26 22:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/3395#pullrequestreview-6081101780) · **approved these changes** Looks good. `watch::retake` (`crates/victory-gpu/src/watch.rs:840-847`) cleanly avoids the temporary `Vec<usize>` allocation by iterating `g.alias_of.range(first..last).flat_map(|(_, links)| links.iter())` directly while holding the shared `Guards` borrow. `mark` (`watch.rs:851-859`) only takes `&Guards`, does not mutate `alias_of`, and preserves the `GUARDS -> Changed.0` lock ordering. Verified by merging `31a5b6bd` onto `origin/main` (`63bcca43`): - `cargo xtask policy` (191 files ok) and `cargo clippy --locked -p victory-gpu --all-targets -- -D warnings` (default and `--features diagnostics`) pass cleanly. - `watch::tests::` (15/15) passes on both RTX 5090 and WARP (`--features diagnostics`, `VICTORY_D3D12_DEBUG=1`). - Also verified with a multi-alias retake test covering 0, 1, and multiple aliased pages alongside a non-copy tracker: all aliased copy trackers are marked dirty, non-copy trackers remain clean, untouched pages stay clean, and existing page guards stay protected.
Author
Owner

@⁠Jackster on GitHub · 2026-11-26 22:29 UTC · original

Windows 11, 63bcca4 + this PR, Radeon RX 7900 XTX (gfx1100, 32.0.32029.2010):

  • cargo test -p victory-gpu --lib: 231 passed / 0 failed / 1 ignored — the same counts as unpatched 63bcca4 here.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.

No test is added, so this is behavioural coverage: the watch tests around title_memory_remapped/retake pass, and the change removes the temporary Vec that was collected while the guards lock was held — the range is still first..last and every alias link is still marked. Synthetic only. AI-assisted.

**@⁠Jackster** on GitHub · 2026-11-26 22:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/3395#issuecomment-7204717878) Windows 11, `63bcca4` + this PR, Radeon RX 7900 XTX (gfx1100, 32.0.32029.2010): - `cargo test -p victory-gpu --lib`: 231 passed / 0 failed / 1 ignored — the same counts as unpatched `63bcca4` here. - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. No test is added, so this is behavioural coverage: the watch tests around `title_memory_remapped`/`retake` pass, and the change removes the temporary `Vec` that was collected while the guards lock was held — the range is still `first..last` and every alias link is still marked. Synthetic only. AI-assisted.
This pull request can be merged automatically.
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/3395/head:github-bot/gh-3395'
git switch 'github-bot/gh-3395'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3395'
git switch 'github-bot/gh-3395'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3395'
git switch 'github-bot/gh-3395'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3395'
git switch 'main'
git merge --squash 'github-bot/gh-3395'
git switch 'main'
git merge --ff-only 'github-bot/gh-3395'
git switch 'main'
git merge 'github-bot/gh-3395'
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!3395
No description provided.