GPU: coalesce identical write declarations within a submission #435

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

@⁠melon0918 on GitHub · 2026-11-24 03:20 UTC · original
melon0918:perf/avoid-duplicate-gpu-writes → main · +40 −18 · 1 files · 1 commits · open

What changed

World passes declare the same writable shadow-buffer ranges repeatedly. Each repeat used to flush the accumulated refreshes, even after the first declaration had taken the pre-submit snapshot and marked that exact range pending. Store the first declaration per shadow, address and length in the submission batch. Use that same ordered list for copy-back after the fence, replacing the second pass over the deferred command steps.

Verification

  • Windows 10 22H2, RX 7900 XT, AMD driver 25.5.1. cargo test --locked -p victory-gpu --features diagnostics -- --test-threads=1 passed 46 tests with one existing benchmark ignored. The added test covers repeated declarations, overlapping ranges, distinct shadows, and submission boundaries.
  • Compared hardware diagnostic runs of the same local integration stack with this change toggled. Across the first ten comparable world log windows after the transition, median reported CPU copy time was 768 ms/frame before and 109 ms/frame after. These are two real runs with varying draw counts and pipeline compilation, so the numbers describe the observed workload rather than a controlled frame-rate benchmark. The 3D picture is still incomplete.
  • cargo xtask policy passed. The PR contains only source and a synthetic test. AI-assisted (Codex).
**@⁠melon0918** on GitHub · 2026-11-24 03:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/435) `melon0918:perf/avoid-duplicate-gpu-writes` → `main` · +40 −18 · 1 files · 1 commits · open ### What changed World passes declare the same writable shadow-buffer ranges repeatedly. Each repeat used to flush the accumulated refreshes, even after the first declaration had taken the pre-submit snapshot and marked that exact range pending. Store the first declaration per shadow, address and length in the submission batch. Use that same ordered list for copy-back after the fence, replacing the second pass over the deferred command steps. ### Verification - Windows 10 22H2, RX 7900 XT, AMD driver 25.5.1. `cargo test --locked -p victory-gpu --features diagnostics -- --test-threads=1` passed 46 tests with one existing benchmark ignored. The added test covers repeated declarations, overlapping ranges, distinct shadows, and submission boundaries. - Compared hardware diagnostic runs of the same local integration stack with this change toggled. Across the first ten comparable world log windows after the transition, median reported CPU copy time was 768 ms/frame before and 109 ms/frame after. These are two real runs with varying draw counts and pipeline compilation, so the numbers describe the observed workload rather than a controlled frame-rate benchmark. The 3D picture is still incomplete. - `cargo xtask policy` passed. The PR contains only source and a synthetic test. AI-assisted (Codex).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:03:52 +00:00
Author
Owner

@⁠DaviTostes on GitHub · 2026-11-24 03:35 UTC · original

Overlaps with #440: both deduplicate Step::GpuWrite per submission in crates/victory-gpu/src/host.rs, and they conflict textually — git merge-tree --write-tree pr435 pr440 reports CONFLICT (content) in host.rs. Worth choosing one.

Both were verified separately on Arch Linux x86_64, Windows MSVC release build under Wine 11.22 (--test-threads=1):

  • this PR (657efd8): victory-gpu 44 passed, 0 failed, 1 ignored; the new host::batch::exact_gpu_writes_are_declared_once_per_submission passes.
  • #440 (0ba3e44): 44 passed, 0 failed, 1 ignored; its shadow::submission_tests::repeated_gpu_writes_keep_their_first_copy_back_order also passes.

The difference is where the state lives: this PR dedupes in Batch::new_gpu_write and keeps copy-back deferred steps, #440 collects Batch::copy_back in first-declaration order (and adds the ordering test). Both fix the same repeated-range cost.

