GPU: the frame line splits a heap sync's slots by outcome #3233

Open
github-bot wants to merge 3 commits from github-bot/gh-3233 into main AGit
Owner

@⁠Jackster on GitHub · 2026-11-26 14:03 UTC · original
Jackster:gpu/mirror-outcomes → main · +80 −2 · 2 files · 3 commits · open

The frame line reports the time a heap sync takes and the slots it looks at, but not what it does with them. On the world's frames a sync looks at ~400,000-600,000 slots and mirrors ~160,000 of them; which of those get a view, which are already current and which name nothing decides whether a change to the sync can help — batching (#3139) only gains where many slots are unchanged — and today it can only be guessed.

This splits the clause. Measured line from a 300 s world run of the retail title on main (63bcca4), diagnostics build:

heap slots the title copied 129.6 ms (590,643 slots); slot mirrors 161,892
(64,340 made (2,695 textures, 9,439 buffer reads, 8,150 buffer writes,
44,056 other), 828 deferred, 74,847 current, 21,877 nulled, 0 empty, 0 past)

HostHeap::mirror counts what it does with a slot, on every path it can take:

  • made — a host view was created. Of those, from a texture view, from a buffer view a shader reads, from a buffer view it writes through, and other (a constant buffer, or a memory view).
  • deferred — a placed texture left for its read mark (later), which creates nothing.
  • current — the record the slot already held, both before and after prepare.
  • nulled — a record that names no view of ours, over a slot that held one.
  • empty, past — a record that names nothing over a slot that held nothing, and a slot past the heap.

The outcomes sum to the calls by construction (made + deferred + current + nulled + empty + past == mirrors), which the two samples above show exactly: 64,340 + 828 + 74,847 + 21,877 = 161,892. That invariant is the property the first version of this change lacked, and it is why the counters are now reported against the mirror calls rather than against the sync's slot count: mirror also runs from descriptor writes, table binding and make_read, so only the call count is a valid denominator.

What it shows

In this run 68% of the views made are "other" — constant buffers and memory views — not textures (already made lazily on their read marks) and not the per-page scan. That is the number to look at before changing the sync.

Cost and behaviour

No runtime change: the counters and the two predicates they use are #[cfg(feature = "diagnostics")], and the enum's length is now asserted by construction (COUNTERS is the exact variant count, so a counter added without its slot fails to compile rather than reading past the array).

Testing

  • cargo clippy -p victory-gpu --all-targets --features diagnostics -- -D warnings
  • cargo build --release -p victory --features diagnostics
  • the world run above; the line prints with each five-second frame report.

No game data is included in this PR.

Written with an AI assistant.

**@⁠Jackster** on GitHub · 2026-11-26 14:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/3233) `Jackster:gpu/mirror-outcomes` → `main` · +80 −2 · 2 files · 3 commits · open The frame line reports the time a heap sync takes and the slots it looks at, but not what it does with them. On the world's frames a sync looks at ~400,000-600,000 slots and mirrors ~160,000 of them; which of those get a view, which are already current and which name nothing decides whether a change to the sync can help — batching (#3139) only gains where many slots are unchanged — and today it can only be guessed. This splits the clause. Measured line from a 300 s world run of the retail title on `main` (`63bcca4`), diagnostics build: ``` heap slots the title copied 129.6 ms (590,643 slots); slot mirrors 161,892 (64,340 made (2,695 textures, 9,439 buffer reads, 8,150 buffer writes, 44,056 other), 828 deferred, 74,847 current, 21,877 nulled, 0 empty, 0 past) ``` `HostHeap::mirror` counts what it does with a slot, on every path it can take: - **made** — a host view was created. Of those, from a texture view, from a buffer view a shader reads, from a buffer view it writes through, and **other** (a constant buffer, or a memory view). - **deferred** — a placed texture left for its read mark (`later`), which creates nothing. - **current** — the record the slot already held, both before and after `prepare`. - **nulled** — a record that names no view of ours, over a slot that held one. - **empty**, **past** — a record that names nothing over a slot that held nothing, and a slot past the heap. The outcomes sum to the calls by construction (`made + deferred + current + nulled + empty + past == mirrors`), which the two samples above show exactly: 64,340 + 828 + 74,847 + 21,877 = 161,892. That invariant is the property the first version of this change lacked, and it is why the counters are now reported against the mirror calls rather than against the sync's slot count: `mirror` also runs from descriptor writes, table binding and `make_read`, so only the call count is a valid denominator. ### What it shows In this run **68% of the views made are "other"** — constant buffers and memory views — not textures (already made lazily on their read marks) and not the per-page scan. That is the number to look at before changing the sync. ### Cost and behaviour No runtime change: the counters and the two predicates they use are `#[cfg(feature = "diagnostics")]`, and the enum's length is now asserted by construction (`COUNTERS` is the exact variant count, so a counter added without its slot fails to compile rather than reading past the array). ### Testing - `cargo clippy -p victory-gpu --all-targets --features diagnostics -- -D warnings` - `cargo build --release -p victory --features diagnostics` - the world run above; the line prints with each five-second frame report. No game data is included in this PR. Written with an AI assistant.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 14:06:08 +00:00
Author
Owner

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

Verified on RTX 5090 against origin/main (63bcca4):

  • cargo test -p victory-gpu --lib descriptor::host:: -- --test-threads=1 --skip dynamic_slots_are_held_until_released: 14/14 passed.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings & --features diagnostics: clean.
  • cargo xtask policy: 191 files ok.

Cleanly splits heap-sync slot counts by outcome in the frame summary line.

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

**@⁠Dukestar69** on GitHub · 2026-11-26 14:07 UTC · [original](https://github.com/Marvisak/VIctory/pull/3233#pullrequestreview-6075506962) · **approved these changes** Verified on RTX 5090 against `origin/main` (`63bcca4`): - `cargo test -p victory-gpu --lib descriptor::host:: -- --test-threads=1 --skip dynamic_slots_are_held_until_released`: 14/14 passed. - `cargo clippy -p victory-gpu --all-targets -- -D warnings` & `--features diagnostics`: clean. - `cargo xtask policy`: 191 files ok. Cleanly splits heap-sync slot counts by outcome in the frame summary line. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
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/3233/head:github-bot/gh-3233'
git switch 'github-bot/gh-3233'

Merge

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