**@⁠DaviTostes** on GitHub · 2026-11-24 03:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/435#issuecomment-7121235959) Overlaps with #440: both deduplicate `Step::GpuWrite` per submission in `crates/victory-gpu/src/host.rs`, and they conflict textually — `git merge-tree --write-tree pr435 pr440` reports `CONFLICT (content)` in `host.rs`. Worth choosing one. Both were verified separately on **Arch Linux x86_64**, Windows MSVC release build under **Wine 11.22** (`--test-threads=1`): - this PR (`657efd8`): `victory-gpu` **44 passed, 0 failed, 1 ignored**; the new `host::batch::exact_gpu_writes_are_declared_once_per_submission` passes. - #440 (`0ba3e44`): **44 passed, 0 failed, 1 ignored**; its `shadow::submission_tests::repeated_gpu_writes_keep_their_first_copy_back_order` also passes. The difference is where the state lives: this PR dedupes in `Batch::new_gpu_write` and keeps copy-back deferred steps, #440 collects `Batch::copy_back` in first-declaration order (and adds the ordering test). Both fix the same repeated-range cost.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:17 UTC · original

Automated triage for the maintainers.

Needs rebase. This PR does not merge cleanly into current main (ac2525d). Conflicting files: crates/victory-gpu/src/host.rs.

The content has not been reviewed yet; it will be once the branch is rebased onto main.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 00:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/435#issuecomment-7148360114) <!-- victory-triage v1 head=657efd8279422a5e35b51d9240350b223ecfb4e8 verdict=needs-rebase at=2026-11-25T00:13:20Z --> Automated triage for the maintainers. **Needs rebase.** This PR does not merge cleanly into current `main` (ac2525d). Conflicting files: `crates/victory-gpu/src/host.rs`. The content has not been reviewed yet; it will be once the branch is rebased onto `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠jeremygold02 on GitHub · 2026-11-25 02:59 UTC · original · edited 2026-11-25 03:22 UTC

Triage verdict — Narrow the scope and rebase (657efd8)

Evidence

  • There are two things to preserve if this is rebased. Current main at 940d32f already deduplicates exact keys for copy-back and combines their missed status. The remaining opportunity here is reducing repeated preparation before submission. That path still flushes on each unmarked declaration.

Checks and limits

  • The later callback regression on #440 is relevant to the old approval: it saw byte 0 on this head (657efd8) where the expected byte was 33.
  • This is a source comparison and a reference to the published test, not a new GPU run.

Next step

  • #440 is closed unmerged, but its test is worth carrying forward. I’d keep this PR’s exact-key test, preserve the current copy-back eligibility bookkeeping, and verify that a repeated unmarked declaration still flushes before a subsequent host callback.

This verification was AI-assisted.

**@⁠jeremygold02** on GitHub · 2026-11-25 02:59 UTC · [original](https://github.com/Marvisak/VIctory/pull/435#issuecomment-7151482600) · edited 2026-11-25 03:22 UTC **Triage verdict — Narrow the scope and rebase** (`657efd8`) **Evidence** - There are two things to preserve if this is rebased. [Current `main` at `940d32f`](https://github.com/Marvisak/VIctory/blob/940d32f69b22265690a0b5a15d6ded572ba33baf/crates/victory-gpu/src/host.rs#L959-L988) already deduplicates exact keys for copy-back and combines their `missed` status. The remaining opportunity here is reducing repeated preparation before submission. [That path](https://github.com/Marvisak/VIctory/blob/940d32f69b22265690a0b5a15d6ded572ba33baf/crates/victory-gpu/src/host.rs#L1854-L1861) still flushes on each unmarked declaration. **Checks and limits** - The [later callback regression on #440](https://git.gtahub.st/github/Marvisak--VIctory/pulls/440) is relevant to the old approval: it saw byte `0` on this head (`657efd8`) where the expected byte was `33`. - This is a source comparison and a reference to the published test, not a new GPU run. **Next step** - #440 is closed unmerged, but its test is worth carrying forward. I’d keep this PR’s exact-key test, preserve the current copy-back eligibility bookkeeping, and verify that a repeated unmarked declaration still flushes before a subsequent host callback. This verification was AI-assisted.
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/host.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

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